Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. desc:switchable MIDI transpose
  2.  
  3. slider1:0<-3,3,1}>Transpose (octaves)
  4. slider2:0<-12,12,1>Transpose (semitones)
  5. slider3:0<0,1,1{Active,Bypassed}>Status
  6.  
  7. // these lines tell Reaper the effect has no audio input/output,
  8. // which enables processing optimizations.
  9. // MIDI-only FX should always have these lines.
  10. in_pin:none
  11. out_pin:none
  12.  
  13.  
  14. @init
  15.  
  16. ext_noinit = 1;
  17.  
  18. NOTE_OFF = $x80;
  19. NOTE_ON = $x90;
  20.  
  21. noteSize = 3;
  22. notesBase = 0;
  23. lastIndex = notesBase;
  24.  
  25. @slider
  26.  
  27. transposition = slider1 * 12 + slider2;
  28. bypass = slider3;
  29.  
  30. @block
  31.  
  32. while (
  33. midirecv(offset, msg1, msg23) ? (
  34. channel = msg1 & $x0F;
  35. m = msg1 & $xF0;
  36. m == NOTE_ON || m == NOTE_OFF ?
  37. (
  38. vel = (msg23 / 256) | 0;
  39. vel < 1 ? m = NOTE_OFF;
  40. note = msg23 & 127;
  41. // Look for a note whose status has changed
  42. i = notesBase;
  43. found = 0;
  44. while (
  45. (i < lastIndex) && (i[0] == note) && (i[1] == channel) ? (
  46. shift = i[2];
  47. found = 1;
  48. );
  49. (i += noteSize) < lastIndex && !found;
  50. );
  51. m == NOTE_ON && !found ? (
  52. // Add a new note
  53. shift = bypass ? 0 : transposition;;
  54. i = lastIndex;
  55. i[0] = note;
  56. i[1] = channel;
  57. i[2] = shift;
  58. lastIndex += noteSize;
  59. )
  60. : m == NOTE_OFF && found ? (
  61. // Remove a note
  62. i < lastIndex ? memcpy(i - noteSize, i, lastIndex - i);
  63. lastIndex -= noteSize;
  64. );
  65. note += shift;
  66. note >= 0 && note < 128 ? msg23 += shift;
  67. );
  68. midisend(offset, msg1, msg23);
  69. );
  70. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement