Home AudioKit - AKOperationGenerator with AKParameters - CPU Issue

# AudioKit - AKOperationGenerator with AKParameters - CPU Issue

Jaroslav Coufalík
1#
Jaroslav Coufalík Published in 2018-02-14 08:28:51Z
 I need help with sending AKParameters to the AKOperationGenerator. My current solution use a lot of CPU. Is there a better way how to do it? Here is my example code: import AudioKit class SynthVoice: AKNode { override init() { let synth = AKOperationGenerator { p in //(1) - 30% CPU let osc: AKOperation = AKOperation.squareWave(frequency: p[0], amplitude: p[1], pulseWidth: p[2]) //(2) - 9% CPU //let osc: AKOperation = AKOperation.squareWave(frequency: 440, amplitude: 1, pulseWidth: 0.5) return osc } synth.parameters[0] = 880 synth.parameters[1] = 1 synth.parameters[2] = 0.5 super.init() self.avAudioNode = synth.avAudioNode synth.start() } } class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let mixer: AKMixer = AKMixer([SynthVoice(), SynthVoice(), SynthVoice(), SynthVoice(), SynthVoice(), SynthVoice()]) AudioKit.output = mixer AudioKit.start() } }  I need 6 voice osc bank with envelope filter for each voice. I did not find any OSC-bank with envelope filter in AudioKit, so I started to write my own via AKOperationGenerator... But the CPU is too high. (About 100% in my project - 6 AKOperationGenerator with PWM square osc and envelope filter and a lot of AKParameters that can be changed via UI) Thanks for any response.
Aurelius Prochazka
2#
Aurelius Prochazka Reply to 2018-02-15 07:13:14Z
 I'd definitely do this at the DSP Kernel level. Its C/C++ but its really not too bad. Use one of the AKOscillatorBank type nodes as your model, but in addition to having an amplitude envelope, put in a filter envelope the same way. We're releasing an open source synth that does this exact thing in a few months if you can wait.
 You need to login account before you can post.
Processed in 0.322671 second(s) , Gzip On .