Hi, so I’ve just finished up the Intro to DSP section and I’ve noticed a couple of things happen when attempting to expand on what I’ve learned.
Adding a 3rd OSC to the Voice class doesn’t create more sound, and as a bonus, the scope no longer outputs any information.
Trying to use the LFO to change the resonance at a slower speed causes the sound to instantly spike, once a note is played and then immediately goes silent until I close the app.
if (lfoUpdateCounter == 0)
lfoUpdateCounter = lfoUpdateRate;
auto lfoOut = lfo.processSample(0.0f);
auto curoffFreqHz = juce::jmap(lfoOut, -1.0f, 1.0f, 100.0f, 2000.0f);
// ******** Update Res Here *****************
processorChain.get<filterIndex>().setResonance(curoffFreqHz * .2);
If anyone has any tips for me, they’d be appreciated
The concepts here were/aren’t very easy for me to grasp(mostly from a programming standpoint) and I’m not sure how to go about understanding them more. I’m hoping that moving to the next tutorial will enlighten.
Without seeing your full code, very difficult to say why adding the new oscillator doesn’t work. Maybe you forgot to change all the relevant parts in the code that deal with the oscillators? Since the oscillators are in a ProcessorChain, things can’t be automatically iterated (at least easily).
Regarding the filter resonance, you may be setting the resonance to some value that isn’t allowed. You are not using the LFO in your code at a different speed but rather reusing the same value you already used for the filter frequency, scaled by 0.2. You would need a second LFO object if you want to modulate the resonance at a different speed. edit : yeah, checking in the Juce code, the resonance value should be equal or greater than 0 and less than 1, but your code will make it go past those limits.
yeah, mine looked almost exactly like that, except my multiplier was -1 at one point, then -12 at another during my experimentation with it.
but under jmap, sourceRangeMin is set to -1.0 and sourceRangeMax to 1.0. targetRangeMin/Max to 100/2000. Not sure what it all means exactly, but that’s what I see.
Where in the code did you find those limits?
Here’s a full copy of the Voice class, if you’re interested (with updates, based on your suggestions):
You are multiplying the 3rd oscillator frequency by some odd factor that makes it several octaves lower/higher than the base frequency of the voice. Remember, you are dealing with Hz values at that point, not with musical notes. If you multiply by 0.5, the oscillator will play one octave lower, if by 2, it will be one octave higher etc. Negative values are not going to work at all.
Your resonance is still mapped to the incorrect range, you should do something like this instead :
auto curresonance = juce::jmap(lfoOut2, -1.0f, 1.0f, 0.0f, 0.95f);
In the jmap the last pair of numbers determines the new range. For the filter cut off, the allowed range is something like 20 to 20000 Hz, but for the resonance the allowed range is from 0 to a bit under 1. The resonance isn’t a frequency parameter but a parameter that changes how the filter curve is shaped around the cut off frequency.