diff options
| author | Making Sound Machines <roland@makingsoundmachines.com> | 2024-08-01 22:57:22 +0200 |
|---|---|---|
| committer | Making Sound Machines <roland@makingsoundmachines.com> | 2024-08-01 22:57:22 +0200 |
| commit | df5950d5baedea61eb51b674077afe00218a83ce (patch) | |
| tree | 2fe7f8fd378ef06ef6e2d15262320bb81e3e7dec /sw/Core/Src/plinky.c | |
| parent | 20df8dfa669f9ef70b591c01a67c1e2b133a40a6 (diff) | |
| download | plinky-df5950d5baedea61eb51b674077afe00218a83ce.tar.gz | |
Unprinted pad sets MIDI I/O channels
Diffstat (limited to 'sw/Core/Src/plinky.c')
| -rwxr-xr-x | sw/Core/Src/plinky.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/sw/Core/Src/plinky.c b/sw/Core/Src/plinky.c index 90df966..fdf9a9b 100755 --- a/sw/Core/Src/plinky.c +++ b/sw/Core/Src/plinky.c @@ -1500,6 +1500,11 @@ const s8 midicctable[128] = { /* 112 */ P_DLRATIO, P_DLWOB, P_RVWOB, -1, P_JIT_POS, P_JIT_GRAINSIZE, P_JIT_RATE, P_JIT_PULSE,
/* 120 */ -1, -1, -1, -1, -1, -1, -1, -1,
};
+
+
+
+
+
bool midi_receive(unsigned char packet[4]); // usb midi poll
void processmidimsg(u8 msg, u8 d1, u8 d2);
bool processusbmidi(void) {
@@ -1532,12 +1537,19 @@ bool send_midimsg(u8 status, u8 data1, u8 data2); void processmidimsg(u8 msg, u8 d1, u8 d2) {
u8 chan = msg & 15;
u8 type = msg >> 4;
- if ((chan != 0)&&(type != 0xF)) //LPZW KAY Fix for MIDI Sync type == F continue
+
+ //int midi_ch_in = ((GetParam(P_MIDI_CH_IN, 0) * 16)/FULL) & 15;
+ //int midi_ch_in = clampi(((GetParam(P_MIDI_CH_IN, 0) * 15)/FULL),0,15);
+
+ int midi_ch_in = clampi((mini(GetParam(P_MIDI_CH_IN, 0), FULL - 1) * 16) / FULL,0,15);
+
+ //if ((chan != 0)&&(type != 0xF)) // chan != 0 = allow all channels; LPZW KAY Fix for MIDI Sync type == F continue
+ if ((chan != midi_ch_in)&&(type != 0xF)) // allow only selected channel and MIDI sync
return;
if (type < 8)
return;
-// send_midimsg(msg, d1, d2); // midi echo!
+ // send_midimsg(msg, d1, d2); // midi echo!
if (type == 9 && d2 == 0)
type = 8;
@@ -2972,13 +2984,22 @@ bool send_midi_serial(const u8 *data, int len) { }
bool send_midimsg(u8 status, u8 data1, u8 data2) { // returns false if too full
+
u8 len=3;
- if (status>=0xc0 && status<0xe0)
+
+ if (status>=0xc0 && status<0xe0) // Cn Program Change, Dn Mono / Channel Aftertouch
len=2;
if (!(status&0x80))
return true;
if (status == 0x80 && data1 == 0)
return true; // er, no
+
+ //int midi_ch_out = ((GetParam(P_MIDI_CH_OUT, 0) * 16)/FULL) & 15;
+ //int midi_ch_out = clampi(((GetParam(P_MIDI_CH_OUT, 0) * 16)/FULL),0,15);
+ int midi_ch_out = clampi((mini(GetParam(P_MIDI_CH_OUT, 0), FULL - 1) * 16) / FULL,0,15);
+
+ if (status<0xf0) status += midi_ch_out; // sets output channel
+
u8 buf[4]={status>>4, status,data1,data2};
usb_midi_write(buf);
#ifdef DEBUG
|
