Created
October 28, 2015 06:49
-
-
Save jrsa/1081cef03768cd701031 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
fun int[][] genPitches(int setCount, int setLength, int pitchRange) | |
{ | |
int result[setCount][setLength]; | |
for(0 => int i; i < setCount; i++) | |
for(0 => int j; j < setLength; j++) | |
(0, pitchRange) => Math.random2 => result[i][j]; | |
return result; | |
} | |
80 => int bpm; | |
(60000/bpm)::ms => dur beat; | |
// 2 synths | |
Gain m1 => Pan2 stereo; | |
SinOsc mod => ADSR env1 => SinOsc bass => m1; | |
SinOsc mod2 => SinOsc synth1 => ADSR env2 => m1; | |
// enable fm | |
2 => bass.sync; | |
2 => synth1.sync; | |
// it could get loud | |
0.02 => bass.gain; | |
0.10 => synth1.gain; | |
// modulation envelope for bass | |
0.8 => env1.gain; | |
// fm index | |
2000 => mod.gain; | |
500 => mod2.gain; | |
// set envelope values | |
(0.25::second, 0.25::second, 0.2, 0.25::second) => env1.set; // bass fm env | |
(0.125::second, 0.5::second, 0.1, 0.25::second) => env2.set; // synth amp env | |
// loud stereo feedback lines on the end of the sound chain | |
Gain masterOut => dac; | |
// split stereo | |
stereo.right => Delay dr; | |
stereo.left => Delay dl; | |
100::ms => dr.max => dr.delay; | |
50::ms => dl.max => dl.delay; | |
dr => Gain rtl => dl => Gain ltr => dr; | |
// constrain feedback | |
0.95 => rtl.gain => ltr.gain; | |
//dl => masterOut; | |
dr => masterOut; | |
genPitches(2, 4, 12) @=> int notes[][]; | |
// play music infinitely i guess | |
for(0 => int counter; counter <= (bpm/2); counter++) | |
{ | |
(0, 1) => Math.random2 => int phrasing; | |
notes[0][counter%4] + 12 => int pitch; | |
pitch + 36 => Std.mtof => bass.freq; | |
pitch + 24 => Std.mtof => mod.freq; | |
env1.keyOn(1); | |
// melody notes | |
for(0 => int i; i < 3; i++) | |
{ | |
notes[1][i%notes[1].cap()] + pitch => int leadPitch; | |
leadPitch + 48 => Std.mtof => synth1.freq; | |
(leadPitch +48) * 3 => Std.mtof => mod2.freq; | |
env2.keyOn(1); | |
(phrasing + 0.5)::beat => now; | |
env2.keyOff(1); | |
} | |
env1.keyOff(1); | |
(phrasing + 0.5)::beat => now; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment