[SOLVED] DSP Tutorial: Adding and Oscillator Exercise

Has anyone gotten the exercise to add a 3rd oscillator working in the Intro to DSP tutorial?
I just duplicated the step to add the 2nd:

I get an error stating:

juce::dsp::gain has no member “setFrequency”

void noteStarted() override
{
    auto velocity = getCurrentlyPlayingNote().noteOnVelocity.asUnsignedFloat();
    auto freqHz = (float)getCurrentlyPlayingNote().getFrequencyInHertz();

    processorChain.get<osc1Index>().setFrequency(freqHz, true);
    processorChain.get<osc1Index>().setLevel(velocity);

    processorChain.get<osc2Index>().setFrequency(freqHz * 1.01f, true);
    processorChain.get<osc2Index>().setLevel(velocity);

    processorChain.get<osc3Index>().setFrequency(freqHz * -1.01f, true);
    processorChain.get<osc3Index>().setLevel(velocity);
}

void notePitchbendChanged() override
{
    auto freqHz = (float)getCurrentlyPlayingNote().getFrequencyInHertz();
    processorChain.get<osc1Index>().setFrequency(freqHz);
    processorChain.get<osc2Index>().setFrequency(freqHz * 1.01f);
    processorChain.get<osc3Index>().setFrequency(freqHz * -1.01f);
}

enum
{
    osc1Index,
    osc2Index,
    osc3Index,
    masterGainIndex
};

I looked through the code and looked for typos, or if there were some limit to t he amount of voices, oscillators etc, but didn’t find anything.
Has anyone worked this out?

You’re calling setFrequency on a juce::dsp::gain which is likely not to have a frequency. I don’t know the tutorial but when you call processorChain.get<osc3Index>() i bet it actually returns you the gain module. I guess you forgot to actually add a third oscillator to your process juce::dsp::ProcessorChain.

1 Like

You’re right!
The chain quite laterally is a chain. You’ve just helped me make sense of the tutorial with that.
I wasn’t sure at which point the chain was more of a figure of speech.
Thanks!