voice changer, contains echo, change low voice and high voice.

Dependencies:   mbed

condenser microphone connect to p16, audio amplifier and speaker connect to p18, and pull-upped switch connect to p5 for chage voice of low voice, high voice and ecoed voice.

test video-> http://youtu.be/z-7Hj0u6OlA

/media/uploads/hayama/2014-08-11_20.21.54.jpg

Files at this revision

API Documentation at this revision

Comitter:
hayama
Date:
Tue Aug 12 01:20:44 2014 +0000
Commit message:
voice changer, contains echo, change low voive and high voice.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
temp.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r f4cbe4a0f1be main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Aug 12 01:20:44 2014 +0000
@@ -0,0 +1,82 @@
+
+// voice changer all function
+#include "mbed.h"
+#define ARRAY 4000
+#define ARRAYLM1 1999
+#define ARRAYHM1 999
+#define ARRAYEM1 3999
+#define DELAYTIME 2000
+#define ECHOFACTOR 0.5
+
+float micCB;
+float x[ARRAY];
+float y;
+int j=0,k=0,n=0;
+int mode=0;
+
+DigitalIn sw(p5);
+AnalogIn micC(p16);         
+AnalogOut spOut(p18);
+BusOut   leds( LED4, LED3, LED2, LED1 ); 
+
+// voice changer (low voice)
+void lowVoice(){
+    while(sw) { 
+        n++; if (n>1) n=0;
+        if (n==0){ k++; if (k>ARRAYLM1) k=0; }
+        j++; if(j>ARRAYLM1) j=0;
+        x[j]=micC-micCB; 
+        y=x[k];
+        spOut=y*10+0.5;
+        leds=abs(y*1000);
+        wait_us(20);
+    }
+}
+
+// voice changer (high voice)
+void highVoice() {
+    while(sw) { 
+        n++; if (n>1) n=0;
+        if (n==0){ k++; if (k>ARRAYHM1) k=0; }
+        j++; if(j>ARRAYHM1) j=0;
+        x[k]=micC-micCB; 
+        y=x[j];
+        spOut=y*10+0.5;
+        leds=abs(y*1000);
+        wait_us(10);
+    }
+}
+
+// voice changer (ECHO)
+void echoVoice() {
+    k=DELAYTIME;    
+    while(sw) { 
+        j++; if(j>ARRAYEM1) j=0;
+        k++; if (k>ARRAYEM1) k=0;
+        y=x[j]+=micC-micCB;      
+        x[k]=x[j]*ECHOFACTOR;       
+        
+        spOut=y*10+0.5;
+        leds=abs(y*1000);
+        wait_us(50);
+    }
+}
+
+//------------------main-----------------------
+int main() {
+    wait(2);
+    micCB=0;
+    for(int i=0;i<1000;i++){ micCB+=micC; } 
+    micCB/=1000;   
+    
+    while(1){
+        switch(mode){
+            case 0: lowVoice(); break;
+            case 1: highVoice(); break;
+            case 2: echoVoice(); break;
+        }
+        while(sw==0);
+        wait(0.5);
+        mode++; if (mode>2) mode=0;
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f4cbe4a0f1be mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Aug 12 01:20:44 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae
\ No newline at end of file
diff -r 000000000000 -r f4cbe4a0f1be temp.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/temp.cpp	Tue Aug 12 01:20:44 2014 +0000
@@ -0,0 +1,233 @@
+/*
+// normal voice
+#include "mbed.h"
+float micCB;
+float y;
+
+AnalogIn micC(p16);         
+AnalogOut spOut(p18);
+BusOut   leds( LED4, LED3, LED2, LED1 ); 
+
+int main() {
+    wait(2);
+    
+    micCB=0;
+    for(int i=0;i<1000;i++){
+        micCB+=micC;
+    }
+    micCB/=1000;   
+    
+    while(1) { 
+        y=micC-micCB; 
+        spOut=y*10+0.5;
+        leds=abs(y*1000);
+        wait_us(20);
+    }
+}
+
+
+
+
+
+// y wo 2 kai syuuki de 0
+#include "mbed.h"
+float micCB;
+float y;
+int j;
+
+AnalogIn micC(p16);         
+AnalogOut spOut(p18);
+BusOut   leds( LED4, LED3, LED2, LED1 ); 
+
+int main() {
+    wait(2);
+    
+    micCB=0;
+    for(int i=0;i<1000;i++){
+        micCB+=micC;
+    }
+    micCB/=1000;   
+    
+    while(1) { 
+        j++; if(j>1) j=0;
+        if(j==0) y=micC-micCB;  else y=0;
+        if (abs(y)>0.005) spOut=y*10+0.5;
+        leds=abs(y*1000);
+        wait_us(20);
+    }
+}
+
+
+
+
+// idouheikin 
+#include "mbed.h"
+float micCB;
+float x1,x2,x3,x4;
+float y;
+int j;
+
+AnalogIn micC(p16);         
+AnalogOut spOut(p18);
+BusOut   leds( LED4, LED3, LED2, LED1 ); 
+  
+int main() {
+    wait(2);
+    
+    micCB=0;
+    for(int i=0;i<1000;i++){
+        micCB+=micC;
+    }
+    micCB/=1000;   
+    
+    while(1) { 
+        y=x2+x1;
+        x2=x1;
+        x1=micC-micCB; 
+        spOut=y*10+0.5;
+        leds=abs(y*1000);
+        wait_us(10);
+    }
+}
+
+
+
+
+// smoothing voice
+#include "mbed.h"
+float micCB;
+float x1,x2,x3,x4;
+float y;
+int j;
+
+AnalogIn micC(p16);         
+AnalogOut spOut(p18);
+BusOut   leds( LED4, LED3, LED2, LED1 ); 
+
+float smooth(float a, float b, float factor){
+    return(a*factor+b*(1-factor));
+}
+    
+int main() {
+    wait(2);
+    
+    micCB=0;
+    for(int i=0;i<1000;i++){
+        micCB+=micC;
+    }
+    micCB/=1000;   
+    
+    while(1) { 
+        //y=x2+x1;
+        //x2=x1;
+        y=smooth(micC-micCB,y,0.05); 
+        spOut=y*10+0.5;
+        leds=abs(y*1000);
+        wait_us(10);
+    }
+}
+
+
+
+
+// voice changer (low voice)
+#include "mbed.h"
+#define ARRAY 2000
+#define ARRAYM1 1999
+
+float micCB;
+float x[ARRAY];
+float y;
+int j=0,k=0,n=0;
+AnalogIn micC(p16);         
+AnalogOut spOut(p18);
+BusOut   leds( LED4, LED3, LED2, LED1 ); 
+
+int main() {
+    wait(2);
+    micCB=0;
+    for(int i=0;i<1000;i++){ micCB+=micC; } 
+    micCB/=1000;   
+    
+    while(1) { 
+        n++; if (n>1) n=0;
+        if (n==0){ k++; if (k>ARRAYM1) k=0; }
+        j++; if(j>ARRAYM1) j=0;
+        x[j]=micC-micCB; 
+        y=x[k];
+        spOut=y*10+0.5;
+        leds=abs(y*1000);
+        wait_us(20);
+    }
+}
+
+
+// voice changer (high voice)
+#include "mbed.h"
+#define ARRAY 1000
+#define ARRAYM1 999
+
+float micCB;
+float x[ARRAY];
+float y;
+int j=0,k=0,n=0;
+AnalogIn micC(p16);         
+AnalogOut spOut(p18);
+BusOut   leds( LED4, LED3, LED2, LED1 ); 
+
+int main() {
+    wait(2);
+    micCB=0;
+    for(int i=0;i<1000;i++){ micCB+=micC; } 
+    micCB/=1000;   
+    
+    while(1) { 
+        n++; if (n>1) n=0;
+        if (n==0){ k++; if (k>ARRAYM1) k=0; }
+        j++; if(j>ARRAYM1) j=0;
+        x[k]=micC-micCB; 
+        y=x[j];
+        spOut=y*10+0.5;
+        leds=abs(y*1000);
+        wait_us(10);
+    }
+}
+
+
+
+
+// voice changer (ECHO)
+#include "mbed.h"
+#define ARRAY 4000
+#define ARRAYM1 3999
+#define DELAYTIME 2000
+#define ECHOFACTOR 0.6
+
+float micCB;
+float x[ARRAY];
+float y;
+int j=0,k=0,n=0;
+AnalogIn micC(p16);         
+AnalogOut spOut(p18);
+BusOut   leds( LED4, LED3, LED2, LED1 ); 
+
+int main() {
+    wait(2);
+    micCB=0;
+    for(int i=0;i<1000;i++){ micCB+=micC; } 
+    micCB/=1000;   
+    
+    k=DELAYTIME;    
+    while(1) { 
+        j++; if(j>ARRAYM1) j=0;
+        k++; if (k>ARRAYM1) k=0;
+        y=x[j]+=micC-micCB;      
+        x[k]=x[j]*ECHOFACTOR;       
+        
+        spOut=y*10+0.5;
+        leds=abs(y*1000);
+        wait_us(50);
+    }
+}
+
+*/
\ No newline at end of file