home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 January / PCWorld_2007-01_cd.bin / temacd / reaper / reaper147-install.exe / Effects / SStillwell / randomizer < prev    next >
Encoding:
Text File  |  2006-08-15  |  2.8 KB  |  82 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.  
  14. //
  15. //The name of Thomas Scott Stillwell may not be used to endorse or 
  16. //promote products derived from this software without specific prior written permission. 
  17.  
  18.  
  19. //
  20.  
  21.  
  22. //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
  23. //IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
  24. //FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
  25. //BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  26. //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
  27. //PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  28. //STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
  29. //THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30.  
  31. desc:randomize input note to multiple notes
  32.  
  33. slider1:0<0,255,1>Listen for note#
  34. slider2:0<0,16,1>Listen channel (0=omni)
  35. slider3:0<0,255,1>Starting output note
  36. slider4:0<0,255,1>Ending output note
  37. slider5:0<0,100,0.1>Mix %
  38.  
  39. @init
  40.   bpos=0;
  41.   note_on = 9*16;
  42.   note_off = 8*16;
  43.  
  44. @slider
  45.   note=slider1;
  46.   chan=slider2-1;
  47.   start=slider3;
  48.   end=slider4;
  49.   mix=slider5/100;
  50.  
  51. @block
  52.   bpos=0;
  53.   while(
  54.     midirecv(mpos, msg1, msg2) ? (
  55.       (msg1 & 240) == note_on ? (
  56.         ((msg1 & 15) == chan) || chan==-1 ? (
  57.           (msg2 & 255) == note ? (
  58.             velocity = msg2 & 65280;
  59.             newnote = floor(rand(end-start)) + start;
  60.             newnote == prevnote ? newnote == end ? newnote = start : newnote += 1;
  61.             midisend(mpos, msg1, velocity | newnote);
  62.             prevnote = newnote;
  63.           );
  64.         ) : (
  65.           midisend(mpos, msg1, msg2);
  66.         );
  67.       );
  68.       (msg1 & 240) == note_off ? (
  69.         ((msg1 & 15) == chan) || chan==-1 ? (
  70.           (msg2 & 255) == note ? (
  71.             midisend(mpos, msg1, newnote);
  72.             prevnote = newnote;
  73.           );
  74.         ) : (
  75.           midisend(mpos, msg1, msg2);
  76.         );
  77.       );
  78.     );
  79.   );
  80.  
  81. @sample
  82.   bpos += 1;
  83.   spl0 = spl0 * mix;
  84.   spl1 = spl1 * mix;
  85.