mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-08 04:20:09 +00:00
Add beginChangeGesture/endChangeGesture support to audio demo plug-in
This commit is contained in:
parent
a401655297
commit
b7a85c767a
2 changed files with 35 additions and 4 deletions
|
|
@ -102,16 +102,28 @@ void JuceDemoPluginAudioProcessorEditor::timerCallback()
|
|||
// This is our Slider::Listener callback, when the user drags a slider.
|
||||
void JuceDemoPluginAudioProcessorEditor::sliderValueChanged (Slider* slider)
|
||||
{
|
||||
if (slider == &gainSlider)
|
||||
if (AudioProcessorParameter* param = getParameterFromSlider (slider))
|
||||
{
|
||||
// It's vital to use setValueNotifyingHost to change any parameters that are automatable
|
||||
// by the host, rather than just modifying them directly, otherwise the host won't know
|
||||
// that they've changed.
|
||||
getProcessor().gain->setValueNotifyingHost ((float) gainSlider.getValue());
|
||||
param->setValueNotifyingHost ((float) slider->getValue());
|
||||
}
|
||||
else if (slider == &delaySlider)
|
||||
}
|
||||
|
||||
void JuceDemoPluginAudioProcessorEditor::sliderDragStarted (Slider* slider)
|
||||
{
|
||||
if (AudioProcessorParameter* param = getParameterFromSlider (slider))
|
||||
{
|
||||
getProcessor().delay->setValueNotifyingHost ((float) delaySlider.getValue());
|
||||
param->beginChangeGesture();
|
||||
}
|
||||
}
|
||||
|
||||
void JuceDemoPluginAudioProcessorEditor::sliderDragEnded (Slider* slider)
|
||||
{
|
||||
if (AudioProcessorParameter* param = getParameterFromSlider (slider))
|
||||
{
|
||||
param->endChangeGesture();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -153,6 +165,20 @@ static String ppqToBarsBeatsString (double ppq, double /*lastBarPPQ*/, int numer
|
|||
return s;
|
||||
}
|
||||
|
||||
AudioProcessorParameter* JuceDemoPluginAudioProcessorEditor::getParameterFromSlider (const Slider* slider) const
|
||||
{
|
||||
if (slider == &gainSlider)
|
||||
{
|
||||
return getProcessor().gain;
|
||||
}
|
||||
else if (slider == &delaySlider)
|
||||
{
|
||||
return getProcessor().delay;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Updates the text in our position label.
|
||||
void JuceDemoPluginAudioProcessorEditor::displayPositionInfo (const AudioPlayHead::CurrentPositionInfo& pos)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue