I am new to Juce and C++ and started with the provided tutorials on the main page. I currently completed "Build a MIDI synthesizer (SynthUsingMidiInputTutorial_02.h) and would be interested in an additive synthesizer where I can add several sine waves (harmonics) playing with one key and envelopes.
Does anybody know how to add this features to the basic “Build a MIDI synthesizer” code? Any help is much appreciated thanks!!!
In the tutorial an oscillator is processed, so you would have to create an array of oscillators in a “Sine” class, each of them will have its frequency, phase, and volume and add each of them to the resulting wave. You should set the volume individually using sliders, but a drawing bar editor would be more convenient. The initial phase can be randomized (except the fundamental partial), and the frequency can be obtained from the fundamental following the harmonic series, with some deviation to obtain inharmonicity.
Each oscillator should also have its envelope, but processing hundreds or thousands of full envelopes (taking into account polyphony) is not viable, and no one is going to want to edit dozens of envelopes to obtain uncertain results. It would be better to use a single envelope, or perhaps only for the first harmonics, or another option could be grouping. You could also define relative settings for each harmonic, for example using another bar editor for sustain levels, and adjust the relative attack and decay times using some algorithm, for example you can make the higher frequencies decay faster, obtaining a string sound, or you can assign random settings.
You can also apply volume modulations in the same way as envelopes, you can use drawbars, perhaps individual controls for the first harmonics, algorithms for relative adjustments such as increasing the phase of the modulation in each partial, and randomness.
But if you don’t have good knowledge of Juce and C++ this is going to be very difficult, full of problems. Although it can be a good way to learn and fun if you are not in a big hurry or with big expectations.
Thanks for your detailed reply! As a non programmer it is sometimes hard to understand the complexity of software. I have to get an overview of the project, but I will definitely need help from an experienced programmer later.