diff options
| author | Mick Grierson <mickgrierson@strangebook.lan> | 2011-10-17 02:03:39 +0100 |
|---|---|---|
| committer | Mick Grierson <mickgrierson@strangebook.lan> | 2011-10-17 02:03:39 +0100 |
| commit | a6cdb047b0eda1c45a9a070f0f56cee2e305f009 (patch) | |
| tree | 97effb5efc64696db10a3c2d18c2f2ee043a90fc /main.cpp | |
| parent | 9b352d42f4631a515345ed7c4992a736aab1fea2 (diff) | |
added maxiEnv - easier to use ADSR and AR envelopes for those who find ramps a bit weird
Diffstat (limited to 'main.cpp')
| -rwxr-xr-x | main.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
@@ -1,6 +1,6 @@ #include "maximilian.h" -maxiOsc sound,timer;//We give our sample a name. It's called beats this time. We could have loads of them, but they have to have different names. +maxiOsc sound,timer; maxiEnv AR; double out; int trigger, lasttrigger; @@ -13,28 +13,22 @@ void setup() {//some inits } void play(double *output) {//this is where the magic happens. Very slow magic. - currentCount=(int)timer.phasor(16);//this sets up a metronome that ticks every 2 seconds + currentCount=(int)timer.phasor(16);//this sets up a metronome that ticks every so often if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound - trigger=rhythm[playHead]; - playHead++; - if (playHead>7) { - playHead=0; + trigger=rhythm[playHead];//read through the array + playHead++;//iterate the playhead + if (playHead>7) {//but not if it's too big.. + playHead=0;//in which case reset the playhead } //cout << "tick\n";//the clock ticks lastCount=0;//set lastCount to 0 } - -// beat=beats.play();//just play the file. Looping is default for all play functions. - *output=AR.adsr(sound.pulse(440,0.5),1,0.999, 0.125, 0.9999, 1, trigger);//new, simple ADSR. - // *output=beats.play(0.69);//play the file with a speed setting. 1. is normal speed. - // *output=beats.play(0.5,0,44100);//linear interpolationplay with a frequency input, start point and end point. Useful for syncing. - // *output=beats.play4(0.5,0,44100);//cubic interpolation play with a frequency input, start point and end point. Useful for syncing. - + } |
