Skip to content

Commit 8a55547

Browse files
committed
UI: Add "Panic" button
1 parent fbe3a8a commit 8a55547

File tree

6 files changed

+348
-19
lines changed

6 files changed

+348
-19
lines changed

plugin/MinatonArtwork.cpp

Lines changed: 292 additions & 18 deletions
Large diffs are not rendered by default.

plugin/MinatonArtwork.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ namespace MinatonArtwork
2525
const unsigned int newknobWidth = 42;
2626
const unsigned int newknobHeight = 42;
2727

28+
extern const char* panic_buttonData;
29+
const unsigned int panic_buttonDataSize = 11200;
30+
const unsigned int panic_buttonWidth = 70;
31+
const unsigned int panic_buttonHeight = 40;
32+
33+
extern const char* panic_button_pressedData;
34+
const unsigned int panic_button_pressedDataSize = 11200;
35+
const unsigned int panic_button_pressedWidth = 70;
36+
const unsigned int panic_button_pressedHeight = 40;
37+
2838
extern const char* sliderData;
2939
const unsigned int sliderDataSize = 6084;
3040
const unsigned int sliderWidth = 39;

plugin/MinatonUI.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ MinatonUI::MinatonUI()
2020
, fSwitchNoLightImage_OFF(Art::switch_off_nolightData, Art::switch_off_nolightWidth, Art::switch_off_nolightHeight, kImageFormatBGRA)
2121
, fImgLabelMixMode(Art::mix_mode_labelData, Art::mix_mode_labelWidth, Art::mix_mode_labelHeight, kImageFormatBGRA)
2222
, fImgLabelMonoStereo(Art::mono_stereo_labelData, Art::mono_stereo_labelWidth, Art::mono_stereo_labelHeight, kImageFormatBGRA)
23-
23+
, fImgPanicButton(Art::panic_buttonData, Art::panic_buttonWidth, Art::panic_buttonHeight)
24+
, fImgPanicButton_Pressed(Art::panic_button_pressedData, Art::panic_button_pressedWidth, Art::panic_button_pressedHeight)
2425
{
2526
// Knob initial angles
2627
constexpr int KNOB_ANGLE = 287;
@@ -100,6 +101,9 @@ MinatonUI::MinatonUI()
100101
// Equalizer params
101102
_createKnob(fCutOffFrequency, PARAM_FREQUENCY, 377, 368, KNOB_ANGLE);
102103
_createKnob(fResonance, PARAM_RESONANCE, 377, 422, KNOB_ANGLE);
104+
105+
// Panic button
106+
_createButton(fPanic, BTN_PANIC, fImgPanicButton, fImgPanicButton_Pressed, 452, 505);
103107
}
104108

105109
void MinatonUI::parameterChanged(uint32_t index, float value)
@@ -279,6 +283,12 @@ void MinatonUI::parameterChanged(uint32_t index, float value)
279283

280284
void MinatonUI::imageButtonClicked(ImageButton* button, int)
281285
{
286+
switch (button->getId()) {
287+
case BTN_PANIC: {
288+
panic();
289+
break;
290+
}
291+
}
282292
}
283293

284294
void MinatonUI::imageSwitchClicked(ImageSwitch* button, bool down)
@@ -365,6 +375,27 @@ void MinatonUI::onDisplay()
365375

366376
void MinatonUI::idleCallback() { }
367377

378+
void MinatonUI::panic()
379+
{
380+
/**
381+
There is no API to send MIDI data to DSP side. Instead, DPF provides UI::sendNote().
382+
But we can still send any MIDI data via this method, simply doing a hack.
383+
384+
In method UI::sendNote(uint8_t channel, uint8_t note, uint8_t velocity):
385+
386+
`channel` will be converted into MIDI data 0 by:
387+
`midi_data[0] = (velocity != 0 ? 0x90 : 0x80) | channel;`
388+
389+
To send MIDI controller data, we need to transform midi_data[0] into MIDI_STATUS_CONTROLLER (0xB0)
390+
by simply applying a proper `channel` value. It would be easy to calculate:
391+
0x80 | channel = 0xB0
392+
=> 0b10000000 | channel = 0b10110000
393+
=> channel = 0b00110000
394+
=> channel = 0x30
395+
*/
396+
sendNote(0x30, 0x7B, 0); // MIDI_CC_ALL_NOTES_OFF = 0x7B
397+
}
398+
368399
// -----------------------------------------------------------------------
369400

370401
UI* createUI()

plugin/MinatonUI.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class MinatonUI : public UI,
6363
Image fSwitchButtonImage_ON, fSwitchButtonImage_OFF;
6464
Image fSwitchNoLightImage_ON, fSwitchNoLightImage_OFF;
6565
Image fImgLabelMixMode, fImgLabelMonoStereo;
66+
Image fImgPanicButton, fImgPanicButton_Pressed;
6667
// ImageAboutWindow fAboutWindow;
6768

6869
// -------------------------------------------------------------------
@@ -93,6 +94,8 @@ class MinatonUI : public UI,
9394

9495
ScopedPointer<ImageKnob> fMasterVolume;
9596

97+
ScopedPointer<ImageButton> fPanic;
98+
9699
// -------------------------------------------------------------------
97100
// Helpers
98101

@@ -101,10 +104,21 @@ class MinatonUI : public UI,
101104
void _createSwitchButton(ScopedPointer<ImageSwitch>& switchButton, MinatonParamId paramId, uint absolutePosX, uint absolutePosY, bool withLight = true);
102105
void _createButton(ScopedPointer<ImageButton>& button, uint id, Image& imageNormal, Image& imagePressed, uint absolutePosX, uint absolutePosY);
103106

107+
// -------------------------------------------------------------------
108+
// Control plugin from UI side
109+
110+
void panic();
104111

105112
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MinatonUI)
106113
};
107114

108115
// -----------------------------------------------------------------------
109116

117+
// --------------------------------
118+
// Button IDs
119+
120+
constexpr uint BTN_PANIC = d_cconst('p', 'n', 'i', 'c');
121+
122+
// -----------------------------------------------------------------------
123+
110124
END_NAMESPACE_DISTRHO

plugin/artwork/panic_button.png

6.46 KB
Loading
6.53 KB
Loading

0 commit comments

Comments
 (0)