SHARE
TWEET

fluffy birds source code

a guest Jun 9th, 2019 164 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (
  2. {
  3.     // change these
  4.     var fund = MouseX.kr(6.448, 7.281);
  5.     var snappiness = MouseY.kr(0, 4);
  6.     var ascendiness = 0-SinOsc.kr(0.1).range(0.2, 0.4); // octaves or hertz per second, depending on interval
  7.     var interval = pi / 20; // <10 read as octaves, >=10 read as hertz
  8.     var wrapLo = 8;
  9.     var wrapHi = 14.55;
  10.     var rollLo = 2;
  11.     var rollHi = 2;
  12.     var fundRollStart = 1;
  13.     var fundRoll = 2;
  14.     var riseOff = -1.3;
  15.     var master = 5;
  16.  
  17.     // don't mess with these
  18.     var wrapLoHertz = 2 ** wrapLo;
  19.     var wrapHiHertz = 2 ** wrapHi;
  20.     var fundHertz = 2 ** fund;
  21.  
  22.     var tones, practicalWrapLo, gliders, glidersHertz,
  23.         snapLoHertz, snapLo, snapHi, snapMid, signedHalfDist, snapped,
  24.         overRollLo, startCurve, wrapRollMultiplier, fundRollProgress, fundRollMultiplier,
  25.         earDistance, rightness, forwardness, distance, delay, mulRaw, mul,
  26.         snappedHertz, amp, group, panned, out;
  27.     if(interval < 10, {
  28.     tones = roundUp((wrapHi - wrapLo) / interval);
  29.     practicalWrapLo = wrapHi - (tones * interval);
  30.     gliders = max(
  31.         Wrap.kr(LFSaw.kr(ascendiness / (wrapHi - practicalWrapLo))
  32.         .range(practicalWrapLo, wrapHi) +
  33.         Array.fill(tones, {arg i; i * interval}), practicalWrapLo, wrapHi),
  34.         fund);
  35.     glidersHertz = 2 ** gliders;
  36.     }, {
  37.     tones = roundUp((wrapHiHertz - wrapLoHertz) / interval);
  38.     practicalWrapLo = wrapHiHertz - (tones * interval);
  39.     glidersHertz = max(
  40.         Wrap.kr(LFSaw.kr(ascendiness / (wrapHiHertz - practicalWrapLo))
  41.         .range(practicalWrapLo, wrapHiHertz) +
  42.         Array.fill(tones, {arg i; i * interval}), practicalWrapLo, wrapHiHertz),
  43.         fundHertz);
  44.     gliders = log2(glidersHertz);
  45.     });
  46.  
  47.     snapLoHertz = trunc(glidersHertz, fundHertz);
  48.     snapLo = log2(snapLoHertz);
  49.     snapHi = log2(snapLoHertz + fundHertz);
  50.     snapMid = (snapLo + snapHi) / 2;
  51.     signedHalfDist = (snapHi - snapLo) / Select.kr(gliders < snapMid, [-2, 2]);
  52.     snapped = (((
  53.         (((gliders - snapMid) / signedHalfDist) + 1)
  54.         ** (2 ** snappiness)) - 1) * signedHalfDist) + snapMid;
  55.  
  56.     overRollLo = snapped > (wrapLo + rollLo);
  57.     startCurve = Select.kr(overRollLo, [wrapLo, wrapHi - rollHi]);
  58.     wrapRollMultiplier = (Select.kr(snapped > startCurve, [1,
  59.         cos((snapped - startCurve)
  60.         * Select.kr(overRollLo, [pi / rollLo, pi / rollHi])
  61.         )]) / Select.kr(overRollLo, [-2, 2])) + 0.5;
  62.     fundRollProgress = (snapped - fund - fundRollStart) / fundRoll;
  63.     fundRollMultiplier = Select.kr(fundRollProgress + 1,
  64.         [0, (cos(pi * fundRollProgress) / (-2)) + 0.5, 1]);
  65.  
  66.     earDistance = 0.00033;
  67.     rightness = Array.fill(tones, { rrand(-4.0, 4.0) });
  68.     forwardness = Array.fill(tones, { rrand(-4.0, 4.0) });
  69.     distance = [hypot(rightness + 1, forwardness),
  70.         hypot(rightness - 1, forwardness)];
  71.     delay = earDistance * (distance + 1.0001
  72.         - Array.fill(2, (distance[0] + distance[1]) / 2));
  73.     mulRaw = (distance + 0.0001) ** -2;
  74.     mul = [mulRaw[0] / hypot(mulRaw[0], mulRaw[1]),
  75.         mulRaw[1] / hypot(mulRaw[0], mulRaw[1])];
  76.  
  77.     snappedHertz = 2 ** snapped;
  78.     amp = wrapRollMultiplier * fundRollMultiplier * (snappedHertz ** riseOff);
  79.     group = SinOsc.ar(snappedHertz, 0, amp);
  80.     panned = DelayN.ar([group, group], earDistance * 3, delay, mul);
  81.     out = [Mix.new(panned[0]), Mix.new(panned[1])] * (2 ** master);
  82.     out
  83. }.play
  84. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top