Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 2:1b50325e256f
- Parent:
- 1:a4ce08417c60
- Child:
- 3:f8bc3ac22ffd
diff -r a4ce08417c60 -r 1b50325e256f main.cpp
--- a/main.cpp Sat Jul 30 02:21:09 2016 +0000
+++ b/main.cpp Sat Jul 30 06:04:21 2016 +0000
@@ -14,13 +14,14 @@
//Cubic interpolation might be a possibility if I can figure out how it works.
//Added a nice lowpass filter class. Might want to put the delay in a class like this for reverb work. Need to make an oscillator next.
-#define DELAYLEN 11500 //24,000 is about as far as you can go in the ram.
+#define DELAYLEN 3900 //24,000 is about as far as you can go in the ram.
#define SAMPLINGFREQ 22 //roughly the smapling frequency in KHz. options are 22,29,44,88 for 22khz,29khz,etc..
#include "mbed.h"
#include "dsp.h"
#include "allpass.h"
#include "codec.h"
+#include "osc.h"
SPI spi(SPI_MOSI,SPI_MISO,SPI_SCK);
Ticker timer;
@@ -33,7 +34,8 @@
index1 = 0, index2 = (DELAYLEN*0.99), index3 = (DELAYLEN*0.99);
uint16_t left_in_u = 0, meas = 0, measprev = 0;
float left_in_f = 0, feedback = 0, feedback2 = 0, feedback3 = 0, offset = 10.0,
-meas2f = 0.5, measf = 0, measf2 = 0, measf3 = 0, left_out_f = 0, right_out_f = 0;
+meas2f = 0.5, measf = 0, measf2 = 0, measf3 = 0, measf3b = 0, measf3c = 0, measf3d = 0, left_out_f = 0, right_out_f = 0;
+float left_out_2 = 0, right_out_2 = 0, loopfb = 0, loopfb2 = 0;
float audioFeedbackRight,audioFeedbackLeft;
float LPdampingFreq = 11000, HPdampingFreq = 100; //some parameters you might want to adjust.
@@ -45,6 +47,12 @@
OnePoleLp lengthFilter;
AllPass delayLeft;
AllPass delayRight;
+AllPass delayLeft2;
+AllPass delayRight2;
+gsOsc Oscillator;
+gsOsc Oscillator2;
+gsOsc Oscillator3;
+gsOsc Oscillator4;
void I2S_send(void){
cs.write(0); //0 for left output
@@ -64,9 +72,35 @@
measf3 = lengthFilter.process(measf2);
measf3 *= (DELAYLEN); //convert to delay index normalization
- //process audio
- left_out_f = delayLeft.process(left_in_f,feedback3,measf3);
- right_out_f = delayRight.process(left_in_f,feedback3,measf3+offset); //add an offset in just for shits.
+ //process audio. probably calculate these coefficients elsewhere so you don't do the multiply all the time.
+ //left delay mod
+ measf3 = DELAYLEN*.64 + Oscillator.process(.013,DELAYLEN/16,1);
+ measf3c = DELAYLEN*.23 + Oscillator3.process(.012,DELAYLEN/15,0);
+ //right delay mod
+ measf3b = DELAYLEN*.75 + Oscillator2.process(.011,DELAYLEN/19,0);
+ measf3d = DELAYLEN*.29 + Oscillator4.process(.015,DELAYLEN/17,0);
+ if(measf3 > DELAYLEN*.9)
+ measf3 = DELAYLEN*.9;
+ if(measf3 < DELAYLEN*.05)
+ measf3 = DELAYLEN*.05;
+ if(measf3b > DELAYLEN*.9)
+ measf3b = DELAYLEN*.9;
+ if(measf3b < DELAYLEN*.05)
+ measf3b = DELAYLEN*.05;
+ if(measf3c > DELAYLEN*.9)
+ measf3c = DELAYLEN*.9;
+ if(measf3c < DELAYLEN*.05)
+ measf3c = DELAYLEN*.05;
+ if(measf3d > DELAYLEN*.9)
+ measf3d = DELAYLEN*.9;
+ if(measf3d < DELAYLEN*.05)
+ measf3d = DELAYLEN*.05;
+ left_out_2 = delayLeft2.process(satSubtract(left_in_f,loopfb),.7,measf3c);
+ left_out_f = delayLeft.process(left_out_2,.8,measf3);
+ right_out_2 = delayRight2.process(satSubtract(left_in_f,loopfb2),.7,measf3d);
+ right_out_f = delayRight.process(right_out_2,.8,measf3b); //add an offset in just for shits.
+ loopfb = left_out_2*feedback3;
+ loopfb2 = right_out_2*feedback3;
left_out_u = satAdd(left_in_f,left_out_f);
right_out_u = satAdd(left_in_f,right_out_f);