I am trying to make a basic synthesiser plugin. I have a problem with my Slider. When I connect it with a ValueTree, I SOMETIMES get the following error. Sometimes it works without error.
// for a two-value style slider, you should use the setMinValue() and setMaxValue() // methods to set the two values. jassert (style != TwoValueHorizontal && style != TwoValueVertical);
I can’t explain why I’m getting a error about a two-value-slider, even though im not using one. Am I missing something?
I am new to JUCE and to C++ in general so please excuse me if I missed something obvious.
This is how I add the Parameter in PluginProcessor.cpp:
tree (*this, nullptr) tree.createAndAddParameter("osc1_attack", "Osc1_Attack", "Osc1_Attack", envParam, 0, nullptr ,nullptr); //Initialize Tree tree.state = ValueTree("SynthTree");
This is how I create the Slider in PluginEditor.cpp:
osc1AttackSlider.setSliderStyle(Slider::SliderStyle::LinearVertical); osc1AttackSlider.setRange(0.1f, 500.0f); osc1AttackSlider.setValue(0.1f); osc1AttackSlider.addListener(this); osc1AttackSlider.setTextBoxStyle(Slider::TextBoxBelow, false, 50, 20); addAndMakeVisible(&osc1AttackSlider); sliderTree = new AudioProcessorValueTreeState::SliderAttachment(processor.tree, "osc1_attack", osc1AttackSlider);
This is how I declared the sliderTree variable in PluginEditor.h:
AudioProcessorValueTreeState::SliderAttachment* sliderTree;
I followed the very good YouTube Tutorial of “theAudioProgrammer” and he used a ScopedPointer for this. For me that only works for ComboBoxes, if I use it here I get the following error:
/** Returns a raw pointer to the allocated data. This may be a null pointer if the data hasn't yet been allocated, or if it has been freed by calling the free() method. */ inline ElementType* get() const noexcept { return data; }