diff options
| author | mick grierson <mickgrierson@gmail.com> | 2015-07-26 23:57:38 +0100 |
|---|---|---|
| committer | mick grierson <mickgrierson@gmail.com> | 2015-07-26 23:57:38 +0100 |
| commit | 68ee8eba9c3834604d220f4bf56e7e9d506a77a7 (patch) | |
| tree | c021e67cc0ebc042a896259c2e508b8b60ad6c6d /maximilian_examples | |
| parent | cb3e92e75b1492bc1434431e975d1acf145c84fc (diff) | |
Some initial changes that are long overdue part 1
Diffstat (limited to 'maximilian_examples')
| -rwxr-xr-x | maximilian_examples/14.monosynth.cpp | 72 | ||||
| -rw-r--r-- | maximilian_examples/17.Compressor.cpp | 37 | ||||
| -rw-r--r-- | maximilian_examples/20.additive.cpp | 26 |
3 files changed, 56 insertions, 79 deletions
diff --git a/maximilian_examples/14.monosynth.cpp b/maximilian_examples/14.monosynth.cpp index 5dd4e7e..897c41a 100755 --- a/maximilian_examples/14.monosynth.cpp +++ b/maximilian_examples/14.monosynth.cpp @@ -5,11 +5,7 @@ //These are the synthesiser bits maxiOsc VCO1,VCO2,LFO1,LFO2; maxiFilter VCF; -maxiEnvelope ADSR; - -//These are the control values for the envelope - -double adsrEnv[8]={1,5,0.125,250,0.125,125,0,500}; +maxiEnv ADSR; //This is a bunch of control signals so that we can hear something @@ -22,38 +18,42 @@ double VCO1out,VCO2out,LFO1out,LFO2out,VCFout,ADSRout; void setup() {//some inits - - + + ADSR.setAttack(1000); + ADSR.setDecay(1); + ADSR.setSustain(1); + ADSR.setRelease(1000); } void play(double *output) { - - //so this first bit is just a basic metronome so we can hear what we're doing. - - currentCount=(int)timer.phasor(0.5);//this sets up a metronome that ticks every 2 seconds - - if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound - - ADSR.trigger(0, adsrEnv[0]);//trigger the envelope from the start - - cout << "tick\n";//the clock ticks - - lastCount=0;//set lastCount to 0 - } - - //and this is where we build the synth - - - ADSRout=ADSR.line(8,adsrEnv);//our ADSR env has 8 value/time pairs. - - LFO1out=LFO1.sinebuf(0.2);//this lfo is a sinewave at 0.2 hz - - VCO1out=VCO1.pulse(55,0.6);//here's VCO1. it's a pulse wave at 55 hz, with a pulse width of 0.6 - VCO2out=VCO2.pulse(110+LFO1out,0.2);//here's VCO2. it's a pulse wave at 110hz with LFO modulation on the frequency, and width of 0.2 - - - VCFout=VCF.lores((VCO1out+VCO2out)*0.5, 250+(ADSRout*15000), 10);//now we stick the VCO's into the VCF, using the ADSR as the filter cutoff - - *output=VCFout*ADSRout;//finally we add the ADSR as an amplitude modulator - + + //so this first bit is just a basic metronome so we can hear what we're doing. + + currentCount=(int)timer.phasor(0.5);//this sets up a metronome that ticks every 2 seconds + + + if (lastCount!=currentCount) {//if we have a new timer int this sample, play the sound + ADSR.trigger=1; + + cout << "tick\n";//the clock ticks + + lastCount=0;//set lastCount to 0 + } + + //and this is where we build the synth + + ADSRout=ADSR.adsr(1.0,ADSR.trigger);//our ADSR env has 8 value/time pairs. + + LFO1out=LFO1.sinebuf(0.2);//this lfo is a sinewave at 0.2 hz + + VCO1out=VCO1.pulse(55,0.6);//here's VCO1. it's a pulse wave at 55 hz, with a pulse width of 0.6 + VCO2out=VCO2.pulse(110+LFO1out,0.2);//here's VCO2. it's a pulse wave at 110hz with LFO modulation on the frequency, and width of 0.2 + + + VCFout=VCF.lores((VCO1out+VCO2out)*0.5, ADSRout*10000, 10);//now we stick the VCO's into the VCF, using the ADSR as the filter cutoff + + double finalSound=VCFout*ADSRout;//finally we add the ADSR as an amplitude modulator + ADSR.trigger=0; + output[0]=finalSound; + output[1]=finalSound; } diff --git a/maximilian_examples/17.Compressor.cpp b/maximilian_examples/17.Compressor.cpp index c6b7897..c9bf221 100644 --- a/maximilian_examples/17.Compressor.cpp +++ b/maximilian_examples/17.Compressor.cpp @@ -5,25 +5,28 @@ maxiDyn compressor; //this is a compressor double out; void setup() {//some inits - - beats.load("/Users/yourusername/somewhere/schub.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/ofxMaxim/examples/OSX/ofMaximExample007OSX_Granular/bin/data/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. + + compressor.setAttack(100); + compressor.setRelease(300); + compressor.setThreshold(0.25); + compressor.setRatio(5); + + //you can set these any time you like. + } void play(double *output) {//this is where the magic happens. Very slow magic. - - - //here, we're just compressing the file in real-time - //arguments are input,ratio,threshold,attack,release - out=compressor.compressor(beats.play(),5,0.25,0.0001,0.9999); - - output[0]=out; - output[1]=out; - - // *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. - + + + //here, we're just compressing the file in real-time + //arguments are input,ratio,threshold,attack,release + out=compressor.compress(beats.play()); + + output[0]=out; + output[1]=out; + } diff --git a/maximilian_examples/20.additive.cpp b/maximilian_examples/20.additive.cpp deleted file mode 100644 index 753434d..0000000 --- a/maximilian_examples/20.additive.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "maximilian.h" - -maxiOsc sineBank[10];//let's create an oscillator and give it a name. - -void setup() {//some inits - //nothing to go here this time -} - - - -void play(double *output) {//this is where the magic happens. Very slow magic. - - double wave=0; - double f0 = 100; - for(int i=0; i < 10; i++) { - double thisSine = wave + sineBank[i].sinewave(f0 + (i * f0)); - double multiplier = 1.0 / (i+1.0); - thisSine = thisSine * multiplier; - wave = wave + thisSine; - } - wave *= 0.1; - *output = wave;//simple as that! - - -} - |
