Open source synth infrastructure

Hello friends!

The Juce Synth classes are wonderful. But I found myself rewriting very similar code to implement some very basic synth functionality in multiple projects, so I decided to create my own Synth and SynthVoice base classes for my own use.

I frequently see people having issues with correctly implementing a juce::SynthVoice class, so I decided to post my synth code here, and mention that it is 100% free to use, and has proven so-far fool proof (if I can’t break it…)

anyway, here she is:

My goal in writing these base classes was to encapsulate as much of the functionality common to almost every synth as possible, to allow the actual creation of a specific synth to only need to worry about its actual audio generation with its specific oscillators, etc.

My SynthVoiceBase class takes care of ADSRs, click-preventing, tracking note off/cleared, and pretty much everything else. All you need to do is override the actual function that generates the voice’s audio – which the base class will call for you with the correct current desired frequency, taking into account pitch bend, master detune, and everything else. (midi note glide is coming soon! it’s on my list!)

This synth infrastructure provides the following features out of the box with no configuration:

  • built in midi-controlled ADSRs and anti-click “quick-fade” ADSRs
  • applied to each voice: midi velocity/aftertouch gain (with a sensitivity setting), soft pedal gain, playing-but-released gain (ie for sostenuto/sustain pedal, etc), soft pedal gain [each with smoothing]
  • panning – easily control the synth’s stereo spread with one stereo width parameter and a lowest panned note parameter
  • sostenuto, sustain & soft pedal behavior that mimics a real piano’s pedals
  • advanced voice management - polyphonic lines are kept (semi-)consistently in the same synth voices
  • automated midi features
    and more…

This code is 100% free to use. Anyone may freely copy, modify, or distribute this code.

I hope this is helpful. If anyone finds any bugs or has any feature requests, feel free to comment on the GitHub repo or on this thread :slight_smile:


This sounds wonderful. Kudos. While I don’t have need of it this second, I am bookmarking for the future.

1 Like

@benvining, amazing work!

1 Like

Seems very cool. Might you consider extending this to use with MPE? Or even something as simple as implementing MTS-ESP (preprocessor guarded, of course) would be quite nice.

If you don’t feel like it, maybe I will… It seems straightforward enough within the framework of what you have here.

1 Like

Thank you for making me aware of MTS-ESP, this looks awesome! I definitely will put this on my list of things to add.

As far as MPE… I don’t know. For my own personal use cases, I’ve never needed MPE, and glancing through the Juce synth code, it seems to make things quite a bit more verbose.

I could definitely see, without too much difficulty, tracking which channel a note on came from as an extra member in the voice class, which would allow for that extra “tuning for note for channel” feature in MTS-ESP. But to be honest, dealing with multiple channels of pitch bend, and sustain/sostenuto pedal states, seems a bit overboard to me? Only because I don’t personally need it, and I think that it would greatly increase the complexity and decrease the maintainability of this code.

So I could see myself adding support for tracking midi channels of note ons/offs, to use in conjunction with MTS-ESP, and I could also expose that data if MTS-ESP isn’t being used, if that would be useful, but I’m not sure I’ll turn this into a truly MPE-compatible framework ¯_(ツ)_/¯

[github forks are welcome tho]

@zac the module now has support for MTS-ESP, and the voices now store the midi channel that their note on came from. You can access it using voice->getMidiChannel(). The synth as a whole still only has one state for pitchbend and the pedals, as of now.

I’ve never used MTS-ESP before, and I haven’t had time to do any testing with it yet, so let me know if you find any bugs or improvements that could be made.

1 Like


It’s really quite simple and works well. You can use ODDSound’s own master plugin to test synths that support it.

I hope the ease of implementing it will lead to it being implemented more widely.

1 Like

yeah, it was quite easy! Only took me about an hour to add :slight_smile:

I’ll test it out in the next couple of days. Thanks again for letting me know about this!