-
Notifications
You must be signed in to change notification settings - Fork 0
/
midi_note_splitter_by_cc
107 lines (75 loc) · 8.59 KB
/
midi_note_splitter_by_cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
A Reaper JS plugin (MIDI effect).
MIDI Note Splitter by CC:
Transform a MIDI note number into two note numbers depending
on whether a previously received CC value is higher or lower
than user-defined threshold.
This is useful for transforming variable hi-hat controller messages
with a single hi-hat note into two (open, closed) hi-hat notes.
Written in 2013 - 2014 by Alexander Shaduri <ashaduri 'at' gmail.com>
Changelog:
1.0.2 - Added note names.
1.0.1 - Tweaked plugin UI.
1.0.0 - First public release.
Copyright:
To the extent possible under law, the author(s) have dedicated all
copyright and related and neighboring rights to this software to the
public domain worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication
along with this software. If not, see:
http://creativecommons.org/publicdomain/zero/1.0/
*/
desc: Split MIDI notes by the last received CC value
slider1:4<0,127,1>CC controller:
slider2:65<0,128,1>Use low note if CC value less than:
slider3:128<0,128,1{0 / 0x00 / C0,1 / 0x01 / C#0,2 / 0x02 / D0,3 / 0x03 / D#0,4 / 0x04 / E0,5 / 0x05 / F0,6 / 0x06 / F#0,7 / 0x07 / G0,8 / 0x08 / G#0,9 / 0x09 / A0,10 / 0x0A / A#0,11 / 0x0B / B0,12 / 0x0C / C1,13 / 0x0D / C#1,14 / 0x0E / D1,15 / 0x0F / D#1,16 / 0x10 / E1,17 / 0x11 / F1,18 / 0x12 / F#1,19 / 0x13 / G1,20 / 0x14 / G#1,21 / 0x15 / A1,22 / 0x16 / A#1,23 / 0x17 / B1,24 / 0x18 / C2,25 / 0x19 / C#2,26 / 0x1A / D2,27 / 0x1B / D#2,28 / 0x1C / E2,29 / 0x1D / F2,30 / 0x1E / F#2,31 / 0x1F / G2,32 / 0x20 / G#2,33 / 0x21 / A2,34 / 0x22 / A#2,35 / 0x23 / B2,36 / 0x24 / C3,37 / 0x25 / C#3,38 / 0x26 / D3,39 / 0x27 / D#3,40 / 0x28 / E3,41 / 0x29 / F3,42 / 0x2A / F#3,43 / 0x2B / G3,44 / 0x2C / G#3,45 / 0x2D / A3,46 / 0x2E / A#3,47 / 0x2F / B3,48 / 0x30 / C4,49 / 0x31 / C#4,50 / 0x32 / D4,51 / 0x33 / D#4,52 / 0x34 / E4,53 / 0x35 / F4,54 / 0x36 / F#4,55 / 0x37 / G4,56 / 0x38 / G#4,57 / 0x39 / A4,58 / 0x3A / A#4,59 / 0x3B / B4,60 / 0x3C / C5,61 / 0x3D / C#5,62 / 0x3E / D5,63 / 0x3F / D#5,64 / 0x40 / E5,65 / 0x41 / F5,66 / 0x42 / F#5,67 / 0x43 / G5,68 / 0x44 / G#5,69 / 0x45 / A5,70 / 0x46 / A#5,71 / 0x47 / B5,72 / 0x48 / C6,73 / 0x49 / C#6,74 / 0x4A / D6,75 / 0x4B / D#6,76 / 0x4C / E6,77 / 0x4D / F6,78 / 0x4E / F#6,79 / 0x4F / G6,80 / 0x50 / G#6,81 / 0x51 / A6,82 / 0x52 / A#6,83 / 0x53 / B6,84 / 0x54 / C7,85 / 0x55 / C#7,86 / 0x56 / D7,87 / 0x57 / D#7,88 / 0x58 / E7,89 / 0x59 / F7,90 / 0x5A / F#7,91 / 0x5B / G7,92 / 0x5C / G#7,93 / 0x5D / A7,94 / 0x5E / A#7,95 / 0x5F / B7,96 / 0x60 / C8,97 / 0x61 / C#8,98 / 0x62 / D8,99 / 0x63 / D#8,100 / 0x64 / E8,101 / 0x65 / F8,102 / 0x66 / F#8,103 / 0x67 / G8,104 / 0x68 / G#8,105 / 0x69 / A8,106 / 0x6A / A#8,107 / 0x6B / B8,108 / 0x6C / C9,109 / 0x6D / C#9,110 / 0x6E / D9,111 / 0x6F / D#9,112 / 0x70 / E9,113 / 0x71 / F9,114 / 0x72 / F#9,115 / 0x73 / G9,116 / 0x74 / G#9,117 / 0x75 / A9,118 / 0x76 / A#9,119 / 0x77 / B9,120 / 0x78 / C10,121 / 0x79 / C#10,122 / 0x7A / D10,123 / 0x7B / D#10,124 / 0x7C / E10,125 / 0x7D / F10,126 / 0x7E / F#10,127 / 0x7F / G10,Disable (no input)}>Input note:
slider4:0<0,127,1{0 / 0x00 / C0,1 / 0x01 / C#0,2 / 0x02 / D0,3 / 0x03 / D#0,4 / 0x04 / E0,5 / 0x05 / F0,6 / 0x06 / F#0,7 / 0x07 / G0,8 / 0x08 / G#0,9 / 0x09 / A0,10 / 0x0A / A#0,11 / 0x0B / B0,12 / 0x0C / C1,13 / 0x0D / C#1,14 / 0x0E / D1,15 / 0x0F / D#1,16 / 0x10 / E1,17 / 0x11 / F1,18 / 0x12 / F#1,19 / 0x13 / G1,20 / 0x14 / G#1,21 / 0x15 / A1,22 / 0x16 / A#1,23 / 0x17 / B1,24 / 0x18 / C2,25 / 0x19 / C#2,26 / 0x1A / D2,27 / 0x1B / D#2,28 / 0x1C / E2,29 / 0x1D / F2,30 / 0x1E / F#2,31 / 0x1F / G2,32 / 0x20 / G#2,33 / 0x21 / A2,34 / 0x22 / A#2,35 / 0x23 / B2,36 / 0x24 / C3,37 / 0x25 / C#3,38 / 0x26 / D3,39 / 0x27 / D#3,40 / 0x28 / E3,41 / 0x29 / F3,42 / 0x2A / F#3,43 / 0x2B / G3,44 / 0x2C / G#3,45 / 0x2D / A3,46 / 0x2E / A#3,47 / 0x2F / B3,48 / 0x30 / C4,49 / 0x31 / C#4,50 / 0x32 / D4,51 / 0x33 / D#4,52 / 0x34 / E4,53 / 0x35 / F4,54 / 0x36 / F#4,55 / 0x37 / G4,56 / 0x38 / G#4,57 / 0x39 / A4,58 / 0x3A / A#4,59 / 0x3B / B4,60 / 0x3C / C5,61 / 0x3D / C#5,62 / 0x3E / D5,63 / 0x3F / D#5,64 / 0x40 / E5,65 / 0x41 / F5,66 / 0x42 / F#5,67 / 0x43 / G5,68 / 0x44 / G#5,69 / 0x45 / A5,70 / 0x46 / A#5,71 / 0x47 / B5,72 / 0x48 / C6,73 / 0x49 / C#6,74 / 0x4A / D6,75 / 0x4B / D#6,76 / 0x4C / E6,77 / 0x4D / F6,78 / 0x4E / F#6,79 / 0x4F / G6,80 / 0x50 / G#6,81 / 0x51 / A6,82 / 0x52 / A#6,83 / 0x53 / B6,84 / 0x54 / C7,85 / 0x55 / C#7,86 / 0x56 / D7,87 / 0x57 / D#7,88 / 0x58 / E7,89 / 0x59 / F7,90 / 0x5A / F#7,91 / 0x5B / G7,92 / 0x5C / G#7,93 / 0x5D / A7,94 / 0x5E / A#7,95 / 0x5F / B7,96 / 0x60 / C8,97 / 0x61 / C#8,98 / 0x62 / D8,99 / 0x63 / D#8,100 / 0x64 / E8,101 / 0x65 / F8,102 / 0x66 / F#8,103 / 0x67 / G8,104 / 0x68 / G#8,105 / 0x69 / A8,106 / 0x6A / A#8,107 / 0x6B / B8,108 / 0x6C / C9,109 / 0x6D / C#9,110 / 0x6E / D9,111 / 0x6F / D#9,112 / 0x70 / E9,113 / 0x71 / F9,114 / 0x72 / F#9,115 / 0x73 / G9,116 / 0x74 / G#9,117 / 0x75 / A9,118 / 0x76 / A#9,119 / 0x77 / B9,120 / 0x78 / C10,121 / 0x79 / C#10,122 / 0x7A / D10,123 / 0x7B / D#10,124 / 0x7C / E10,125 / 0x7D / F10,126 / 0x7E / F#10,127 / 0x7F / G10}>Low CC-triggered note:
slider5:0<0,127,1{0 / 0x00 / C0,1 / 0x01 / C#0,2 / 0x02 / D0,3 / 0x03 / D#0,4 / 0x04 / E0,5 / 0x05 / F0,6 / 0x06 / F#0,7 / 0x07 / G0,8 / 0x08 / G#0,9 / 0x09 / A0,10 / 0x0A / A#0,11 / 0x0B / B0,12 / 0x0C / C1,13 / 0x0D / C#1,14 / 0x0E / D1,15 / 0x0F / D#1,16 / 0x10 / E1,17 / 0x11 / F1,18 / 0x12 / F#1,19 / 0x13 / G1,20 / 0x14 / G#1,21 / 0x15 / A1,22 / 0x16 / A#1,23 / 0x17 / B1,24 / 0x18 / C2,25 / 0x19 / C#2,26 / 0x1A / D2,27 / 0x1B / D#2,28 / 0x1C / E2,29 / 0x1D / F2,30 / 0x1E / F#2,31 / 0x1F / G2,32 / 0x20 / G#2,33 / 0x21 / A2,34 / 0x22 / A#2,35 / 0x23 / B2,36 / 0x24 / C3,37 / 0x25 / C#3,38 / 0x26 / D3,39 / 0x27 / D#3,40 / 0x28 / E3,41 / 0x29 / F3,42 / 0x2A / F#3,43 / 0x2B / G3,44 / 0x2C / G#3,45 / 0x2D / A3,46 / 0x2E / A#3,47 / 0x2F / B3,48 / 0x30 / C4,49 / 0x31 / C#4,50 / 0x32 / D4,51 / 0x33 / D#4,52 / 0x34 / E4,53 / 0x35 / F4,54 / 0x36 / F#4,55 / 0x37 / G4,56 / 0x38 / G#4,57 / 0x39 / A4,58 / 0x3A / A#4,59 / 0x3B / B4,60 / 0x3C / C5,61 / 0x3D / C#5,62 / 0x3E / D5,63 / 0x3F / D#5,64 / 0x40 / E5,65 / 0x41 / F5,66 / 0x42 / F#5,67 / 0x43 / G5,68 / 0x44 / G#5,69 / 0x45 / A5,70 / 0x46 / A#5,71 / 0x47 / B5,72 / 0x48 / C6,73 / 0x49 / C#6,74 / 0x4A / D6,75 / 0x4B / D#6,76 / 0x4C / E6,77 / 0x4D / F6,78 / 0x4E / F#6,79 / 0x4F / G6,80 / 0x50 / G#6,81 / 0x51 / A6,82 / 0x52 / A#6,83 / 0x53 / B6,84 / 0x54 / C7,85 / 0x55 / C#7,86 / 0x56 / D7,87 / 0x57 / D#7,88 / 0x58 / E7,89 / 0x59 / F7,90 / 0x5A / F#7,91 / 0x5B / G7,92 / 0x5C / G#7,93 / 0x5D / A7,94 / 0x5E / A#7,95 / 0x5F / B7,96 / 0x60 / C8,97 / 0x61 / C#8,98 / 0x62 / D8,99 / 0x63 / D#8,100 / 0x64 / E8,101 / 0x65 / F8,102 / 0x66 / F#8,103 / 0x67 / G8,104 / 0x68 / G#8,105 / 0x69 / A8,106 / 0x6A / A#8,107 / 0x6B / B8,108 / 0x6C / C9,109 / 0x6D / C#9,110 / 0x6E / D9,111 / 0x6F / D#9,112 / 0x70 / E9,113 / 0x71 / F9,114 / 0x72 / F#9,115 / 0x73 / G9,116 / 0x74 / G#9,117 / 0x75 / A9,118 / 0x76 / A#9,119 / 0x77 / B9,120 / 0x78 / C10,121 / 0x79 / C#10,122 / 0x7A / D10,123 / 0x7B / D#10,124 / 0x7C / E10,125 / 0x7D / F10,126 / 0x7E / F#10,127 / 0x7F / G10}>High CC-triggered note:
slider6:0<0,16,1{Any,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Input channel:
// MIDI-only FX should always have these lines for optimization
in_pin:none
out_pin:none
@init
MSG_NOTE_OFF = 8 * 16;
MSG_NOTE_ON = 9 * 16;
MSG_CC = 11 * 16;
last_cc_value = 127;
@slider
user_cc_number = slider1;
user_border_cc_value = slider2;
user_in_note = slider3;
user_out_small = slider4;
user_out_large = slider5;
user_in_channel = slider6 - 1;
@block
while (
midirecv(offset,msg1,msg23) ? (
channel = msg1 & 15; // Low four bits is channel number (15 == 00001111)
// Is it on our channel or are we using all channels?
(channel == user_in_channel || user_in_channel == -1) ? (
msg_type = msg1 & 240; // High four bits is message type (240 == 11110000)
// If this is a CC event, store its value
(msg_type == MSG_CC && ((msg23&255) == user_cc_number)) ? (
last_cc_value = (msg23/256)&255;
);
// If this is a note event, check and transform it
(msg_type == MSG_NOTE_ON || msg_type == MSG_NOTE_OFF) ? (
note = msg23 & 127;
(note == user_in_note) ? (
velocity = (msg23 / 256) | 0;
//original_note = note;
//comparison_cc_val = last_cc_value;
(last_cc_value < user_border_cc_value) ? (
note = user_out_small;
) : (
note = user_out_large;
);
//modified_note = note;
msg23 = note | (velocity * 256);
);
);
);
midisend(offset,msg1,msg23); // Send the data
1; // Continue until all messages are processed
);
);