diff options
| author | Mick Grierson <mickgrierson@strangebook.lan> | 2011-10-19 00:34:21 +0100 |
|---|---|---|
| committer | Mick Grierson <mickgrierson@strangebook.lan> | 2011-10-19 00:34:21 +0100 |
| commit | 40a09191d818c964d5ea8bceb2ea56b1c362bd3a (patch) | |
| tree | 88afced2672c826d41aa22704943cd54985d2ecb /main.cpp | |
| parent | 92af27026aa1aa72535e94bd8007d7066a3136e7 (diff) | |
having some fun
Diffstat (limited to 'main.cpp')
| -rwxr-xr-x | main.cpp | 53 |
1 files changed, 39 insertions, 14 deletions
@@ -1,13 +1,22 @@ #include "maximilian.h" -maxiOsc sound,bass,timer,mod; -maxiEnv envelope; -double bassout,leadout; -int trigger; -int currentCount,lastCount,playHead=0; -int rhythm[8]={1,0,1,0,1,0,1,0}; -float pitch[8]={220,220,246.9,261.6}; -float currentPitch; +//Bizarelly, this sounds a little bit like Kraftwerk's 'Metropolis', although it isn't. Funny that. + +maxiOsc sound,bass,timer,mod,lead,lead2,leadmod;//here are the synth bits +maxiEnv envelope, leadenvelope;//some envelopes +maxiFilter filter, filter2;//some filters +maxiDelayline delay;//a delay +convert mtof;//a method for converting midi notes to frequency +double bassout,leadout, delayout;//some variables to hold the data and pass it around +int trigger, trigger2, newnote;//some control variables +int currentCount,lastCount,playHead=0, currentChord=0;//some other control variables +int pitch[8]={57,57,59,60};//the bassline for the arpeggio +int chord[8]={0,0,7,2,5,5,0,0};//the root chords for the arpeggio +float currentPitch,leadPitch;//the final pitch variables + +//here's the lead line trigger array, followed by the pitches +int leadLineTrigger[256]={1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +int leadLinePitch[15]={69,67,65,64,67,66,64,62,65,64,62,57,55,60,57}; @@ -16,22 +25,38 @@ void setup() {//some inits } void play(double *output) {//this is where the magic happens. Very slow magic. - currentCount=(int)timer.phasor(20);//this sets up a metronome that ticks every so often + + currentCount=(int)timer.phasor(9);//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%8];//read through the array - currentPitch=pitch[(playHead%8)/2]; + trigger=1;//play the arpeggiator line + trigger2=leadLineTrigger[playHead%256];//play the lead line + if (trigger2==1) {//if we are going to play a note + leadPitch=mtof.mtof(leadLinePitch[newnote]);//get the next pitch val + newnote++;//and iterate + if (newnote>14) { + newnote=0;//make sure we don't go over the edge of the array + } + } + currentPitch=mtof.mtof(pitch[(playHead%4)]+chord[currentChord%8]);//write the frequency val into currentPitch playHead++;//iterate the playhead + if (playHead%32==0) {//wrap every 4 bars + currentChord++;//change the chord + } //cout << "tick\n";//the clock ticks lastCount=0;//set lastCount to 0 } - bassout=envelope.adsr(bass.saw(currentPitch*0.5)+sound.pulse(currentPitch*0.5,mod.phasor(1)),1,0.9995, 0.25, 0.9995, 1, trigger);//new, simple ADSR. + bassout=filter2.lores(envelope.adsr(bass.saw(currentPitch*0.5)+sound.pulse(currentPitch*0.5,mod.phasor(1)),1,0.9995, 0.25, 0.9995, 1, trigger),9250,2);//new, simple ADSR. + leadout=filter.lores(leadenvelope.ar(lead2.saw(leadPitch*4)+lead.pulse(leadPitch+(leadmod.sinebuf(1.9)*1.5), 0.6), 0.00005, 0.999975, 50000, trigger2),5900,10);//leadline - *output=bassout; + delayout=(leadout+(delay.dl(leadout, 14000, 0.8)*0.5))/2;//add some delay - + if(trigger!=0)trigger=0;//set the trigger to off if you want it to trigger immediately next time. + output[0]=(bassout+delayout)/2;//sum output + output[1]=(bassout+delayout)/2; + } |
