So I’ve been working through the Introduction to DSP Tutorial and had a question about how it uses enums as the indices for the DSP processes.
Basically, it creates the enums and ProcessorChain
enum
{
oscIndex,
gainIndex // [2]
};
juce::dsp::ProcessorChain<juce::dsp::Oscillator<Type>, juce::dsp::Gain<Type>> processorChain;
Then calls the prepare function to prepare the chain.
Then in the constructor does this:
CustomOscillator()
{
auto& osc = processorChain.template get<oscIndex>(); // [5]
osc.initialise ([] (Type x) { return std::sin (x); }, 128); // [6]
}
My question is, how does the code know that oscIndex corresponds to the juce::DSP::Oscillator? More importantly, when/how is oscIndex connected to processorChain in the first place?
To me it just seems like these enums are setup, then the processorChain is initialized independently of that, but somehow the processorChain knows that oscIndex should return the DSP::Oscillator.
Any information greatly appreciated!