# Creating custom synth voices

**URL:** <https://iplug2.discourse.group/t/creating-custom-synth-voices/613>\
**Category:** Uncategorized\
**Created:** [6 April 2022 18:49 UTC](https://iplug2.discourse.group/t/creating-custom-synth-voices/613 "2022-04-06T18:49:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramdheads](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@ramdheads](https://iplug2.discourse.group/u/ramdheads)\
**Post date:** [6 April 2022 18:49 UTC](https://iplug2.discourse.group/t/creating-custom-synth-voices/613/1 "2022-04-06T18:49:42Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![radiofarmer](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@radiofarmer](https://iplug2.discourse.group/u/radiofarmer)\
**Post date:** [14 April 2022 16:24 UTC](https://iplug2.discourse.group/t/creating-custom-synth-voices/613/2 "2022-04-14T16:24:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ramdheads](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@ramdheads](https://iplug2.discourse.group/u/ramdheads)\
**Post date:** [1 May 2022 19:45 UTC](https://iplug2.discourse.group/t/creating-custom-synth-voices/613/3 "2022-05-01T19:45:01Z")

</div>

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.
