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:
- 3:f8bc3ac22ffd
- Parent:
- 2:1b50325e256f
- Child:
- 4:efa5e07fd268
diff -r 1b50325e256f -r f8bc3ac22ffd main.cpp
--- a/main.cpp Sat Jul 30 06:04:21 2016 +0000
+++ b/main.cpp Sat Jul 30 06:42:24 2016 +0000
@@ -34,8 +34,9 @@
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, 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;
+meas2f = 0.5, measf = 0, measf2 = 0, measf3 = 0, measf3L = 0, measf3L2 = 0, measf3L3 = 0, measf3R = 0, measf3R2 = 0, measf3R3 = 0,
+left_out_f = 0, right_out_f = 0;
+float left_out_2 = 0, right_out_2 = 0, left_out_3 = 0, right_out_3 = 0, loopfb = 0, loopfb2 = 0;
float audioFeedbackRight,audioFeedbackLeft;
float LPdampingFreq = 11000, HPdampingFreq = 100; //some parameters you might want to adjust.
@@ -46,13 +47,17 @@
OnePoleLp feedbackFilter;
OnePoleLp lengthFilter;
AllPass delayLeft;
+AllPass delayLeft2;
+AllPass delayLeft3;
AllPass delayRight;
-AllPass delayLeft2;
AllPass delayRight2;
-gsOsc Oscillator;
-gsOsc Oscillator2;
-gsOsc Oscillator3;
-gsOsc Oscillator4;
+AllPass delayRight3;
+gsOsc OscillatorL;
+gsOsc OscillatorL2;
+gsOsc OscillatorL3;
+gsOsc OscillatorR;
+gsOsc OscillatorR2;
+gsOsc OscillatorR3;
void I2S_send(void){
cs.write(0); //0 for left output
@@ -74,33 +79,45 @@
//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);
+ measf3L = DELAYLEN*.94 + OscillatorL.process(.013,DELAYLEN/26,1);
+ measf3L2 = DELAYLEN*.73 + OscillatorL2.process(.012,DELAYLEN/25,1);
+ measf3L3 = DELAYLEN*.43 + OscillatorL3.process(.02,DELAYLEN/28,1);
//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;
+ measf3R = DELAYLEN*.95 + OscillatorR.process(.011,DELAYLEN/29,0);
+ measf3R2 = DELAYLEN*.79 + OscillatorR2.process(.015,DELAYLEN/27,0);
+ measf3R3 = DELAYLEN*.43 + OscillatorR3.process(.02,DELAYLEN/28,1);
+ if(measf3L > DELAYLEN*.9)
+ measf3L = DELAYLEN*.9;
+ if(measf3L < DELAYLEN*.05)
+ measf3L = DELAYLEN*.05;
+ if(measf3L2 > DELAYLEN*.9)
+ measf3L2 = DELAYLEN*.9;
+ if(measf3L2 < DELAYLEN*.05)
+ measf3L2 = DELAYLEN*.05;
+ if(measf3L3 > DELAYLEN*.9)
+ measf3L3 = DELAYLEN*.9;
+ if(measf3L3 < DELAYLEN*.05)
+ measf3L3 = DELAYLEN*.05;
+ if(measf3R > DELAYLEN*.9)
+ measf3R = DELAYLEN*.9;
+ if(measf3R < DELAYLEN*.05)
+ measf3R = DELAYLEN*.05;
+ if(measf3R2 > DELAYLEN*.9)
+ measf3R2 = DELAYLEN*.9;
+ if(measf3R2 < DELAYLEN*.05)
+ measf3R2 = DELAYLEN*.05;
+ if(measf3R3 > DELAYLEN*.9)
+ measf3R3 = DELAYLEN*.9;
+ if(measf3R3 < DELAYLEN*.05)
+ measf3R3 = DELAYLEN*.05;
+ left_out_2 = delayLeft2.process(satAdd(left_in_f,loopfb),.7,measf3L);
+ left_out_3 = delayLeft3.process(left_out_2,.5,measf3L2);
+ left_out_f = delayLeft.process(left_out_3,.6,measf3L3);
+ right_out_2 = delayRight2.process(satAdd(left_in_f,loopfb2),.7,measf3R);
+ right_out_3 = delayRight3.process(right_out_2,.5,measf3R2);
+ right_out_f = delayRight.process(right_out_3,.6,measf3R3);
+ loopfb = left_out_f*feedback3;
+ loopfb2 = right_out_f*feedback3;
left_out_u = satAdd(left_in_f,left_out_f);
right_out_u = satAdd(left_in_f,right_out_f);