home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February / PCWorld_2008-02_cd.bin / audio-video / reaper / reaper2028-install.exe / Effects / SStillwell / randomizer < prev    next >
Text File  |  2007-12-03  |  3KB  |  76 lines

  1. // Copyright 2006, Thomas Scott Stillwell
  2. // All rights reserved.
  3. //
  4. //Redistribution and use in source and binary forms, with or without modification, are permitted 
  5. //provided that the following conditions are met:
  6. //
  7. //Redistributions of source code must retain the above copyright notice, this list of conditions 
  8. //and the following disclaimer. 
  9. //
  10. //Redistributions in binary form must reproduce the above copyright notice, this list of conditions 
  11. //and the following disclaimer in the documentation and/or other materials provided with the distribution. 
  12. //
  13. //The name of Thomas Scott Stillwell may not be used to endorse or 
  14. //promote products derived from this software without specific prior written permission. 
  15. //
  16. //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
  17. //IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
  18. //FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
  19. //BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  20. //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
  21. //PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  22. //STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
  23. //THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24.  
  25. desc:randomize input note to multiple notes
  26.  
  27. slider1:0<0,255,1>Listen for note#
  28. slider2:0<0,16,1>Listen channel (0=omni)
  29. slider3:0<0,255,1>Starting output note
  30. slider4:0<0,255,1>Ending output note
  31. slider5:0<0,100,0.1>Mix %
  32.  
  33. @init
  34.   note_on = 9*16;
  35.   note_off = 8*16;
  36.  
  37. @slider
  38.   note=slider1;
  39.   chan=slider2-1;
  40.   start=slider3;
  41.   end=slider4;
  42.   mix=slider5/100;
  43.  
  44. @block
  45.   while(
  46.     midirecv(mpos, msg1, msg2) ? (
  47.       (msg1 & 240) == note_on ? (
  48.         ((msg1 & 15) == chan) || chan==-1 ? (
  49.           (msg2 & 255) == note ? (
  50.             velocity = msg2 & 65280;
  51.             newnote = floor(rand(end-start)) + start;
  52.             newnote == prevnote ? newnote == end ? newnote = start : newnote += 1;
  53.             midisend(mpos, msg1, velocity | newnote);
  54.             prevnote = newnote;
  55.           );
  56.         ) : (
  57.           midisend(mpos, msg1, msg2);
  58.         );
  59.       );
  60.       (msg1 & 240) == note_off ? (
  61.         ((msg1 & 15) == chan) || chan==-1 ? (
  62.           (msg2 & 255) == note ? (
  63.             midisend(mpos, msg1, newnote);
  64.             prevnote = newnote;
  65.           );
  66.         ) : (
  67.           midisend(mpos, msg1, msg2);
  68.         );
  69.       );
  70.     );
  71.   );
  72.  
  73. @sample
  74.   spl0 = spl0 * mix;
  75.   spl1 = spl1 * mix;
  76.