Skip to content

Instantly share code, notes, and snippets.

@mohayonao
Created February 24, 2014 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohayonao/9187072 to your computer and use it in GitHub Desktop.
Save mohayonao/9187072 to your computer and use it in GitHub Desktop.
SCScript(function($SC) {
return $SC.I.r = $SC('play', $SC('new', $SC.Class('Task'), [$SC.SyncFunction(function() {
var freq, indexDepth, indexRange, synthIndex, dur, repeat, next, count, countDown, offset, ratioa, ratiob, envs, env, range, outBus;
return [
function() {
range = 60, outBus = 0;
count = 0;
countDown = 0;
offset = 0;
envs = [[0, 0.9], [0.01, 0.9], [0.1, 0.8], [0.8, 0.01]];
repeat = $SC('fill', $SC.Class('Array'), [10, function() {
return [$SC('midicps', $SC('round', $SC('rrand', range, [$SC('+', range, [24])]), [1])), 3, $SC('-', 2.1, [$SC('exprand', 0.1, [2.0])]), 0, 1, 1, 0, 0.9];
}]);
next = $SC('fill', $SC.Class('Array'), [10, function() {
return $SC('choose', [3, 0.75, 0.5, 0.25, 0.125]);
}]);
freq = $SC('rrand', range, [$SC('*', range, [2])]);
indexDepth = 1;
return $SC('do', Infinity, [$SC.SyncFunction(function() {
return [
function() {
$SC('if', $SC('<=', countDown, [0]), [function() {
env = $SC('choose', envs);
$SC('put', next, [$SC('%', count, [10]), $SC('choose', [3, 0.5, 0.25, 0.125, 0.125])]);
return $SC('put', repeat, [$SC('%', count, [10]), [$SC('midicps', $SC('round', $SC('rrand', range, [$SC('+', range, [24])]), [1])), $SC('rrand', 0.1, [12.0]), $SC('-', 2.1, [$SC('exprand', 0.1, [2.0])]), outBus, $SC('rrand', 1, [12]), $SC('rrand', 1, [12]), $SC('at', env, [0]), $SC('at', env, [1])]]);
}]);
$SC('setn', $SC('new', $SC.Class('Synth'), ['crotale']), ['param', $SC('wrapAt', repeat, [count])]);
$SC('wait', $SC('wrapAt', next, [count]));
},
function() {
$SC('if', $SC('and', $SC('>', count, [10]), [$SC('<=', countDown, [0])]), [function() {
offset = countDown = $SC('choose', [0, $SC('rand', 3), $SC('rand', 6)]);
return count = $SC('-', count, [offset]);
}]);
count = $SC('+', count, [1]);
return countDown = $SC('-', countDown, [1]);
}
];
}, [])]);
}
];
}, [])]));
});
r = Task({
var freq, indexDepth, indexRange, synthIndex, dur, repeat;
var next, count, countDown, offset, ratioa, ratiob, envs, env;
var range = 60, outBus = 0;
count = 0; countDown = 0; offset = 0;
envs = [[0, 0.9], [0.01, 0.9], [0.1, 0.8], [0.8, 0.01]];
repeat = Array.fill(10,
{[rrand(range, range+24).round(1).midicps, 3,
2.1 - exprand(0.1, 2.0), 0, 1, 1, 0, 0.9]});
next = Array.fill(10, {[3, 0.75, 0.5, 0.25, 0.125].choose});
freq = rrand(range, range*2); // these two are just starting points
indexDepth = 1;
inf.do({
if(countDown <= 0,
{
env = envs.choose;
next.put(count%10, [3, 0.5, 0.25, 0.125, 0.125].choose);
repeat.put(count%10, [
rrand(range, range + 24).round(1).midicps,
rrand(0.1, 12.0),
2.1 - exprand(0.1, 2.0), outBus, rrand(1, 12),
rrand(1, 12), env.at(0), env.at(1)]);
});
Synth("crotale").setn(\param, repeat.wrapAt(count));
next.wrapAt(count).wait;
if((count > 10).and(countDown <= 0),
{offset = countDown = [0, 3.rand, 6.rand].choose;
count = count - offset});
count = count + 1;
countDown = countDown - 1;
});
}).play();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment