AudioKit v5 - How do I change the waveform of a DunneAudioKit Synth?

111 views Asked by At

I am trying to build a simple synthesizer that will play a MIDINoteNumber using the DunneAudioKit Synth function .play(noteNumber:, velocity:) when a button is pressed.

I am able to produce sound and change a few parameters of the Synth instance (attackDuration, decayDuration, sustainLevel, releaseDuration, etc.), but I do not know how I can change the waveform of the Synth instance itself.

I would like to be able to use .sine, .square, and .sawtooth tables as well as their combinations. Ideally, I would be able to have a sub oscillator, FM pair, and noise generator in addition to the regular oscillators, similar to SynthOne. I do not know if this is even possible with the Synth class.

Ultimately, I am trying to create a polyphonic instrument without running, say, 10 different oscillators all at once.

Right now, I am using the following lines of code to attempt changing the waveform, but it seems to have no effect - the Synth sounds the same if I remove the code or if I use .sine, .square, or .sawtooth:

        self.audio_synth = Synth()
        self.audio_synth.au.setWavetable(Table(.sine).content)

        self.audio_engine.output = self.audio_synth
        try? audio_engine.start()

Any help would be greatly appreciated. A similar post here mentioned using CoreAudio and a variable called SynthVoice, but that went over my head.

Thanks in advance.

0

There are 0 answers