I’m trying to build a simple synthesiser which generates a sine wave for the key note and sine waves for its harmonics/overtones when a key on a midi keyboard is pressed. The idea is to allow the user to define an individual adsr envelope for the key note and each harmonic.
My approach: I have a synthesiser object which uses a synthesiserSound and a number of synthesiserVoices. A single synthesiserVoice object contains an adjustable number of wavetable oscillators (the key note and the harmonics). In the gui i want to be able to configure the adsr envelope params for each wavetable oscillator. For now i’m using the standard juce adsr class.
The issue: This approach works as long as i’m using the synthesiser as a monophonic one (number of voices = 1). When i change it to a polyphonic one, it’s not working as i wish. I understand that i have more than one instance of synthesiserVoice when i add more than one voice to the synthesiser. This leads to the problem that i can only change the adsr envelope params of one voice and the other voices are not effected by any changes in the gui.
When i do a change in the adsr envelope params for the first harmonic, i want every first harmonic of each synthesiser voice to be changed.
I think there is probably something wrong with my idea of how to structure my synth. I hope the issue is understandable. Maybe someone can help me?
Thanks in advance
Without seeing the code, very difficult to say what the problem could be. But kind of sounds like you are sharing a single ADSR instance between all the voices, maybe? If that is the case, you need to change your code so that each voice has its own ADSR instance or instances in this case, since you want a separate envelope per harmonic.
Thanks for your reply. What you’re mentioning is actually what i want. I would like to share a single ADSR instance between my voices. So i can make a change for the first harmonic (for example) and this will have impact on every voice.
So at the moment i’m changing the adsr params but it only affects the adsr of one voice.
But here is the link to the repo:
I think what you really want is an ADSR for each voice, but for them all to share the same parameters? That way if you change the attack parameter on the screen it will then go in and change the attack value in all the voices?
Yeah, somehow you’re right. But i think i didn’t explain well. I’ll give it another try:
In the gui, i want to configure different ADSRs for the key note and every harmonic. So i have one component for the key note, one component for the first harmonic, one component for the second harmonic and so on. And each component contains an own ADSR.
And these ADSRs need to be applied to each oscillator of each synthesiser voice.
The problem is no different from a monophonic voice, ie. each note will have an individual envelope which begins with the start of that note. and, each of those envelopes use the same settings. you are just adding more envelopes. if you have a working monophonic solution, then you should be able to just apply that technique for the additional envelopes for each harmonic. Are you just overthinking it?
That sounds quite wrong. Surely you don’t have the ADSR objects as parts of your GUI components? (I didn’t yet look at your code repository…)
sometimes it’s useful to use an envelope generator in a component to draw the envelope
It’s probably not a good idea to apply different individual envelopes to each harmonic, you’ll usually get a series of meaningless uncontrollable beeps. That is, too much effort for poor results.
It’s best if you apply a single envelope to all harmonics, with variations based on some formula. for example you could get a damping effect if the harmonics with high frequencies decay more quickly. you can also do the same with the attack or release to get various effects.
Usually the harmonics respond grouped, with a certain gradient, so you could make for example that the sustained part, some harmonics have more or less level than in the attack, creating a resonance effect. That is, by applying formulas you can create different envelopes that are consistent with each other.
It is true that in many sounds the harmonics seem to have an individual character, but in this case it would be better to treat them with modulations, since they will go up and down in volume repeatedly. Although in the same way it is convenient that they have a coherence with the near harmonics.
Thank you very much all of you. Helped me to understand. I will think about it and get back to it. Will let you know about my solution or, more likely, will ask further questions soon.
What you are describing was a feature on the Kawai K5000 additive synth. They called it Harmonic Envelopes and they had 64 ADSRs for 64 harmonics in the K5000 spectrum. I developed a synth for Reason called Spectra, which is now free via their App Store. I built this same thing into Spectra using 256 harmonics and 256 harmonic envelopes. It sounds to me like you are trying to use a voice for each harmonic. You may want to consider using an FFT for generating the sound. I’m not sure if I truly understand what you are trying to do, but it resonated with me and I hope my response assists you in what you are trying to do.
I think it is a worthwhile project. Could be interesting.
Kind of like fading in various organ drawbars at differing rates…
different rates, but how? Randomly? Harmonics require consistency between them, otherwise they are heard as individual whistles that rise and fall.
There is also another problem, the low notes contain dozens of harmonics, while the high notes only a handful. So the results will be even more unpredictable.
It would be more practical if each slider covered a band of frequencies. having a more manageable group of 8 or 16. In addition to controls that allow you to adjust the amount for each end of the keyboard. for example string sounds will have a much faster harmonic decay on the high notes.