Skip to content

Commit 74932c8

Browse files
committed
synth: Implement CC: All Notes Off & All Sounds Off
1 parent 8d81700 commit 74932c8

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

plugin/MinatonProcess.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,19 @@ void MinatonPlugin::_processMidi(const uint8_t* data, const uint32_t size)
170170
}
171171
// control change. `key` is control's ID (CC ID).
172172
else if (status == 0xb0) {
173-
d_stderr2("[Unimplemented] Control change: CC#%d", key);
173+
if (key == 0x78) { // Process All Notes Off (0x78)
174+
d_stderr("[MIDI] All Notes Off");
175+
fSynthesizer->panic();
176+
177+
last_note = -1;
178+
} else if (key == 0x7b) { // Process All Sounds Off (0x7b)
179+
d_stderr("[MIDI] All Sounds Off");
180+
fSynthesizer->panic();
181+
182+
last_note = -1;
183+
} else {
184+
d_stderr2("[Unimplemented] Control change: CC#%d", key);
185+
}
174186
}
175187
// pitch bend
176188
else if (status == 0xe0) {

src/synth_dpf.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,19 @@ int minaton_synth_dpf::add_wave(string name, const unsigned char* data, size_t s
115115
return number_of_waves - 1;
116116
}
117117

118+
void minaton_synth_dpf::panic()
119+
{
120+
// Setting state to "dormant" can immediately turn all sounds off.
121+
//
122+
// "dormant" is the state when envelope ceases.
123+
// See minaton_synth::dca_update(): part `if (envelope1.state == release)`.
124+
125+
envelope1.state = dormant;
126+
envelope1.level = 0;
127+
envelope2.state = dormant;
128+
envelope2.level = 0;
129+
}
130+
118131
//=========================================================
119132
//-- Accessor for embedded waves
120133
//=========================================================

src/synth_dpf.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class minaton_synth_dpf : public minaton_synth {
3737
void init();
3838
int add_wave(string, const unsigned char*, size_t size);
3939

40+
void panic();
41+
4042
private:
4143
Memory m_memory;
4244
};

0 commit comments

Comments
 (0)