Issue with Custom Oscillator in ProcessorChain

Hi there. I’m trying to build an audio application from scratch basically recreating this DSP tutorial but on my own so that I understand how everything links together. I’m running into an issue when creating the processorChain in the Voice class where it’s not recognizing my syntax for linking a CustomOscillator (in my code, just written as Oscillator). Any guidance on what I might be missing or doing wrong? Included some code snippets & the error below. Thanks in advance!

My constructor for an Oscillator (seems to be working otherwise) in Oscillator.cpp

template <typename Type> Oscillator::Oscillator()
{
    auto& osc = processorChain.template get<oscIndex>();
    osc.initialise ([] (Type x)
                    {
                        return juce::jmap (x,
                                           Type (-juce::MathConstants<double>::pi),
                                           Type (juce::MathConstants<double>::pi),
                                           Type (-1),
                                           Type (1));
                    }, 2);

}

My private members defining the ProcessorChain, & the #include at the top of the Voice.cpp file

#include "Oscillator.h"

...

enum
    {
        osc1Index,
        osc2Index,
        filterIndex,
        masterGainIndex
    };
    
    juce::dsp::ProcessorChain<Oscillator<float>, Oscillator<float>, juce::dsp::LadderFilter<float>, juce::dsp::Gain<float>> customProcessorChain;

Screenshot of the error

Seems it doesn’t see Oscillator as a template, that’s why it wants a closing >.
Is your Oscillator class declared as a template? We only see the constructor being templated…

Hm, I think I see what you’re saying. I may need to look more into Template usage guidelines, here’s my Oscillator.h class though, let me know if it looks correct or if I might be missing something.

class Oscillator
{
public:
    template <typename Type> Oscillator();
    
    template <typename Type> void setFrequency (Type newValue, bool force = false);
    template <typename Type> void setLevel (Type newValue);
    void reset() noexcept;
    template <typename ProcessContext> void process (const ProcessContext& context) noexcept;
    void prepare (const juce::dsp::ProcessSpec& spec);

private:
   
    enum
    {
        oscIndex,
        gainIndex   // [2]
    };
    
    juce::dsp::ProcessorChain<juce::dsp::Oscillator<float>, juce::dsp::Gain<float>> processorChain;
    
    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Oscillator)
};

So you templated the methods instead of the class.

Remove the template command from all the functions. You only need them in the implementation (but then as type of the class namespace).

It should look like:

template <typename Type>
class Oscillator
{
public:
    Oscillator();
// ...
};

// Impl:
template <typename Type>
Oscillator<Type>::Oscillator() {}

Ahhhh I see. Thank you! This solved my problem