Input and output of voice to arduino

Hello everyone,

i have an arduino nano and a mega board.

I want to make a project where i have input of voice/audio through a jack then maybe edit it(or maybe not if its impossible,not a big problem) and then output it at the same time to a speaker (jack again). Editing as i said is not a big problem for me if its impossible, because i do not want big delay in between input and output.
You will be wondering why input no edit and output! Because sometimes my software will decide if it will output the sound or if it will not output the sound.depends on some buttons that i will have.

About the buttons thing im happy to do it but how to input voice and output it through jacks?

Thanks in advance

Well you can do that but there are much simpler ways of switching an Audio stream with a simple analogue switch.

Otherwise get a PWM signal going at about 40KHz and use the analogue reading from the input to change the PWM duty cycle.

Hi, thanks for your reply.

Sorry but i dont know how to do that. Is there any tutorial?

What you said is going to be connected to the arduino board?
Sorry for my stupid questions but i have no idea.

Thank you in advance

Is there any tutorial?

I doubt it. Not for something this simple.
How are you wiring up your input, and what exactly is it?

Untested but something like this for a Uno / Nano:-

void setup() {
 setPWMtimer();
 pinMode(9, OUTPUT); // Make timer’s PWM pin an output
}

int inputSample;
void loop() {
  inputSample = analogRead(0) >> 2;
  OCR1AL = inputSample;
}

void setPWMtimer(){
// Set timer1 for 8-bit fast PWM output to use as our analogue output
 TCCR1B = _BV(CS10); // Set prescaler to full 16MHz
 TCCR1A |= _BV(COM1A1); // Pin low when TCNT1=OCR1A
 TCCR1A |= _BV(WGM10); // Use 8-bit fast PWM mode
 TCCR1B |= _BV(WGM12); 
 OCR1AL = 0x80; // start PWM going at half maximum 
}

Audio out is on pin 9, audio in is on analogue pin 0. The Audio in should be biased to 2.5V with two 10K resistors.

chris700:
Hello everyone,

i have an arduino nano and a mega board.

I want to make a project where i have input of voice/audio through a jack then maybe edit it(or maybe not if its impossible,not a big problem) and then output it at the same time to a speaker (jack again). Editing as i said is not a big problem for me if its impossible, because i do not want big delay in between input and output.
You will be wondering why input no edit and output! Because sometimes my software will decide if it will output the sound or if it will not output the sound.depends on some buttons that i will have.

About the buttons thing im happy to do it but how to input voice and output it through jacks?

Thanks in advance

Edit? What do you mean by edit?

Hello! Thank you guys for your replies.

@MarkT By editing I mean clear the sound from noise

@Grumpy_Mike

I was thinking to put a jack somehow on the arduino board and connect there a microphone.

Then have an other jack on the output and be able to "play" this sound.

So lets say if i run this code and connect the jack of output with a speaker it is supposed to play what the input has or i need amplifier in between etc?

THank you so much everyone

PS i guess the microphone has 2 cables in the cable a red and a black. black should go to ground and red to the analog input pin in arduino..right?

Is it just a microphone or a microphone board?
The output from a microphone is very small and will not drive the Arduino at all. It needs an amplifier between the microphone and the analogue input to produce a 5V peak to peak signal.this has to be biased at a D.C. level of 2.5V. Most amplifiers will do this but you will have to check.

The output will be a 5V peak to peak signal. This will probably be too much for an amplifier and you would have to cut it down with a potential divider circuit and maybe use a capacitor as a filter.

You will not be able to remove noise from the signal, infact you will be adding a bit of noise into it.

chris700:
@MarkT By editing I mean clear the sound from noise

Could you be less vague? Noise gating? De-hissing? what?

@Grumpy_Mike just a normal microphone…actually from a headset. Headset has 2 male jacks. One for speaker and one for microphone. The microphone one i want to plug it on my arduino somehow.

For input:
As far as I understand i need to connect the Microphone to an amplifier and the amplifier to arduino.

For output:
Arduino board will output that to “potential divider circuit” and then jack has to be connected to the output of the potentioal divider circuit?

@MarkT
By clearning noise i mean, when you speak to the microphone it will be on an open enviroment but lots of noise from wind and i was thinking somehow to “cancel” the frequencies from the sound and keep only voice…

Arduino board will output that to "potential divider circuit" and then jack has to be connected to the output of the potentioal divider circuit?

Yes. If you look it up a potential divider is just two resistors.

i was thinking somehow to "cancel" the frequencies from the sound and keep only voice..

That is not going to happen, sorry.

chris700:
@MarkT
By clearning noise i mean, when you speak to the microphone it will be on an open enviroment but lots of noise from wind and i was thinking somehow to "cancel" the frequencies from the sound and keep only voice..

That's a research project, don't imagine you can tackle this other than by simple noise gating.

chris700:
@Grumpy_Mike just a normal microphone..actually from a headset...

@MarkT
By cleaning noise i mean, when you speak to the microphone it will be on an open environment but lots of noise from wind and i was thinking somehow to "cancel" the frequencies from the sound and keep only voice..

What you are trying to do has long ago been solved by microphone manufacturers.

If you want a microphone that picks up speech clearly while cutting down on background noise then you need a noise cancelling microphone. The microphones used in many headsets are this kind so they can be used in a noisy office without the background noise being picked up. The simple way to tell is to look at whether the microphone is 'voice tube', that is, a thin plastic tube from the headset that is positioned in front of the mouth, these are NOT noise cancelling, or if the microphone itself is mounted on a boom that puts the microphone in front of the mouth, these are usually noise cancelling.

If you watch outside news broadcasts you will see the microphone used by the reporter has a big, soft muffler on it, this is also to reduce noise from wind.

chris700

Something else I’ve just thought of, if you are dealing with voice then you can limit the bandwidth with a bandpass filter, thus removing any noise outside the passband of the filter. Telephone quality is 300 to 3400 Hz, or maybe go a bit wider than that for better quality. You can use a fairly simple analogue filter with an op amp or 2 and some resistors and capacitors for this.

PerryBebbington:
What you are trying to do has long ago been solved by microphone manufacturers.

That's the easy problem - cancelling noise at the microphone using a second microphone.

Removing noise after the event from the recording is many orders of magnitude harder, you have
no way to cancel.