successfully notified release slider UI to move
This commit is contained in:
parent
1fe64e31f7
commit
82f18ed4a0
|
@ -13,15 +13,15 @@
|
|||
#include "GuiConstants.h"
|
||||
|
||||
//==============================================================================
|
||||
JuicySFAudioProcessorEditor::JuicySFAudioProcessorEditor(JuicySFAudioProcessor& p, AudioProcessorValueTreeState& state)
|
||||
JuicySFAudioProcessorEditor::JuicySFAudioProcessorEditor(JuicySFAudioProcessor& p, AudioProcessorValueTreeState& valueTreeState)
|
||||
: AudioProcessorEditor{&p},
|
||||
processor{p},
|
||||
state{state},
|
||||
valueTreeState{valueTreeState},
|
||||
sharedParams{p.sharedParams},
|
||||
midiKeyboard{p.keyboardState, SurjectiveMidiKeyboardComponent::horizontalKeyboard},
|
||||
tablesComponent{p.getFluidSynthModel()},
|
||||
filePicker{p.getFluidSynthModel()},
|
||||
slidersComponent{p.sharedParams, state, p.getFluidSynthModel()}
|
||||
slidersComponent{p.sharedParams, valueTreeState, p.getFluidSynthModel()}
|
||||
{
|
||||
// set resize limits for this plug-in
|
||||
setResizeLimits(
|
||||
|
|
|
@ -49,7 +49,7 @@ private:
|
|||
// access the processor object that created it.
|
||||
JuicySFAudioProcessor& processor;
|
||||
|
||||
AudioProcessorValueTreeState& state;
|
||||
AudioProcessorValueTreeState& valueTreeState;
|
||||
shared_ptr<SharesParams> sharedParams;
|
||||
|
||||
SurjectiveMidiKeyboardComponent midiKeyboard;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "Util.h"
|
||||
#include "SharesParams.h"
|
||||
#include "Params.h"
|
||||
#include "MidiConstants.h"
|
||||
|
||||
using namespace std;
|
||||
using Parameter = AudioProcessorValueTreeState::Parameter;
|
||||
|
@ -28,7 +29,7 @@ AudioProcessor* JUCE_CALLTYPE createPluginFilter();
|
|||
JuicySFAudioProcessor::JuicySFAudioProcessor()
|
||||
: AudioProcessor{getBusesProperties()}
|
||||
, sharedParams{static_pointer_cast<SharesParams>(make_shared<Params>())}
|
||||
, state{*this, nullptr,
|
||||
, valueTreeState{*this, nullptr,
|
||||
{ "PARAMETERS" /* MYPLUGINSETTINGS */ },
|
||||
createParameterLayout()
|
||||
}
|
||||
|
@ -45,7 +46,8 @@ AudioProcessorValueTreeState::ParameterLayout JuicySFAudioProcessor::createParam
|
|||
// for (int i = 1; i < 9; ++i)
|
||||
// params.push_back (std::make_unique<AudioParameterInt> (String (i), String (i), 0, i, 0));
|
||||
|
||||
vector<unique_ptr<AudioParameterInt>> params{
|
||||
// https://stackoverflow.com/a/8469002/5257399
|
||||
unique_ptr<AudioParameterInt> params[] = {
|
||||
make_unique<AudioParameterInt>("attack", "volume envelope attack time", 0, 127, 0, "A" ),
|
||||
make_unique<AudioParameterInt>("decay", "volume envelope sustain attentuation", 0, 127, 0, "D" ),
|
||||
make_unique<AudioParameterInt>("sustain", "volume envelope decay time", 0, 127, 0, "S" ),
|
||||
|
@ -54,7 +56,10 @@ AudioProcessorValueTreeState::ParameterLayout JuicySFAudioProcessor::createParam
|
|||
make_unique<AudioParameterInt>("filterResonance", "low-pass filter resonance attentuation", 0, 127, 0, "Res" ),
|
||||
};
|
||||
|
||||
return { params.begin(), params.end() };
|
||||
return {
|
||||
make_move_iterator(begin(params)),
|
||||
make_move_iterator(end(params))
|
||||
};
|
||||
}
|
||||
|
||||
JuicySFAudioProcessor::~JuicySFAudioProcessor()
|
||||
|
@ -205,12 +210,53 @@ void JuicySFAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
|
|||
fluid_synth_handle_midi_event(fluidSynth, midi_event);
|
||||
delete_fluid_midi_event(midi_event);
|
||||
|
||||
sharedParams->acceptMidiControlEvent(m.getControllerNumber(), m.getControllerValue());
|
||||
switch(static_cast<fluid_midi_control_change>(m.getControllerNumber())) {
|
||||
case SOUND_CTRL2: { // MIDI CC 71 Timbre/Harmonic Intensity (filter resonance)
|
||||
valueTreeState.state.setProperty({"filterResonance"}, m.getControllerValue(), nullptr);
|
||||
break;
|
||||
}
|
||||
case SOUND_CTRL3: { // MIDI CC 72 Release time
|
||||
// valueTreeState.state.setProperty({"release"}, m.getControllerValue(), nullptr);
|
||||
// valueTreeState.state.flushParameterValuesToValueTree();
|
||||
// jassert(dynamic_cast<ExposesComponents*> (editor) != nullptr);
|
||||
RangedAudioParameter *param {valueTreeState.getParameter("release")};
|
||||
// dynamic_cast<AudioParameterInt&>(*param)
|
||||
jassert(dynamic_cast<AudioParameterInt*> (param) != nullptr);
|
||||
AudioParameterInt* castParam {dynamic_cast<AudioParameterInt*> (param)};
|
||||
// castParam->setValue(m.getControllerValue());
|
||||
// castParam->
|
||||
// param->setValue(m.getControllerValue());
|
||||
// param->setValueNotifyingHost(m.getControllerValue());
|
||||
*castParam = m.getControllerValue();
|
||||
break;
|
||||
}
|
||||
case SOUND_CTRL4: { // MIDI CC 73 Attack time
|
||||
valueTreeState.state.setProperty({"attack"}, m.getControllerValue(), nullptr);
|
||||
break;
|
||||
}
|
||||
case SOUND_CTRL5: { // MIDI CC 74 Brightness (cutoff frequency, FILTERFC)
|
||||
valueTreeState.state.setProperty({"filterCutOff"}, m.getControllerValue(), nullptr);
|
||||
break;
|
||||
}
|
||||
case SOUND_CTRL6: { // MIDI CC 75 Decay Time
|
||||
valueTreeState.state.setProperty({"decay"}, m.getControllerValue(), nullptr);
|
||||
break;
|
||||
}
|
||||
case SOUND_CTRL10: { // MIDI CC 79 undefined
|
||||
valueTreeState.state.setProperty({"sustain"}, m.getControllerValue(), nullptr);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AudioProcessorEditor* editor{getActiveEditor()};
|
||||
jassert(dynamic_cast<ExposesComponents*> (editor) != nullptr);
|
||||
ExposesComponents* exposesComponents{dynamic_cast<ExposesComponents*>(editor)};
|
||||
exposesComponents->getSliders().acceptMidiControlEvent(m.getControllerNumber(), m.getControllerValue());
|
||||
// sharedParams->acceptMidiControlEvent(m.getControllerNumber(), m.getControllerValue());
|
||||
|
||||
// AudioProcessorEditor* editor{getActiveEditor()};
|
||||
// jassert(dynamic_cast<ExposesComponents*> (editor) != nullptr);
|
||||
// ExposesComponents* exposesComponents{dynamic_cast<ExposesComponents*>(editor)};
|
||||
// exposesComponents->getSliders().acceptMidiControlEvent(m.getControllerNumber(), m.getControllerValue());
|
||||
} else if (m.isProgramChange()) {
|
||||
fluid_midi_event_t *midi_event(new_fluid_midi_event());
|
||||
fluid_midi_event_set_type(midi_event, static_cast<int>(PROGRAM_CHANGE));
|
||||
|
@ -291,7 +337,7 @@ bool JuicySFAudioProcessor::hasEditor() const
|
|||
AudioProcessorEditor* JuicySFAudioProcessor::createEditor()
|
||||
{
|
||||
// grab a raw pointer to it for our own use
|
||||
return /*pluginEditor = */new JuicySFAudioProcessorEditor (*this, state);
|
||||
return /*pluginEditor = */new JuicySFAudioProcessorEditor (*this, valueTreeState);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
private:
|
||||
void initialiseSynth();
|
||||
|
||||
AudioProcessorValueTreeState state;
|
||||
AudioProcessorValueTreeState valueTreeState;
|
||||
|
||||
FluidSynthModel fluidSynthModel;
|
||||
fluid_synth_t* fluidSynth;
|
||||
|
|
|
@ -106,10 +106,10 @@ void SlidersComponent::acceptMidiControlEvent(int controller, int value) {
|
|||
|
||||
SlidersComponent::SlidersComponent(
|
||||
shared_ptr<SharesParams> sharedParams,
|
||||
AudioProcessorValueTreeState& state,
|
||||
AudioProcessorValueTreeState& valueTreeState,
|
||||
FluidSynthModel* fluidSynthModel)
|
||||
: sharedParams{sharedParams}
|
||||
, state{state}
|
||||
, valueTreeState{valueTreeState}
|
||||
, fluidSynthModel{fluidSynthModel}
|
||||
, envelopeGroup{"envelopeGroup", "Envelope"}
|
||||
, filterGroup{"filterGroup", "Filter"}
|
||||
|
@ -121,39 +121,39 @@ SlidersComponent::SlidersComponent(
|
|||
|
||||
attackSlider.setSliderStyle(style);
|
||||
attackSlider.setRange(rangeMin, rangeMax, rangeStep);
|
||||
attackSlider.onValueChange = makeSliderListener(attackSlider, static_cast<int>(SOUND_CTRL4));
|
||||
// attackSlider.onValueChange = makeSliderListener(attackSlider, static_cast<int>(SOUND_CTRL4));
|
||||
attackSlider.setTextBoxStyle(Slider::TextBoxBelow, true, attackSlider.getTextBoxWidth(), attackSlider.getTextBoxHeight());
|
||||
attackSliderAttachment = make_unique<SliderAttachment>(state, "attack", attackSlider);
|
||||
attackSliderAttachment = make_unique<SliderAttachment>(valueTreeState, "attack", attackSlider);
|
||||
|
||||
decaySlider.setSliderStyle(style);
|
||||
decaySlider.setRange(rangeMin, rangeMax, rangeStep);
|
||||
decaySlider.onValueChange = makeSliderListener(decaySlider, static_cast<int>(SOUND_CTRL6));
|
||||
// decaySlider.onValueChange = makeSliderListener(decaySlider, static_cast<int>(SOUND_CTRL6));
|
||||
decaySlider.setTextBoxStyle(Slider::TextBoxBelow, true, decaySlider.getTextBoxWidth(), decaySlider.getTextBoxHeight());
|
||||
decaySliderAttachment = make_unique<SliderAttachment>(state, "decay", decaySlider);
|
||||
decaySliderAttachment = make_unique<SliderAttachment>(valueTreeState, "decay", decaySlider);
|
||||
|
||||
sustainSlider.setSliderStyle(style);
|
||||
sustainSlider.setRange(rangeMin, rangeMax, rangeStep);
|
||||
sustainSlider.onValueChange = makeSliderListener(sustainSlider, static_cast<int>(SOUND_CTRL10));
|
||||
// sustainSlider.onValueChange = makeSliderListener(sustainSlider, static_cast<int>(SOUND_CTRL10));
|
||||
sustainSlider.setTextBoxStyle(Slider::TextBoxBelow, true, sustainSlider.getTextBoxWidth(), sustainSlider.getTextBoxHeight());
|
||||
sustainSliderAttachment = make_unique<SliderAttachment>(state, "sustain", sustainSlider);
|
||||
sustainSliderAttachment = make_unique<SliderAttachment>(valueTreeState, "sustain", sustainSlider);
|
||||
|
||||
releaseSlider.setSliderStyle(style);
|
||||
releaseSlider.setRange(rangeMin, rangeMax, rangeStep);
|
||||
releaseSlider.onValueChange = makeSliderListener(releaseSlider, static_cast<int>(SOUND_CTRL3));
|
||||
// releaseSlider.onValueChange = makeSliderListener(releaseSlider, static_cast<int>(SOUND_CTRL3));
|
||||
releaseSlider.setTextBoxStyle(Slider::TextBoxBelow, true, releaseSlider.getTextBoxWidth(), releaseSlider.getTextBoxHeight());
|
||||
releaseSliderAttachment = make_unique<SliderAttachment>(state, "release", releaseSlider);
|
||||
releaseSliderAttachment = make_unique<SliderAttachment>(valueTreeState, "release", releaseSlider);
|
||||
|
||||
filterCutOffSlider.setSliderStyle(style);
|
||||
filterCutOffSlider.setRange(rangeMin, rangeMax, rangeStep);
|
||||
filterCutOffSlider.onValueChange = makeSliderListener(filterCutOffSlider, static_cast<int>(SOUND_CTRL5));
|
||||
// filterCutOffSlider.onValueChange = makeSliderListener(filterCutOffSlider, static_cast<int>(SOUND_CTRL5));
|
||||
filterCutOffSlider.setTextBoxStyle(Slider::TextBoxBelow, true, filterCutOffSlider.getTextBoxWidth(), filterCutOffSlider.getTextBoxHeight());
|
||||
filterCutOffSliderAttachment = make_unique<SliderAttachment>(state, "filterCutOff", filterCutOffSlider);
|
||||
filterCutOffSliderAttachment = make_unique<SliderAttachment>(valueTreeState, "filterCutOff", filterCutOffSlider);
|
||||
|
||||
filterResonanceSlider.setSliderStyle(style);
|
||||
filterResonanceSlider.setRange(rangeMin, rangeMax, rangeStep);
|
||||
filterResonanceSlider.onValueChange = makeSliderListener(filterResonanceSlider, static_cast<int>(SOUND_CTRL2));
|
||||
// filterResonanceSlider.onValueChange = makeSliderListener(filterResonanceSlider, static_cast<int>(SOUND_CTRL2));
|
||||
filterResonanceSlider.setTextBoxStyle(Slider::TextBoxBelow, true, filterResonanceSlider.getTextBoxWidth(), filterResonanceSlider.getTextBoxHeight());
|
||||
filterResonanceSliderAttachment = make_unique<SliderAttachment>(state, "filterResonance", filterResonanceSlider);
|
||||
filterResonanceSliderAttachment = make_unique<SliderAttachment>(valueTreeState, "filterResonance", filterResonanceSlider);
|
||||
|
||||
addAndMakeVisible(attackSlider);
|
||||
addAndMakeVisible(decaySlider);
|
||||
|
|
|
@ -14,7 +14,7 @@ class SlidersComponent : public Component,
|
|||
public:
|
||||
SlidersComponent(
|
||||
shared_ptr<SharesParams> sharedParams,
|
||||
AudioProcessorValueTreeState& state,
|
||||
AudioProcessorValueTreeState& valueTreeState,
|
||||
FluidSynthModel* fluidSynthModel);
|
||||
~SlidersComponent();
|
||||
|
||||
|
@ -36,7 +36,7 @@ private:
|
|||
std::function<void()> makeSliderListener(Slider& slider, int controller);
|
||||
|
||||
shared_ptr<SharesParams> sharedParams;
|
||||
AudioProcessorValueTreeState& state;
|
||||
AudioProcessorValueTreeState& valueTreeState;
|
||||
FluidSynthModel* fluidSynthModel;
|
||||
|
||||
GroupComponent envelopeGroup;
|
||||
|
|
Loading…
Reference in New Issue
Block a user