Audio recording in real time on the PC

I wonder if someone can explain to me how to do:

I have an analog stereo signal, would like to connect to the Arduino {INPUT}
and be able to record this audio sample in PC preferably in audacity
so I can generate a Sample_file.Wav.

However I am beginner, this will be my first project has not yet mastered the Arduino platform C’m more used to Pacal Delphi

How should I proceed to do this if you have an example I ask you please put the or link post here …

Sincerely,
Luiz Antonio

Why not use PC internal sound card & capture it direct in the PC using Sound Recorder, or maybe even audacity itself?

Complicating the process:
One way is to use Adafruit Wave Shield.
Won't be stereo tho.
I am working on mono 44.1K here with help from fat16lib who's done great work with high speed datalogging & SD cards.
http://forum.arduino.cc/index.php?topic=180769.30
Will be adding 16 bit ADC & DAC for the audio capture & creation.

CrossRoads:
Why not use PC internal sound card & capture it direct in the PC using Sound Recorder, or maybe even audacity itself?

Complicating the process:
One way is to use Adafruit Wave Shield.
Won't be stereo tho.
I am working on mono 44.1K here with help from fat16lib who's done great work with high speed datalogging & SD cards.
16-bit sample & store, then readback & play, finally store to SD - Programming Questions - Arduino Forum
Will be adding 16 bit ADC & DAC for the audio capture & creation.

HI, Cross
You commented exatamento the two most obvious point (Sound Card and SD Card)
His observation that correata however not solve my problem because:
For my project had used sound card would have to be doing configurations in accordance with the version of windows and this is not legal.E if not for windows?
Still do not know if it is possible to capture real-time amostrade SD Card.
But I think it depends on a card, my project would be a little fragile.

I have an analog stereo signal, would like to connect to the Arduino {INPUT}
and be able to record this audio sample in PC preferably in audacity.

So basically, you are trying to build your own USB soundcard? If you want to do that for some reason, it would probably be cheaper & easier to use a soundcard chip, and you might get better sound quality.

For my project had used sound card would have to be doing configurations in accordance with the version of windows and this is not legal.E if not for windows?

What's not legal???? There's nothing illegal about writing an application that uses the existing Windows drivers (or Linux or OS-X drivers).

DVDdoug:

I have an analog stereo signal, would like to connect to the Arduino {INPUT}
and be able to record this audio sample in PC preferably in audacity.

So basically, you are trying to build your own USB soundcard? If you want to do that for some reason, it would probably be cheaper & easier to use a soundcard chip, and you might get better sound quality.

For my project had used sound card would have to be doing configurations in accordance with the version of windows and this is not legal.E if not for windows?

What’s not legal??? There’s nothing illegal about writing an application that uses the existing Windows drivers (or Linux or OS-X drivers).

Once again thank you for all that you write here,

  • I’ll try to explain my problem:*

I have project in Aduino where I sent two cables to the PC.
One is the data via USB-Arduino and other audio input microphone Via the PC, I would like to unify all sending only the USB port and send to Arduino serial port.
I do not know how to put in (capture, send and store) audio sample on the serial port
Here in this example shows how to capture,
http://interface.khm.de/index.php/lab/experiments/arduino-realtime-audio-processing/
but do not know how to send
this sample and store the serial port.
If anyone knows put an example HERE:
thank you,

this sample and store the serial port.

Yes but it is only a tiny buffer, only a fraction of a second.

Please do not use PMs for technical matters.
You wrote:-

I am new to programming Arduino,
would very much like you to help me this question:
Streaming Audio over Serial - Exhibition - Arduino Forum

This code is exactly what I need, however
these questions I do not know:

1st I have two Audio input (Mic_A and Mic_B):
/ * How to read data from the same buffer Microphones
since it has only 8bits.
would be better to use the analog ports of araduino} * /

2nd - Sending Buffer to Serial port:
/ / * Cause I need to capture the data buffer in another inteface * / /

It is not clear if you want to record in stereo. If so you need twice the buffer space and can only run at half the speed. If you want to use mono then combine the two audio signals with a mixer before you digitize them.
What arduino are you using?
The USB input and the serial input are the same thing for a lot of models so you can not use them for different things.

Grumpy_Mike:

this sample and store the serial port.

Yes but it is only a tiny buffer, only a fraction of a second.

Please do not use PMs for technical matters.
You wrote:-

