Advertisement
Guest User

Untitled

a guest
Nov 9th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*     Requirements:
  2. * - Use one of Linked Automata Systems, Cellular Automata
  3. * - Have at least three instruments whose material is derived from above system
  4. * - Be at least two minutes in length when played
  5. */
  6.  
  7. // The voice leader is fairly often making small random adjustments using ~changevoice
  8. // The percussion / rhythm / bass feeds the new values for the lead voice into ~fuzzinesstostate
  9. //         and change states if the values cross certain thresholds
  10.  
  11.  
  12.  
  13.  
  14. // TODO: figure out chord transitions and integrate instruments
  15.  
  16.  
  17. // The starting pitch set that song will be derived from
  18. ~startingPitchSet = [0, 1, 4, 5, 7, 11, 12, 16]
  19.  
  20. ~attack = 0.25 // attack (0.01 - 0.5),
  21. ~decay = 0.3 // decay (0.1-0.5)
  22. ~fmrate = 10 // 0 - 1000
  23. ~fmdepth = 0 // 0 - 1
  24. ~arpeggiator = 0 //  0 or 1 for Off or On
  25.  
  26.  
  27. // take in the parameters of the leading voice and return what state the rhythm and bass should move to
  28. ~fuzzinesstostate = {arg currentstate, attack, decay, fmdepth, fmrate, arpeggiator;
  29.  
  30.     ~fuzziness = (fmdepth + (fmrate / 1000) + (attack / 0.5)) / 3;
  31.  
  32.     ~state = 0;
  33.  
  34.     if (~fuzziness < 0.25) {
  35.         ~state = 0;
  36.     } {
  37.         if (~fuzziness < 0.5) {
  38.             ~state = 1;
  39.         } {
  40.             ~state = 2;
  41.         };
  42.     };
  43.  
  44.     // 50% chance we stay on the current state
  45.     if (2.rand == 0) {
  46.         ~state = currentstate;
  47.     };
  48.  
  49.  
  50.     ~state;
  51. };
  52. ~fuzzinesstostate.value(0, 11, 0.5, 500, 0, 5);
  53.  
  54.  
  55. // randomly change leading voice parameters
  56. ~changevoice = {arg attack, decay, fmrate, fmdepth, arpeggiator;
  57.  
  58.     // array with new values for attack, decay, fmrate, fmdepth, arpeggiator to return later
  59.     ~ret = Array.newClear(5);
  60.  
  61.     // change attack
  62.     switch (3.rand,
  63.         0, {~ret[0] = attack;},
  64.         1, {~ret[0] = attack - 0.02;
  65.             if (~ret[0] < 0.01) {
  66.                 ~ret[0] = 0.25;
  67.             }; },
  68.         2, {~ret[0] = attack + 0.02;
  69.             if (~ret[0] > 0.5) {
  70.                 ~ret[0] = 0.25;
  71.             };}
  72.     );
  73.  
  74.     // change decay
  75.     switch (3.rand,
  76.         0, {~ret[1] = decay;},
  77.         1, {~ret[1] = decay - 0.02;
  78.             if (~ret[1] < 0.1) {
  79.                 ~ret[1] = 0.3;
  80.             }; },
  81.         2, {~ret[1] = decay + 0.02;
  82.             if (~ret[1] > 0.5) {
  83.                 ~ret[1] = 0.3;
  84.             };}
  85.     );
  86.  
  87.     // change fmrate
  88.     switch (3.rand,
  89.         0, {~ret[2] = fmrate;},
  90.         1, {~ret[2] = fmrate - 30;
  91.             if (~ret[2] < 10) {
  92.                 ~ret[2] = 500;
  93.             }; },
  94.         2, {~ret[2] = fmrate + 30;
  95.             if (~ret[2] > 1000) {
  96.                 ~ret[2] = 500;
  97.             };}
  98.     );
  99.  
  100.     // change fmdepth
  101.     switch (3.rand,
  102.         0, {~ret[3] = fmrate;},
  103.         1, {~ret[3] = fmrate - 0.05;
  104.             if (~ret[3] < 0.05) {
  105.                 ~ret[3] = 0.5;
  106.             }; },
  107.         2, {~ret[3] = fmrate + 0.05;
  108.             if (~ret[3] > 0.95) {
  109.                 ~ret[3] = 0.5;
  110.             };}
  111.     );
  112.  
  113.     // change arpeggiator (1/4 chance it's changed)
  114.     if (4.rand == 0) {
  115.         ~ret[4] = 1 - arpeggiator
  116.     } {
  117.         ~ret[4] = arpeggiator
  118.     };
  119.  
  120.     ~ret;
  121.  
  122. };
  123.  
  124. // continually call with old values to get new values
  125. ~changevoice.value(0.2, 0.3, 500, 0.1, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement