Hi everyone I’m totally new to audio programming and I’m getting started following a tutorial for a drive plugin that is a few years old, so things have changed a bit.
I’m stuck at a part where I need to link the sliders and knobs I’ve initialized to the audio processor value tree state (slider attachment).
The tutorial used scoped pointers which have since been deprecated and I was able to work out how to do it in the up to date framework except one thing, the compiler (I think) says I am dereferencing null pointers. Here are the snippets of code if you could help me out it’d be much appreciated.
Here is the error:
error: no match for ‘operator=’ (operand types are ‘std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment>
from PluginEditor.h:
std::unique_ptr<juce::Slider> driveKnob;
std::unique_ptr<juce::Slider> preVolumeKnob;
std::unique_ptr<juce::Slider> postVolumeKnob;
std::unique_ptr<juce::Slider> lowCut;
std::unique_ptr<juce::Slider> highCut;
std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> driveAttachment;
std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> preVolumeAttachment;
std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> postVolumeAttachment;
std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> lowCutAttachment;
std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> highCutAttachment;
from PluginEditor.cpp
driveKnob = std::make_unique<juce::Slider> ("Drive");
addAndMakeVisible(driveKnob.get());
driveKnob->setSliderStyle(juce::Slider::RotaryVerticalDrag);
driveKnob->setTextBoxStyle(juce::Slider::NoTextBox, false, 100, 100);
preVolumeKnob = std::make_unique<juce::Slider> ("Pre Volume");
addAndMakeVisible(preVolumeKnob.get());
preVolumeKnob->setSliderStyle(juce::Slider::LinearVertical);
preVolumeKnob->setTextBoxStyle(juce::Slider::NoTextBox, false, 100, 100);
postVolumeKnob = std::make_unique<juce::Slider> ("Post Volume");
addAndMakeVisible(postVolumeKnob.get());
postVolumeKnob->setSliderStyle(juce::Slider::LinearVertical);
postVolumeKnob->setTextBoxStyle(juce::Slider::NoTextBox, false, 100, 100);
lowCut = std::make_unique<juce::Slider> ("Low Cut");
addAndMakeVisible(lowCut.get());
lowCut->setSliderStyle(juce::Slider::RotaryVerticalDrag);
lowCut->setTextBoxStyle(juce::Slider::NoTextBox, false, 100, 100);
highCut = std::make_unique<juce::Slider> ("High Cut");
addAndMakeVisible(highCut.get());
highCut->setSliderStyle(juce::Slider::RotaryVerticalDrag);
highCut->setTextBoxStyle(juce::Slider::NoTextBox, false, 100, 100);
driveAttachment = new juce::AudioProcessorValueTreeState::SliderAttachment(p.getState(), "Drive", *driveKnob);
preVolumeAttachment = new juce::AudioProcessorValueTreeState::SliderAttachment(p.getState(), "Pre Volume", *preVolumeKnob);
postVolumeAttachment = new juce::AudioProcessorValueTreeState::SliderAttachment(p.getState(), "Post Volume", *postVolumeKnob);
lowCutAttachment = new juce::AudioProcessorValueTreeState::SliderAttachment(p.getState(), "Low Cut", *lowCut);
highCutAttachment = new juce::AudioProcessorValueTreeState::SliderAttachment(p.getState(), "High Cut", *highCut);