I am new to programming Arduino,
would very much like you to help me this question:
Streaming Audio over Serial - Exhibition - Arduino Forum

This code is exactly what I need, however
these questions I do not know:

1st I have two Audio input (Mic_A and Mic_B):
/ * How to read data from the same buffer Microphones
since it has only 8bits.
would be better to use the analog ports of araduino} * /

2nd - Sending Buffer to Serial port:
/ / * Cause I need to capture the data buffer in another inteface * / /

It is not clear if you want to record in stereo. If so you need twice the buffer space and can only run at half the speed. If you want to use mono then combine the two audio signals with a mixer before you digitize them.
What arduino are you using?
The USB input and the serial input are the same thing for a lot of models so you can not use them for different things.

Dear Friend,
I'll try to be more objective:
How can I capture and send audio to another interface (Visual Basic or Delphi)

I Do 2 control line through the Arduino telephonic Duelamilanove
Using Digital Audio ports However online'm sending these to
recording the microphone input of the sound card of the PC.

I would send these two channels of audio (8bit Mono Each)
the analog ports of the Arduino, sending these audio data for some
place the computer where I can capture this audio buffer
through my interface and then do the Recording file individually
each telephone line.

Still not sure what you mean. I have attached this diagram is this what you are trying to do? Take two analogue inputs, convert them to digital, send them to a PC and have the PC write two separate files, one for each audio stream?

If this is correct then there are several problems with doing this.

First off the normal analogRead can only take samples at 10KHz, so that would only give you a sample rate of 5KHz per channel. There are ways to speed it up though all be it at a reduced resolution. This is fine for you because the A/D in the Arduino is 10 bits and you are only after 8 bits. There are lots of threads on how to do this. Here is one I found:-
http://forum.arduino.cc/index.php/topic,6549.0.html

Next is the speed of the serial port. Again the standard rate is too slow, but you can speed this up:-

You have to make sure that your PC can run at the same speed as the Arduino.

Next comes the problem of transmission, as the two sample stream are 8 bits the sample values could be anything. You have to be able to uniquely identify each sample at the receiving end. But your sample could be any value so you have to send extra bytes to tag the information. Perhaps the simplest method is to send three bytes per sample. There are many ways to do this but off the top of my head how about this one. The first byte would have bit 7, the most significant bit set. All the other bits would be clear apart from the two least significant bits which would be set or cleared according to if the most significant bits of the sample 1 and 2 were set. Then the next two bytes would be the sample with the most significant bit cleared.

This way the first byte in a package is identifiable and the PC application would read the serial data until a first byte is recognised. Then it would read the following two bytes, put back the missing most significant bit from each sample and store them in different files.

Hope that helps you.

audio recording (10.9 KB)

Grumpy_Mike:
Still not sure what you mean. I have attached this diagram is this what you are trying to do? Take two analogue inputs, convert them to digital, send them to a PC and have the PC write two separate files, one for each audio stream?

If this is correct then there are several problems with doing this.

First off the normal analogRead can only take samples at 10KHz, so that would only give you a sample rate of 5KHz per channel. There are ways to speed it up though all be it at a reduced resolution. This is fine for you because the A/D in the Arduino is 10 bits and you are only after 8 bits. There are lots of threads on how to do this. Here is one I found:-
http://forum.arduino.cc/index.php/topic,6549.0.html

Next is the speed of the serial port. Again the standard rate is too slow, but you can speed this up:-
Modified Arduino library, Serial | Mekonikuv blog
You have to make sure that your PC can run at the same speed as the Arduino.

Next comes the problem of transmission, as the two sample stream are 8 bits the sample values could be anything. You have to be able to uniquely identify each sample at the receiving end. But your sample could be any value so you have to send extra bytes to tag the information. Perhaps the simplest method is to send three bytes per sample. There are many ways to do this but off the top of my head how about this one. The first byte would have bit 7, the most significant bit set. All the other bits would be clear apart from the two least significant bits which would be set or cleared according to if the most significant bits of the sample 1 and 2 were set. Then the next two bytes would be the sample with the most significant bit cleared.

This way the first byte in a package is identifiable and the PC application would read the serial data until a first byte is recognised. Then it would read the following two bytes, put back the missing most significant bit from each sample and store them in different files.

Hope that helps you.

Thanks Mike,

