Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- desc:switchable MIDI transpose
- slider1:0<-3,3,1}>Transpose (octaves)
- slider2:0<-12,12,1>Transpose (semitones)
- slider3:0<0,1,1{Active,Bypassed}>Status
- // these lines tell Reaper the effect has no audio input/output,
- // which enables processing optimizations.
- // MIDI-only FX should always have these lines.
- in_pin:none
- out_pin:none
- @init
- ext_noinit = 1;
- NOTE_OFF = $x80;
- NOTE_ON = $x90;
- noteSize = 3;
- notesBase = 0;
- lastIndex = notesBase;
- @slider
- transposition = slider1 * 12 + slider2;
- bypass = slider3;
- @block
- while (
- midirecv(offset, msg1, msg23) ? (
- channel = msg1 & $x0F;
- m = msg1 & $xF0;
- m == NOTE_ON || m == NOTE_OFF ?
- (
- vel = (msg23 / 256) | 0;
- vel < 1 ? m = NOTE_OFF;
- note = msg23 & 127;
- // Look for a note whose status has changed
- i = notesBase;
- found = 0;
- while (
- (i < lastIndex) && (i[0] == note) && (i[1] == channel) ? (
- shift = i[2];
- found = 1;
- );
- (i += noteSize) < lastIndex && !found;
- );
- m == NOTE_ON && !found ? (
- // Add a new note
- shift = bypass ? 0 : transposition;;
- i = lastIndex;
- i[0] = note;
- i[1] = channel;
- i[2] = shift;
- lastIndex += noteSize;
- )
- : m == NOTE_OFF && found ? (
- // Remove a note
- i < lastIndex ? memcpy(i - noteSize, i, lastIndex - i);
- lastIndex -= noteSize;
- );
- note += shift;
- note >= 0 && note < 128 ? msg23 += shift;
- );
- midisend(offset, msg1, msg23);
- );
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement