-
-
Save zeffii/7631990 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// week 2 introduces | |
/* Std conversion */ | |
Std.powtodb(float val) // signal power ratio to dB | |
Std.dbtopow(float val) // dB to signal power ratio | |
Std.rmstob(float val) // linear amp to dB | |
Std.dbtorms(float val) // dB to linear amp | |
Std.atoi(string val) // alpha to int | |
Std.atof(string val) // alpha to float | |
Std.itoa(int val) // int to alpha | |
Std.ftoa(int val) // float to alpha | |
Std.mtof() | |
Std.ftom() | |
Std.abs() | |
Std.fabs() | |
Std.sgn | |
/* Math random */ | |
// seed, forces reproducible random | |
Math.srandom(n) // use n to set random seed | |
Math.random() // random int between 0, max int | |
Math.randomf() // random float between 0.0 and 1.0 | |
Math.random2(a, b) // random int between a and b | |
Math.random2f(a, b) // random float between a and b | |
/* Math geometry and operations on numbers */ | |
Math.hypot(fx, fy) // takes floats, returns euclidean distance of vector | |
Math.pow(a, b) // a^b, takes ints or floats. | |
Math.sqrt(x) | |
Math.exp(x) | |
Math.log(x) // natural log | |
Math.log2(x) // log base 2 | |
Math.log10(x) // base 10 | |
/* Math utility functions */ | |
Math.floor(float) // round down to next integeral ( 2.3 becomes 2.0 ) | |
Math.ceil(float) // round up to next integral ( 2.3 becomes 3.0 ) | |
Math.round(float) // regular rounding rules apply | |
Math.trunc() // round to largest integral val no greater than x | |
Math.fmod(float, float) // float remainder of x / y | |
Math.min(float, float) // returns lowest value of the two inputs | |
Math.max(float, float) // returns highest value of the two inputs | |
Math.nextpow2(float) // (int) returns smallest int (power of 2 greater than input) | |
// all of these return floats | |
Math.sin(x) // for parameter control, not for generating audio | |
Math.cos(x) | |
Math.tan(x) | |
Math.asin(x) | |
Math.acos(x) | |
Math.atan2(x,y) | |
Math.sinh(x) | |
Math.cosh(x) | |
Math.tanh(x) | |
// week 2 section 4 | |
dac.left | |
dac.right | |
dac.chan(0) | |
dac.chan(1) | |
dac.chan(n) // in case more than 2 channels available | |
// Panning! | |
SinOsc s => Pan2 p => dac; | |
1.0 => p.pan; // one side | |
-1.0 => p.pan; // other side | |
pi // 3.141592... | |
// noise generator, doesn't produce a repeating waveform, use | |
// as SinOsc etc | |
Noise n; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment