Hi,
I am trying to follow an outdated tutorial and convert it to more C++ as it’s using old JUCE specific pointer type.
I got a drive knob and drive attachment for the GUI. Which is as below:
std::unique_ptr<juce::Slider> driveKnob;
std::unique_ptr<juce::AudioProcessorValueTreeState::SliderAttachment> driveAttachment;
I successfully implemented driveKnob like so:
driveKnob = std::make_unique<juce::Slider>("Drive");
addAndMakeVisible(driveKnob.get());
driveKnob->setSliderStyle(juce::Slider::SliderStyle::Rotary);
driveKnob->setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, false, 100, 100);
Then I try to init driveAttachment like so:
driveAttachment = std::make_unique<juce::AudioProcessorValueTreeState::SliderAttachment>(p.getState(), "drive", driveKnob.get());
the state related definitions from the processor are below:
public:
juce::AudioProcessorValueTreeState& getState();
private:
std::unique_ptr<juce::AudioProcessorValueTreeState> state;
And getState function is below:
juce::AudioProcessorValueTreeState& DistortionAudioProcessor::getState()
{
return *state;
}
The error I am getting is
|Severity|Code|Description|Project|File|Line|Suppression State|
|---|---|---|---|---|---|---|
|Error|C2664|'juce::AudioProcessorValueTreeState::SliderAttachment::SliderAttachment(juce::AudioProcessorValueTreeState &,const juce::String &,juce::Slider &)': cannot convert argument 3 from '_Ty' to 'juce::Slider &'|Distortion_SharedCode|C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\memory|3580||
And for more visual people here is the screenshot of the error log: https://i.gyazo.com/10e8c48245eae7c35c42fad655628a5c.png
the function template looks like so:
// FUNCTION TEMPLATE make_unique
template <class _Ty, class... _Types, enable_if_t<!is_array_v<_Ty>, int> = 0>
_NODISCARD unique_ptr<_Ty> make_unique(_Types&&... _Args) { // make a unique_ptr
return unique_ptr<_Ty>(new _Ty(_STD forward<_Types>(_Args)...));
}