diff options
Diffstat (limited to 'maximilian_examples')
| -rwxr-xr-x | maximilian_examples/12.SamplePlayer.cpp | 22 | ||||
| -rw-r--r-- | maximilian_examples/20.FFT_example.cpp | 31 | ||||
| -rw-r--r-- | maximilian_examples/arrays.cpp | 60 |
3 files changed, 42 insertions, 71 deletions
diff --git a/maximilian_examples/12.SamplePlayer.cpp b/maximilian_examples/12.SamplePlayer.cpp index 2706f0b..df6b3d2 100755 --- a/maximilian_examples/12.SamplePlayer.cpp +++ b/maximilian_examples/12.SamplePlayer.cpp @@ -3,19 +3,19 @@ maxiSample beats; //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. void setup() {//some inits - - beats.load("/Users/username/somewhere/Maximilian/beat2.wav");//load in your samples. Provide the full path to a wav file. - printf("Summary:\n%s", beats.getSummary());//get info on samples if you like. - + + beats.load("/Users/michaelgrierson/Documents/workspace/Maximilian/beat2.wav");//load in your samples. Provide the full path to a wav file. + printf("Summary:\n%s", beats.getSummary());//get info on samples if you like. + } void play(double *output) {//this is where the magic happens. Very slow magic. - - *output=beats.play();//just play the file. Looping is default for all play functions. - // *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. - - + + //output[0]=beats.play();//just play the file. Looping is default for all play functions. + output[0]=beats.play(0.68);//play the file with a speed setting. 1. is normal speed. + //output[0]=beats.play(0.5,0,44100);//linear interpolationplay with a frequency input, start point and end point. Useful for syncing. + //output[0]=beats.play4(0.5,0,44100);//cubic interpolation play with a frequency input, start point and end point. Useful for syncing. + + output[1]=output[0]; } diff --git a/maximilian_examples/20.FFT_example.cpp b/maximilian_examples/20.FFT_example.cpp new file mode 100644 index 0000000..086dac0 --- /dev/null +++ b/maximilian_examples/20.FFT_example.cpp @@ -0,0 +1,31 @@ + +#include "maximilian.h" +#include "libs/maxim.h" + +maxiOsc mySine, myPhasor; // This is the oscillator we will use to generate the test tone +maxiFFT myFFT; + + + +void setup() { + + myFFT.setup(1024, 512, 2); + +} + +void play(double *output) { + + + float myOut=mySine.sinewave(myPhasor.phasor(0.2,100,5000)); + //output[0] is the left output. output[1] is the right output + + if (myFFT.process(myOut)) { + + //if you want you can mess with FFT frame values in here + + } + + output[0]=myOut;//simple as that! + output[1]=output[0]; + +}
\ No newline at end of file diff --git a/maximilian_examples/arrays.cpp b/maximilian_examples/arrays.cpp deleted file mode 100644 index 1badd9b..0000000 --- a/maximilian_examples/arrays.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// -// arrays.cpp -// -// -// Created by Michael Grierson on 14/09/2015. -// -// - -#include "maximilian.h" - -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}; - - - -void setup() {//some inits - -} - -void play(double *output) {//this is where the magic happens. Very slow magic. - - 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=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=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 - - 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; - -}
\ No newline at end of file |
