Creating custom synth voices

Hey, hope this isn’t too much of a noob question.

After so many effect plugins, I’m making my first synth plugin. Basically I want to have 9 objects (i think each could be a midiSynth or voiceallocator) generatting sound from the same midi notes. Each of these midisynths should be using a custom voice, but the function is the same for all objects. On top of that some of these midiSynths should be adding a different number of regular sine wave voices at different frequencies.

So, to clarify, I want 9 objects (probably midisynths). Each of them has a custom voice, which uses an equation involving squares and square roots. Each of them should also have or not a few regular sine waves with different frequencies.

Looking at the IPlugInstrument and documentation I can not figure out how to make my custom voice. Am I better off making my own custom voice class? Also, I am having a hard time undestanding the structure betweem
midisynth - voiceallocator - voice
So if you have some tips on that it would be really nice.

Thanks in advance, and have fun!

The iPlugInstrument example has a custom voice class called Voice derived from the SynthVoice class in the DSP header file, as well as the code that initializes the voice objects, which belong to an instance of MidiSynth. Your oscillator code should go within the ProcessSamplesAccumulating function of the Voice class.

As for the relationship between MidiSynth, VoiceAllocator, and Voice - you shouldn’t need to mess with any classes except Voice if you want standard synth functions, as the example code is quite comprehensive. (When I started my synth plugin, legato voicing wasn’t available in the example code, but it’s been a while since I’ve looked at the examples, so maybe it’s been added.) You basically just need to write your own signal-processing code.

1 Like

Thanks, this was really helpfull.

For any other noobs having trouble with this, I just made an extension of Oscillator.h to make my custom voices. And then, in IPlugInstrument_DSP.h, where mOSC is declared, I declared all my oscilators (including FastSinOscilators and my custom oscilators). Then, wherever mOSC appears I do the same for all my oscilators and delete mOSC. To make it easy i made arrays of oscilators, because I have a lot of them.