Skip to content

Commit cd2bec5

Browse files
committed
added an auto pad selection for the edrumulus controller
1 parent abd4672 commit cd2bec5

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

tools/edrumuluscontrol.m

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@
8888
'position', [0.7, 0.75, 0.3, 0.1], ...
8989
'callback', @checkbox_callback);
9090

91+
% auto pad select checkbox
92+
GUI.autopad = false;
93+
GUI.autopad_chbx = uicontrol(figure_handle, ...
94+
'style', 'checkbox', ...
95+
'value', 0, ...
96+
'string', 'Auto Pad Select', ...
97+
'units', 'normalized', ...
98+
'position', [0.7, 0.65, 0.3, 0.1], ...
99+
'callback', @checkbox_callback);
100+
91101
% settings panel
92102
GUI.set_panel = uipanel(figure_handle, ...
93103
'Title', 'Edrumulus settings', ...
@@ -320,12 +330,42 @@
320330
end
321331

322332
end
333+
334+
% auto pad selection
335+
if GUI.autopad
336+
337+
if ~isempty(midi_message) && (midi_message.type == midimsgtype.NoteOn) && ...
338+
(midi_message.channel == 10)
339+
340+
update_pad_selection(midi_message, 38, 40, 0) % snare
341+
update_pad_selection(midi_message, 36, 36, 1) % kick
342+
update_pad_selection(midi_message, 22, 26, 2) % hi-hat
343+
update_pad_selection(midi_message, 49, 55, 4) % crash
344+
update_pad_selection(midi_message, 48, 50, 5) % tom1
345+
346+
end
347+
348+
end
349+
323350
pause(0.01); % do not block the CPU all the time
324351
end
325352

326353
end
327354

328355

356+
function update_pad_selection(midi_message, midi_note1, midi_note2, pad_index)
357+
358+
global GUI;
359+
if ((midi_message.note == midi_note1) || (midi_message.note == midi_note2)) && ...
360+
(round(get(GUI.slider1, 'value')) ~= pad_index)
361+
362+
set(GUI.slider1, 'value', pad_index);
363+
set_slieder_value(GUI.slider1, pad_index, true)
364+
365+
end
366+
367+
end
368+
329369
function midi_out_sel_callback(hObject)
330370

331371
global GUI;
@@ -533,9 +573,15 @@ function button_callback(hObject)
533573
function checkbox_callback(hObject)
534574

535575
global GUI;
576+
switch hObject
577+
case GUI.spike_chbx
578+
% spike cancellation checkbox
579+
midisend(GUI.midi_out_dev, midimsg("controlchange", 10, 110, get(hObject, 'value')));
536580

537-
% spike cancellation checkbox
538-
midisend(GUI.midi_out_dev, midimsg("controlchange", 10, 110, get(hObject, 'value')));
581+
case GUI.autopad_chbx
582+
% auto pad select
583+
GUI.autopad = get(hObject, 'value');
584+
end
539585

540586
end
541587

0 commit comments

Comments
 (0)