Guest User

Untitled

a guest
Jan 25th, 2016
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.04 KB | None | 0 0
  1. ((
  2.   // abcdeghi is what bar you're currently on in the stepper, which is s.
  3.   // s rises very slowly relative to t. we set it to step 0-7 inclusive
  4.   // and for each step in the bars (0-7) we assign a letter variable to it
  5.   // to save space. This is the bass note layout for each bar.
  6.   (a = (s = floor(t / 9600 % 8)) == 0) * (y = t * 2) * 1.5873 +
  7.   (b = (s == 1)) * y * (v = 1.4983) +
  8.   (c = (s == 2)) * y * v +
  9.   (d = (s == 3)) * y +
  10.   (e = (s == 4)) * y * 1.5873 +
  11.   (g = (s == 5)) * y * v +
  12.   (h = (s == 6)) * y +
  13.   (i = (s == 7)) * y
  14.  )%(m = 256)+
  15.  (
  16.   // u is an octave frequency, 4x the frequency of y (bass line) which is 2x the frequency of t (raw counter % 256)
  17.   // the constant multipliers above and below are derived from the formula
  18.   // as described on http://www.phy.mtu.edu/~suits/NoteFreqCalcs.html
  19.   // to solve for a note offset, plug a constant into the formula f/(12th root of 2)
  20.   // notice how we're using multiple bar identifier for the same notes.
  21.   // this is another code shrinker.
  22.   // also, v is = to 1.4983. I just used it so much
  23.   // in the song I replaced it with a variable.
  24.   (a | e) * (u = y * 4) * v +
  25.   u *
  26.   (
  27.    (b | c | g | h) * 1.3348 +
  28.    d * 0.8908 +
  29.    i * 1.2599
  30.   )
  31.   // the above is equivalent to
  32.   // u*(
  33.   //    (s == 0) * 1.4983 +
  34.   //    (s == 1) * 1.3348 +
  35.   //    (s == 2) * 1.3348 +
  36.   //    (s == 3) * 0.8908 +
  37.   //    (s == 4) * 1.4983 +
  38.   //    (s == 5) * 1.3348 +
  39.   //    (s == 6) * 1.3348 +
  40.   //    (s == 7) * 1.2599
  41.   //   )
  42.  )%m +
  43.  (
  44.   u *
  45.   (
  46.    i + (a | e) * 1.1892 +
  47.    (b | c | g | h) * 1.1224 +
  48.    d * v
  49.   )
  50.  )%m +
  51.  (
  52.   u *
  53.   (
  54.    (a | e) +
  55.    (b | g | h) * 0.8908 +
  56.    c * 0.9438 +
  57.    d * 1.1892 +
  58.    i * 0.7491
  59.   )
  60.  )%m +
  61.  (
  62.   u *
  63.   (
  64.    (a | e) * 0.7937 +
  65.    (b | c | g | h) * 0.7491 +
  66.    d / 2 + i * 0.627
  67.   )
  68.  )%m)/8 *
  69.  (
  70.  // now this is where the gating/chord groove happens
  71.  // during the duration of the 8 bars above, there's
  72.  // 96 steps. w represents each step as it occurs.
  73.  // as the number '1' is bitshifted through each set
  74.  // of hex numbers, if it lines up with another 1, it
  75.  // will activate the above chord to be played by
  76.  // evaluating to 1, otherwise, it will be zero and
  77.  // mute the above chords.
  78.  // I'm not doing any sort of fancy tempo changes for the groove
  79.  // er, i guess the best way to show how the groove works is with a
  80.  // pseudo tracker interface
  81.  // C-5 --
  82.  // --- --
  83.  // D-5 --
  84.  // C-5 --
  85.  // --- --
  86.  // D-5 --
  87.  // E-5 --
  88.  // --- --
  89.  // G-5 --
  90.  // manual swing i guess you can call it
  91.   (((w = floor(t / 800 % 96)) < 32) * (1 << w & 0xC007307) +
  92.     (w >= 32 && w < 64) * (1 << w & 0x73070E70) +
  93.     (w > 64) * (1 << w & 0xE70C400)) != 0
  94.   ) +
  95.  
  96.   // noise generators
  97.   (t * sin(t * cos(t)) % 18 + 25) * ((1 << (t / 200 % 24) & 1052928) != 0) +
  98.   (t * sin(t * cos(t)) % 38 + 75) * ((1 << (t / 400 % 24) & 12288) != 0) +
  99.   (tan(sin(t * cos(t))) * 32 + 74) * (t % sin(t / 33) < cos(0.032 * t)) * ((1 << (t / 400 % 24) & 1) != 0) +
  100.   // same concept as above, except they're running on much smaller loops.  
  101.  
  102.   // melody!
  103.   // manually changes the frequency based on what
  104.   // tick we're on (0-95)
  105.   // zero is considered to be off... but sometimes we need the root note,
  106.   // so we just use a number really close to zero! !! ! ! HAX
  107.   (pow(1.059463,
  108.          z = ((w == 83 |
  109.                w == 77 |
  110.                w == 63 |
  111.                w == 35 |
  112.                w == 17 |
  113.                w == 51 |
  114.                w == 47 |
  115.                w == 9  |
  116.                w == 0  |
  117.                w == 30) * -5 +
  118.               (w == 3) * 0.1 +
  119.               (w == 41 | w == 6 | w == 74) * -2 +
  120.               (w == 72 |
  121.                w == 66 |
  122.                w == 80 |
  123.                w == 59 |
  124.                w == 62 |
  125.                w == 29 |
  126.                w == 18 |
  127.                w == 54 |
  128.                w == 15 |
  129.                w == 12) * -7 +
  130.               (w == 69 | w == 56 | w == 26 | w == 20 | w == 14) * -9 +
  131.               (w == 21) * -12 +
  132.               (w == 50 | w == 44 | w == 33) * -4 +
  133.               (w == 93) * -6)
  134.      )*u * 2)%m / 4 * (z != 0)
Add Comment
Please, Sign In to add comment