void SimplePianoVisualizerAudioProcessorEditor::sliderValueChanged(juce::Slider *slider)
{
horizontalSliderValue = horizontalSlider.getValue();
verticalSliderValue = verticalSlider.getValue();
// making sure the resized() (UI changes) are made on the UI thread
(new SliderValueChangedCallback(this))->post();
}
void SimplePianoVisualizerAudioProcessorEditor::resized()
{
auto area = getLocalBounds();
auto verticalMargin = area.getHeight()/2.8;
auto keyboardArea = area.removeFromBottom(verticalMargin).reduced(30, 0);
keyWidth = 32 * (horizontalSliderValue/10);
keyboardComponent.setKeyWidth(keyWidth);keyboardComponent.setBounds(keyboardArea.getX(), keyboardArea.getY(), keyboardArea.getWidth(), keyboardArea.getHeight()*(verticalSliderValue/10));
}
auto param = valueTreeState.getParameterAsValue(ParamId);
// getting value
int paramValue = param.getValue();
// setting value
param.setValue(juce::var(newValue));
2. パラメターのリアルタイム値をゲットしたい場合
int value = (int)*valueTreeState.getRawParameterValue(ParamId);
void comboBoxChanged(juce::ComboBox *comboBoxThatHasChanged) override
{
if (comboBoxThatHasChanged == &voicingSelector)
{
controls.clear();
int comboBoxSelectedIndex = comboBoxThatHasChanged->getSelectedId();
if(comboBoxSelectedIndex != 0)
{
DBG("comboBoxSelectedIndex " << comboBoxSelectedIndex);
auto selectorIdParam = valueTreeState.getParameterAsValue(selectorIdString);
// need to cast to juce::var type in order to persist the value in Host...
selectorIdParam.setValue(juce::var(comboBoxSelectedIndex));
}
}
}
復習ですが、ComboBoxの基本的な使い方は以下。。。
// add the parent Component as a listener
// you should remove the listener in the deconstructor
comboBox.addListener(this);
// sets selector id
comboBox.setSelectedId(id, juce::dontSendNotification);