Skip to content

Commit

Permalink
added various random number ugens
Browse files Browse the repository at this point in the history
  • Loading branch information
coleingraham committed Jun 18, 2014
1 parent a4e7ad4 commit 086abf0
Showing 1 changed file with 146 additions and 0 deletions.
146 changes: 146 additions & 0 deletions Soliton.js/SuperCollider.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,152 @@ function scBitRightShift(a, b)
return _binaryOpUGen(_BIN_SHIFTRIGHT, a, b);
}

/**
* Generate a random number with uniform distribution when synth starts playing.
*
* @class scRand
* @constructor
* @param lo Lowest possible value
* @param hi Highest possible value
* @example
* let test a => sin (scRand 220 440) >> out 0<br>
* let t = test 1<br>
* stop t
*/
function scRand(lo,hi)
{
return multiNewUGen("Rand", ScalarRate, [lo,hi], 1, 0);
}

/**
* Generate a random number with distribution based on the sum of n random numbers when synth starts playing.
*
* @class scNRand
* @constructor
* @param lo Lowest possible value
* @param hi Highest possible value
* @param n Number of random numbers to sum. 1 = uniform distribution, 2 = triangular, etc. Higher numbers approach gaussian
* @example
* let test a => sin (scNRand 220 440 4) >> out 0<br>
* let t = test 1<br>
* stop t
*/
function scNRand(lo,hi,n)
{
return multiNewUGen("NRand", ScalarRate, [lo,hi,n], 1, 0);
}

/**
* Random Number Generators.
* @submodule Random
*/

/**
* Generate a random number with linear distribution when synth starts playing.
*
* @class scLinRand
* @constructor
* @param lo Lowest possible value
* @param hi Highest possible value
* @example
* let test a => sin (scLinRand 220 440) >> out 0<br>
* let t = test 1<br>
* stop t
*/
function scLinRand(lo,hi)
{
return multiNewUGen("LinRand", ScalarRate, [lo,hi], 1, 0);
}

/**
* Generate a random integer with uniform distribution when synth starts playing.
*
* @class scIRand
* @constructor
* @param lo Lowest possible value
* @param hi Highest possible value
* @example
* let test a => sin (scIRand 220 440) >> out 0<br>
* let t = test 1<br>
* stop t
*/
function scIRand(lo,hi)
{
return multiNewUGen("IRand", ScalarRate, [lo,hi], 1, 0);
}


/**
* Generate a random number with exponential distribution when synth starts playing.
*
* @class scExpRand
* @constructor
* @param lo Lowest possible value
* @param hi Highest possible value
* @example
* let test a => sin (scExpRand 220 440) >> out 0<br>
* let t = test 1<br>
* stop t
*/
function scExpRand(lo,hi)
{
return multiNewUGen("ExpRand", ScalarRate, [lo,hi], 1, 0);
}

/**
* Generate a random number with uniform distribution on each trigger.
*
* @class scTRand
* @constructor
* @param lo Lowest possible value
* @param hi Highest possible value
* @param trigger A trigger happens when the signal changes from non-positive to positive
* @example
* let test a => sin (scTRand 220 440 (impulse 1)) >> out 0<br>
* let t = test 1<br>
* stop t
*/
function scTRand(lo,hi,trigger)
{
return multiNewUGen("TRand", AudioRate, [lo,hi,trigger], 1, 0);
}

/**
* Generate a random integer with uniform distribution on each trigger.
*
* @class scTIRand
* @constructor
* @param lo Lowest possible value
* @param hi Highest possible value
* @param trigger A trigger happens when the signal changes from non-positive to positive
* @example
* let test a => sin (scTIRand 220 440 (impulse 1)) >> out 0<br>
* let t = test 1<br>
* stop t
*/
function scTIRand(lo,hi,trigger)
{
return multiNewUGen("TIRand", AudioRate, [lo,hi,trigger], 1, 0);
}

/**
* Generate a random number with exponential distribution on each trigger.
*
* @class scTExpRand
* @constructor
* @param lo Lowest possible value
* @param hi Highest possible value
* @param trigger A trigger happens when the signal changes from non-positive to positive
* @example
* let test a => sin (scTExpRand 220 440 (impulse 1)) >> out 0<br>
* let t = test 1<br>
* stop t
*/
function scTExpRand(lo,hi,trigger)
{
return multiNewUGen("TExpRand", AudioRate, [lo,hi,trigger], 1, 0);
}

/**
* Output a constant value
*
Expand Down

0 comments on commit 086abf0

Please sign in to comment.