I’m working through the second part of the DSP Introduction Tutorial, I’m modifying class Voice : public juice::MPESynthesiserVoice to add a second oscillator. In the noteStarted() function, I’m getting an error calling getCurrentlyPlayingNote():
Cannot initialize object parameter of type ‘const juce::MPESynthesiserVoice’ with an expression of type ‘Voice’
Before I started to add the second oscillator, the demo compiled and ran fine. Now I’m getting this error and I’m not sure why, perhaps I don’t understand enough about how classes are inherited in C++. Thanks for any pointers
We need to see some code to be helpful…
class Voice : public juce::MPESynthesiserVoice
{
public:
Voice()
{
auto& masterGain = processorChain.get();
masterGain.setGainLinear (0.7f);
}
//==============================================================================
void prepare (const juce::dsp::ProcessSpec& spec)
{
tempBlock = juce::dsp::AudioBlock<float> (heapBlock, spec.numChannels, spec.maximumBlockSize);
processorChain.prepare (spec);
}
//==============================================================================
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, true);
processorChain.get<osc2Index>().setLevel (velocity);
}
//==============================================================================
void notePitchbendChanged() override
{
auto freqHz = (float) getCurrentlyPlayingNote().getFrequencyInHertz();
processorChain.get<osc1Index>().setFrequency (freqHz);
processorChain.get<osc1Index>().setFrequency (freqHz * 1.01f);
}