I have managed to get Sliders onto the main PluginEditor and got them attached to an APVTS and got the Listeners working, all good!
The problem is that my project requires Tabs because there’s no way everything will fit on one screen. I created a new Class for each Tab and I managed to get that working with a basic slider but when it comes to getting all the APVTS stuff working I have hit a brick wall!
If I leave the APVTS Attachment and the ParameterListener in the main PluginEditor Constructor then I cannot access the slider that is now defined in the new Tab Class! If I move all the APVTS Attachment and the ParameterListener stuff over to the new Tab Class then I get a problem trying to access the audioProcessor.apvts from the new Tab Class!!!
I know these are all basic C++ problems but I don’t know C++ very well, so could someone please be so kind as to start by telling me the correct approach?
If I have a bunch of sliders on a Tab, defined in a new Class for that Tab, how do I get the APVTS Attachments and Listeners working, should all that be moved into the new Class or left in the PluginEditor Constructor?
The new Class for the Tab is fairly basic:
class VoicePage : public juce::Component
{
public:
juce::Slider filterCutoffSlider;
VoicePage()
{
addAndMakeVisible(filterCutoffSlider);
filterCutoffSlider.setSliderStyle(juce::Slider::SliderStyle::Rotary);
filterCutoffSlider.setTextBoxStyle(juce::Slider::TextBoxBelow, true, 44, 20);
filterCutoffSlider.setRange(0, 127, 1);
}
void resized() override
{
filterCutoffSlider.setBounds(10, 10, 100, 100);
}
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VoicePage)
};
The PluginEditor Constructor just has this:
TabbedComponentAudioProcessorEditor::TabbedComponentAudioProcessorEditor (TabbedComponentAudioProcessor& p)
: AudioProcessorEditor (&p), audioProcessor (p)
{
//Tabs.setTitle(“Demo tabs”);
const auto tabColour = getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId).darker(0.1f);
Tabs.addTab(“VOICE”, tabColour, new VoicePage(), true);
Tabs.addTab(“GLOBAL”, tabColour, new GlobalPage(), true);
addAndMakeVisible(Tabs);
filterCutoffSliderAttachment = std::make_unique<juce::AudioProcessorValueTreeState::SliderAttachment>(audioProcessor.apvts, "FILTER_CUTOFF", filterCutoffSlider);
audioProcessor.apvts.addParameterListener("FILTER_CUTOFF", this);
setSize (400, 300);
}