2

I can't seem to get the AudioKit instruments to behave the way I'd like: I want to be able to change the frequency continuously and also have the instruments play for an infinite amount of time, just like the oscillators. However, I can't even get a simple playground like the following to output any sound:

//: ## Flute
//: Physical model of a Flute
import AudioKitPlaygrounds
import AudioKit

let playRate = 2.0

let flute = AKFlute()

let reverb = AKReverb(flute)

var triggered = false
let performance = AKPeriodicFunction(frequency: playRate) {
    if !triggered {
        flute.frequency = 240.0
        flute.amplitude = 0.6
        flute.play()

        triggered = true
    }
}

AudioKit.output = reverb
try AudioKit.start(withPeriodicFunctions: performance)
performance.start()

import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true

The behavior I want is the ability to set the frequency at any time and have the note ring-out forever. Is this possible?

synchronizer
  • 1,955
  • 1
  • 14
  • 37

1 Answers1

0

Change flute.play() to flute.trigger()

Aurelius Prochazka
  • 4,510
  • 2
  • 11
  • 34