-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmidi_note_learned_repeater
131 lines (91 loc) · 9.54 KB
/
midi_note_learned_repeater
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
A Reaper JS plugin (MIDI effect).
Learned MIDI Note Repeater:
This plugin uses two MIDI sources. The first one is a single MIDI
note ("trigger-note"), for example a trigger attached to a bass drum.
The second one is some kind of MIDI controller, which sends
notes ("change-notes") filtered by a configurable range.
This plugin remembers the last received change-note and transforms
any received trigger notes to have the change-note numbers.
Written in 2014 by Alexander Shaduri <ashaduri 'at' gmail.com>
Changelog:
1.0.1 - Added note names.
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: Learned MIDI note repeater
slider1:35<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 trigger note:
slider2:0<0,16,1{Any,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Trigger-note input channel:
slider3:0<0,16,1{Original,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Modified trigger-note output channel:
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}>Change-note min:
slider5:127<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}>Change-note max:
slider6:0<0,16,1{Any,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Change-note channel:
slider7:0<0,1,1{No,Yes}>Change-note passthrough:
slider8:0<0,16,1{Original,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Change-note passthrough 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;
last_change_note = slider5; // change_note_min
@slider
trig_note_value = slider1;
trig_note_input_channel = slider2 - 1;
trig_note_output_channel = slider3 - 1;
change_note_min = slider4;
change_note_max = slider5;
change_note_input_channel = slider6 - 1;
change_note_passthrough = slider7;
change_note_output_channel = slider8 - 1;
@block
while (
midirecv(offset,msg1,msg23) ? (
channel = msg1 & 15; // Low four bits is channel number (15 == 00001111)
block_sending = 0;
// Match channels
(channel == trig_note_input_channel || trig_note_input_channel == -1
|| channel == change_note_input_channel || change_note_input_channel == -1) ? (
msg_type = msg1 & 240; // High four bits is message type (240 == 11110000)
// If this is a note event, check and transform it
(msg_type == MSG_NOTE_ON || msg_type == MSG_NOTE_OFF) ? (
note = msg23 & 127;
is_trigger_note = 0;
is_change_note = 0;
(note == trig_note_value && (channel = trig_note_input_channel || trig_note_input_channel == -1)) ? (
is_trigger_note = 1;
) : (note >= change_note_min && note <= change_note_max
&& (channel = change_note_input_channel || change_note_input_channel == -1)) ? (
is_change_note = 1;
);
(is_change_note) ? (
last_change_note = note;
(change_note_passthrough == 0) ? (
block_sending = 1;
) : (change_note_output_channel != -1) ? (
channel = change_note_output_channel;
);
);
(is_trigger_note) ? (
note = last_change_note;
(trig_note_output_channel != -1) ? (
channel = trig_note_output_channel;
);
);
velocity = (msg23 / 256) | 0;
msg23 = note | (velocity * 256);
msg1 = msg1 - (msg1 & 15) + channel;
);
);
(!block_sending) ? (
midisend(offset,msg1,msg23); // Send the data
);
1; // Continue until all messages are processed
);
);