Home AudioKit - AKOperationGenerator with AKParameters - CPU Issue
Reply: 0

AudioKit - AKOperationGenerator with AKParameters - CPU Issue

user1518
1#
user1518 Published in June 21, 2018, 4:39 am

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.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.342174 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO