mic input speaker out

22 May 2011

How do I get the mic input to output to the speaker analog output, also not to sure about how to set the buffer, I want to set a buffer without a limit, and then have the mic continuously output to the speaker like a karaoke or headphone mic monitor

#include "mbed.h"

AnalogIn input(p20);
DigitalOut led1(LED1);
AnalogOut speaker(p18);

int main() {
    unsigned short samples[1024];

    for(int i=0; i<1024; i++) {
        samples[i] = input.read_u16();
        wait_ms(1);
    }

    printf("Results:\n");
    for(int i=0; i<1024; i++) {
        printf("%d, 0x%04X\n", i, samples[i]);
        speaker.write_u16(samples[i]);
    }
}
22 May 2011

For some reason it will only work with this code?? and if I did get anything working with other code the gain for the output was lower?

this code

http://mbed.org/users/vsergeev/programs/echo_effect/5zrah/docs/main_8cpp_source.html