Synthesis - from mic??

Hello everybody,

I just made a project that reads analog input from a mic or audio source and outputs it as numbers.

Now, i thought if there is a way to take that mic input (float variable) and reverse it back into a speaker so i will get exactly the same result broadcasted, real time.

this is my current code:

int analogPin = 0; //PIN to be read
float x = 0;  //Analog input
float y = 0;  //What to output after math

void setup() {
 Serial.begin(9600); 
}

void loop() {
  x = analogRead(analogPin);
  y = x; //here i will do some math to fit my project..
  Serial.println(y);
}

i thought if there is a way to take that mic input (float variable) and reverse it back into a speaker so i
will get exactly the same result broadcasted, real time.

Then what?
Are you thinking noise cancellation? If so then no it is not that easy. All you are doing is getting an out of phase signal, you can get that by just reversing the speaker wires.

Two things:-

  1. It won’t be exactly the same it will be a sample period behind.
  2. Unless you have an external D/A the best you can do is the PWM output and that is only 8 bits (0 to 255)

Dont worry Grumpy_Mike, i got that covered. all the D/A problems are already solved, and also a bit of delay is no problem at all. Do you know a way to do that sound synthesis without FFT since i just dont need it?

Still not sure what you want to do?

Just output that noise ^^

void loop() {
  x = analogRead(analogPin);
  y = 1023 - x;
  // output y to the D/A
}