SHARE
TWEET

snappiness

a guest Jun 8th, 2019 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (
  2. {
  3.     // change these
  4.     var fund = MouseX.kr(5, 9);
  5.     var snappiness = MouseY.kr(4.78136, 8.78136);
  6.     var ascendiness = 0.33;
  7.     var interval = 0.618; // <10 read as octaves, >=10 read as hertz
  8.     var wrapLo = 6;
  9.     var wrapHi = 14.55;
  10.     var rollLo = 0.5;
  11.     var rollHi = 0.5;
  12.     var fundRollStart = 2;
  13.     var fundRoll = 1;
  14.     var riseOff = -1.5;
  15.     var master = -20;
  16.  
  17.     // don't mess with these
  18.     var wrapLoHertz = 2 ** wrapLo;
  19.     var wrapHiHertz = 2 ** wrapHi;
  20.  
  21.     var tones, practicalWrapHi, gliders, glidersHertz;
  22.     if(interval < 10, {
  23.     tones = roundUp((wrapHi - wrapLo) / interval);
  24.     practicalWrapHi = (tones * interval) + wrapLo;
  25.     gliders = min(
  26.         Wrap.kr(LFSaw.kr(ascendiness / (practicalWrapHi - wrapLo))
  27.         .range(wrapLo, practicalWrapHi) +
  28.         Array.fill(tones, {arg i; i * interval}), wrapLo, practicalWrapHi),
  29.         wrapHi);
  30.     glidersHertz = 2 ** gliders;
  31.     }, {
  32.     tones = roundUp((wrapHiHertz - wrapLoHertz) / interval);
  33.     practicalWrapHi = (tones * interval) + wrapLoHertz;
  34.     glidersHertz = min(
  35.         Wrap.kr(LFSaw.kr(ascendiness / (practicalWrapHi - wrapLoHertz))
  36.         .range(wrapLoHertz, practicalWrapHi) +
  37.         Array.fill(tones, {arg i; i * interval}), wrapLoHertz, practicalWrapHi),
  38.         wrapHiHertz);
  39.     gliders = log2(glidersHertz);
  40.     });
  41.  
  42.     var fundHertz = 2 ** fund;
  43.     var snapLoHertz = trunc(glidersHertz, fundHertz);
  44.     var snapLo = log2(snapLoHertz);
  45.     var snapHi = log2(snapLoHertz + fundHertz);
  46.     var snapMid = (snapLo + snapHi) / 2;
  47.     var signedHalfDist = (snapHi - snapLo) / if(gliders < snapMid, 2, -2);
  48.     var snapped = (((
  49.         (((gliders - snapMid) / signedHalfDist) + 1)
  50.         ** (2 ** snappiness)) - 1) * signedHalfDist) + snapMid;
  51.     var rollLoFull = wrapLo + rollLo;
  52.     var piOverRollLo = pi / rollLo;
  53.     var rollLoMultiple = if(snapped > rollLoFull, 1,
  54.         (cos((snapped - rollLoFull) * piOverRollLo) + 1) / 2);
  55.     var rollHiFull = wrapHi - rollHi;
  56.     var piOverRollHi = pi / rollHi;
  57.     var rollHiMultiple = if(snapped < rollHiFull, 1,
  58.         (cos((snapped - rollHiFull) * piOverRollHi) + 1) / 2);
  59.     var fundRollEnd = fundRollStart + fundRoll;
  60.     var piOverFundRoll = pi / fundRoll;
  61.     var fundRollMultiple = if(snapped < fundRollStart, 0,
  62.         if(snapped > fundRollEnd, 1,
  63.         (cos((snapped - fundRollEnd) * piOverFundRoll) + 1) / 2));
  64.     var snappedHertz = 2 ** snapped;
  65.     var balanced = rollLoMultiple * rollHiMultiple * fundRollMultiple
  66.         * (snappedHertz ** riseOff);
  67.     var group = SinOsc.ar(snappedHertz, 0, balanced);
  68.     var panned = [group, group];
  69.     var out = [Mix.new(panned[0]), Mix.new(panned[1])] * (2 ** master);
  70.  
  71.     Poll.kr(Impulse.kr(10), fund);
  72.     out
  73. }.play
  74. )
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top