{
   "author" : "codepool",
   "name" : "Add it up!",
   "description" : "Migration from the old SourceForge wiki.",
   "ancestor_list" : [],
   "labels" : [
      "oscillator"
   ],
   "id" : "1-56Z",
   "is_private" : null,
   "code" : "// Add it up!\r\n// Building an array of oscillators loosely based on the harmonic series, and playing around with this idea.\r\n// nonprivate standing on the shoulders of andy baxter\r\n\r\n// Formlet\r\n\r\n\r\n(\r\nvar numHarm = 40, freqJitterDensity = 500; \r\n\r\nSynthDef.new(\"additup1\", \r\n\t{\r\n\targ freq = 440, amp = 1, out = 0,\r\n\t\tfreqJitterAmt = 0, harmMult = 1, harmOffset = 1, harmDecayPower = 1,\r\n\t\tformFreqRatio = 1, formAttack = 0.005, formDecay = 0.003; \r\n\t\t\r\n\t\tfreq = MouseX.kr(30, 1600, 1); \r\n\t\t\r\n\t\tOut.ar(out, Pan2.ar(\r\n\t\t\r\n\t\t\tMix.fill(\r\n\t\t\t\tnumHarm,\r\n\t\t\t\t{ \r\n\t\t\t\targ index; \r\n\r\n\t\t\t\tFormlet.ar(\r\n\t\t\t\t\tImpulse.ar(freq * Lag.ar(Dust2.ar( (freqJitterDensity + (freqJitterDensity * 0.2).rand2), freqJitterAmt, 1), 0.3), 1.0.rand), \r\n\t\t\t\t\tfreq * formFreqRatio * (index * harmMult + harmOffset),\r\n\t\t\t\t\tformAttack,\r\n\t\t\t\t\tformDecay,\r\n\t                \t\t1/((index * harmMult + harmOffset) ** harmDecayPower) \r\n\t            \t) \r\n\t\t\t\t} \r\n\t\t\t) * amp * 0.8,\r\n\t\t0, 1)); \r\n    } \r\n    ).send(s); \r\n) \r\n\r\n\r\n(\r\nn = s.nextNodeID;\r\ns.sendMsg(\"/s_new\", \"additup1\", n, 0, 0);\r\n)\r\n\r\n\r\n(\r\n//attack of the wasps\r\n\r\ns.sendMsg(\"/n_set\", n, \r\n\t\\amp, 1.6,\t\r\n\t\\freqJitterAmt, 40, \\harmMult, 3, \\harmOffset, 2, \\harmDecayPower, 0.7,\r\n\t\\formFreqRatio, 0.2, \\formAttack, 0.003, \\formDecay, 0.0002\r\n);\r\n\r\n)\r\n\r\n(\r\n// small airplane\r\ns.sendMsg(\"/n_set\", n,\r\n\t\\amp, 0.6, \t\r\n\t\\freqJitterAmt, 4, \\harmMult, 0.01, \\harmOffset, 1.1, \\harmDecayPower, 2,\r\n\t\\formFreqRatio, 4, \\formAttack, 0.003, \\formDecay, 0.02\r\n);\r\n\r\n)\r\n\r\n(\r\n// synthy\r\ns.sendMsg(\"/n_set\", n, \t\r\n\t\\amp, 0.2,\r\n\t\\freqJitterAmt, 0, \\harmMult, 1, \\harmOffset, 1.1, \\harmDecayPower, 0.8,\r\n\t\\formFreqRatio, 0.5, \\formAttack, 0.0007, \\formDecay, 0.2\r\n);\r\n\r\n)\r\n\r\n(\r\n// cubik\r\ns.sendMsg(\"/n_set\", n, \t\r\n\t\\amp, 0.4,\r\n\t\\freqJitterAmt, 0.5, \\harmMult, 0.8, \\harmOffset, 1.1, \\harmDecayPower, 0.5,\r\n\t\\formFreqRatio, 3.01, \\formAttack, 0.07, \\formDecay, 0.002\r\n);\r\n\r\n\r\n)\r\n\r\ns.sendMsg(\"/n_free\", n);\r\n\r\n\r\n\r\n// Sines\r\n\r\n(\r\n\r\nvar numHarm = 20, freqJitterDensity = 200; \r\n\r\nSynthDef.new(\"additup2\", \r\n\t{\r\n\targ freq = 223, amp = 1, out = 0,\r\n\t\tfreqJitterAmt = 0,\r\n\t\tharmMult = 1, harmOffset = 1, harmDecayPower = 1; \r\n\t\t\r\n\t\tfreq = MouseX.kr(30, 1600, 1); \r\n\t\t\r\n\t\tOut.ar(out, Pan2.ar(\r\n\t\t\tMix.fill(\r\n\t\t\t\tnumHarm,\r\n\t\t\t\t{ \r\n\t\t\t\targ index; \r\n\r\n\t\t\t\tSinOsc.ar(\r\n\t\t\t\t\t\r\n\t\t\t\t\t(freq * Lag.ar(Dust2.ar( (freqJitterDensity + (freqJitterDensity * 0.2).rand2), freqJitterAmt, 1), 0.3)) \r\n\t\t\t\t\t* (index * harmMult + harmOffset),\r\n\t\t\t\t\t1.00.rand,\r\n\t                \t\t1/((index * harmMult + harmOffset) ** harmDecayPower) \r\n\t            \t) \r\n\t\t\t\t} \r\n\t\t\t) * amp * 0.1,\r\n\t\t0, 1)); \r\n    } \r\n    ).send(s); \r\n\r\n) \r\n\r\n(\r\nn = s.nextNodeID;\r\ns.sendMsg(\"/s_new\", \"additup2\", n, 0, 0);\r\n)\r\n\r\n\r\n\r\n(\r\n// hollow joy\r\n\r\ns.sendMsg(\"/n_set\", n, \r\n\t\\amp, 1.2,\t\r\n\t\\freqJitterAmt, 1.7, \\harmMult, 1.4, \\harmOffset, 1, \\harmDecayPower, 1.3\r\n);\r\n\r\n)\r\n\r\n(\r\n// alien brook\r\ns.sendMsg(\"/n_set\", n,\r\n\t\\amp, 4, \t\r\n\t\\freqJitterAmt, 400, \\harmMult, 0.2, \\harmOffset, 6, \\harmDecayPower, 1\r\n);\r\n\r\n)\r\n\r\n(\r\n// hard nosed\r\ns.sendMsg(\"/n_set\", n, \t\r\n\t\\amp, 0.5,\r\n\t\\freqJitterAmt, 0, \\harmMult, 5, \\harmOffset, 5, \\harmDecayPower, 0.1\r\n);\r\n\r\n)\r\n\r\n(\r\n// whistling breeze\r\ns.sendMsg(\"/n_set\", n, \t\r\n\t\\amp, 3,\r\n\t\\freqJitterAmt, 4, \\harmMult, 0.1, \\harmOffset, 7, \\harmDecayPower, 1\r\n);\r\n\r\n\r\n)\r\n\r\ns.sendMsg(\"/n_free\", n);"
}
