voice recorder

Go To Last Post
15 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After building a simple wav player i would like to build a voice recorder.Get ADC samples and save it in wav format...first of all I attempt to create a simple wave file with 2 samples.

I refer this tutorial

https://ccrma.stanford.edu/cours...

But I fail to create a sample wav file using ancii c compiler.(I create a "sample.wav" file of 46 bytes.When I started to open it in mediaplayer it will give an error.. )Can any body Help me....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The wav file contains the speech data. If you are reading the a/d 8000 times a sec and saving a byte from each reading, you have to save 8K per sec to a file somewhere. You could do this with a real fast serial port, or you could try to compile the file system routines for an sd card to save your data. If you get a mega2560, you can store about 200K of data in flash, but this is 'canned speech' for playback, not for recording.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can any body give me a sample code for creating a simple wav file.....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A quick google search found this: http://karplus4arduino.wordpress.com/2011/10/08/making-wav-files-from-c-programs/. Plenty of examples out there.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Can any body give me a sample code for creating a simple wav file.....

As you've already noted most of the 44 byte header of a WAV file holding something simple like 8bit mono PCM data is fixed. As discussed in another thread the other day the only thing that really varies in the header are the length fields. So if you know how much data you are about to write you should be able to take a fixed copy of the usual 44 bytes then just fix up the length fields within it. Write those 44 bytes then the rest of the sample data and you are done. If you don't know the length at the start, write the fixed 44 anyway with the length fields set to 0. Then write the data and finally at the end f_seek() back to the start and re-write the length info once it is known.

Can you post one of the WAV files you have created so we can take a look at the header and maybe suggest what part of it you have got wrong?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is the project...

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The ONLY thing I can see different in that (apart from the lenghts that I didn't check) between an 8bit mono 8kHz file I have and the one you created is the 16th byte (the one after "fmt"). In the working file I have the byte is 0x20 (ie space) while in your file it is 0x00 (NUL). Otherwise it looks like it should work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you clawson.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can use the pc sound recorder to record voice files, and you can use audacity to edit them and convert the number of bits and samples per sec.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

These days I tried to make my own simple wav file with four samples.
But I fail to create a sample wav file using ancii c compiler.(I create a "sample.wav" file of 46 bytes.When I started to open it in mediaplayer it will give an error.. )Can any body Help me....
Can any body detect the error and remake my project to create a successful wav file..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
The ONLY thing I can see different in that (apart from the lenghts that I didn't check) between an 8bit mono 8kHz file I have and the one you created is the 16th byte (the one after "fmt"). In the working file I have the byte is 0x20 (ie space) while in your file it is 0x00 (NUL). Otherwise it looks like it should work.

As you told there is a small mismatch.But I cannot correct the error can you please correct it and post... :D

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well apart from that error the file you had generated in the zip did not have the number of sample bytes the headers said. I imagine most players will fstat() the file and complain about this. You might get away with a file that said there were less bytes than actually exist though.

When I'm next near a PC I'll have a go at writing a program to generate a wav with a sine wave in it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

When I'm next near a PC I'll have a go at writing a program to generate a wav with a sine wave in it.

If you write that program please send it to me it will be really useful to me.... :D

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can any body give me a simple wav file coding please....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is your city and country?

Imagecraft compiler user