I have the following code for AudioKit v5. The intention is to have a PitchTap for tuning and also be able to play a plucked string note. The problem is that no sound ever comes out. I have connected the PluckedString directly to the output and still no sound. Using AK v4 this worked fine. It's probably something stupid, but I can't find it. When followed in the debugger everything seems to work fine and all values are as expected.
Everything is up to date release versions AFAIK, except AK 5 which is under SPM. MacOS, XCode, iOS, 11 Pro Max simulator.
Is there perhaps an issue with AK 5 PluckedString?
private let pluckedString : PluckedString
private let engine = AudioEngine()
private var pitchTap: PitchTap
private let mixer1: Mixer
private let mixer2: Mixer
private let mic: AudioEngine.InputNode
private let silence : Fader
private let startTime = NSDate.timeIntervalSinceReferenceDate
init() {
mic = engine.input
mixer1 = Mixer(mic)
silence = Fader(mixer1, gain: 0)
mixer2 = Mixer(silence)
pitchTap = PitchTap(mic, handler: {_ , _ in })
pluckedString = PluckedString(frequency: Float(NoteList.shared.minFreq),
amplitude: 1.0)
mixer2.addInput(pluckedString)
engine.output = pluckedString
// engine.output = mixer2
self.pitchTap = PitchTap(mic, handler:
{ freq, amp in
let t = round((NSDate.timeIntervalSinceReferenceDate-self.startTime)*100)/100
if (amp[0] > self.ampThreshhold) {
self.sample(freq: freq[0], amp: amp[0])
}
})
do {
try engine.start()
akStartSucceeded = true
} catch {
akStartSucceeded = false
}
} // init
func hammer(note: Note) -> Void {
pluckedString.trigger(frequency: note.frequency, amplitude: 1.0)
pluckedString.$amplitude.ramp(to: 0.0, duration: 1.5)
print("Play frequency: " + String(note.frequency) + " Midi Note Number:" + String(note.noteNumber))
} // hammer