Your explanation points to the right direction,
looking at this example: Arduino Audio Input : 8 Steps (with Pictures) - Instructables
I believe that with a few more details I can achieve mygoal.
I hope more people put their opinions because they are all very
validates for me that I'm starting.

luiz_antoniosp:

Grumpy_Mike:
Still not sure what you mean. I have attached this diagram is this what you are trying to do? Take two analogue inputs, convert them to digital, send them to a PC and have the PC write two separate files, one for each audio stream?

If this is correct then there are several problems with doing this.

First off the normal analogRead can only take samples at 10KHz, so that would only give you a sample rate of 5KHz per channel. There are ways to speed it up though all be it at a reduced resolution. This is fine for you because the A/D in the Arduino is 10 bits and you are only after 8 bits. There are lots of threads on how to do this. Here is one I found:-
http://forum.arduino.cc/index.php/topic,6549.0.html

Next is the speed of the serial port. Again the standard rate is too slow, but you can speed this up:-
http://mekonik.wordpress.com/2009/03/02/modified-arduino-library-serial/
You have to make sure that your PC can run at the same speed as the Arduino.

Next comes the problem of transmission, as the two sample stream are 8 bits the sample values could be anything. You have to be able to uniquely identify each sample at the receiving end. But your sample could be any value so you have to send extra bytes to tag the information. Perhaps the simplest method is to send three bytes per sample. There are many ways to do this but off the top of my head how about this one. The first byte would have bit 7, the most significant bit set. All the other bits would be clear apart from the two least significant bits which would be set or cleared according to if the most significant bits of the sample 1 and 2 were set. Then the next two bytes would be the sample with the most significant bit cleared.

This way the first byte in a package is identifiable and the PC application would read the serial data until a first byte is recognised. Then it would read the following two bytes, put back the missing most significant bit from each sample and store them in different files.

Hope that helps you.

Thanks Mike,

Your explanation points to the right direction,
looking at this example: http://www.instructables.com/id/Arduino-Audio-Input/
I believe that with a few more details I can achieve mygoal.
I hope more people put their opinions because they are all very
validates for me that I’m starting.

Hello, Mike
I want to tell you that I am very grateful to enormous help you have given to me.
All I understood your explanation, however I am having difficulty in the transmission, I’m not getting the message, peopl you a little patience, because I’m still beginner. Could you show me an example of how I do it:

{
Problem of transmission, the sample stream are the two 8-bit values ??the sample Could be anything. You have to be able to uniquely Identify each sample at the receiving end. But your sample Could be any value so you have to send extra bytes to the tag information. Perhaps the simplest method is to send three bytes per sample. There are many ways to do this but off the top of my head how about this one. The first byte would have bit 7, the Most Significant bit set. All the other bits would be clear apart from the two least significant bits Which would be September or cleared if According to the Most Significant bit of the sample 1 and 2 were in September Then the next two bytes would be the sample with the most significant bit cleared.
This way the first byte in the package is identifiable and the PC application would read the serial data until the first byte is Recognised. Then it would read The Following two bytes, put back the missing most significant bit from each sample and store Them in different files.
}
Here is a point I made in the diagram:
Thank you for now.

In order to understand this code you will nee to know about this:-
http://playground.arduino.cc/Code/BitMath

First to make the three bytes to send assume you have two 8 bit samples in the variables sample1 and sample2

head = 0x80; 
if( (sample1 & 0x80) != 0 ) head |= 0x01;
if( (sample2 & 0x80) != 0 ) head |= 0x02;
sample1 &= 0x7f;
sample2 &= 0x7f;
// the three bytes head ssample1 and sample2 are ready to send

Now on the receive end you will need to do the equivalent of this in what ever language you use:-

  1. wait until a header arrives - you know when because its most significant bit will be set.
  2. read the two samples
  3. restore the most significant bit for each sample
  4. store each sample in a separate file
   head = 0;
   while((head & 0x80) == 0) {
    while(Serial.available() == 0) { } // do nothing until a byte arrives
    head = Serial.read();
   }
   while(Serial.available() == 0) { } // do nothing until a byte arrives
    sample1 = Serial.read();
   while(Serial.available() == 0) { } // do nothing until a byte arrives
    sample2 = Serial.read();
    // restore sample's most significant bits
    if( ( head & 0x01) !=0) sample1 |= 0x80;
    if( ( head & 0x02) !=0) sample2 |= 0x80;