Using AKBooster with AKAmplitudeTracker in Audiokit

Viewed 507

My question here is about adding an AKBooster to AKAmplitudeTracker before it gets added to the output later in the signal chain. It should look something like this:

do {
   try sprite.MIDISamplerPlayer.loadAudioFile(myAudioFile)
} catch let error as NSError {
   print("There's an error: \(error)")
}

sprite.amplitudeTracker = AKAmplitudeTracker(sprite.MIDISamplerPlayer)
sprite.silentBooster = AKBooster(sprite.amplitudeTracker)

sprite.silentBooster?.gain = 0

sprite.silentBooster! >>> mixer
sprite.MIDISamplerPlayer.enableMIDI(sprite.samplerMIDI.client, name: "My MIDISampler")
sprite.MIDISamplerPlayer >>> mixer

sequencer = AKSequencer(filename: myMIDI)

AudioKit.output = mixer
AudioKit.start()

sequencer!.play()

The issue I'm having is that the gain is reporting as 0.0 but volume is playing as normal, ie the gain has no effect on the output.

I can't have AKBooster added to signal chain at the end as I want the AKBooster to be added to tracks in the sequencer.

Ideas on how to solve this much appreciated! Thanks 8•)

EDITED missed some steps in my process, noticed after Aure's answer below...

2 Answers

I think you're not putting the booster in the chain. You'd have to do

sprite.silentBooster >>> mixer

instead of sprite.MIDIsampler or else neither the tracker nor the booster will have audio pulled through it.

Thanks to Aure again (as his suggestion solved the issue). Amended code as follows, and now working as expected.

sprite.amplitudeTracker = AKAmplitudeTracker(sprite.MIDISamplerPlayer)
sprite.MIDISamplerPlayer.enableMIDI(sprite.samplerMIDI.client, name: "My MIDISampler")
sprite.silentBooster = AKBooster(sprite.amplitudeTracker)

sprite.silentBooster?.gain = 0
sprite.silentBooster! >>> mixer

//sprite.MIDISamplerPlayer >>> mixer
Related