Go Down

Topic: Record audio from a microphone to an SD card? (Read 18929 times) previous topic - next topic

flyrontech

#15
Feb 26, 2016, 08:11 am Last Edit: Mar 10, 2016, 12:47 pm by flyrontech
FN-RM01 is a high quality MP3 audio recorder that can record voice messages to a micro SD card. Maybe you can take a few to try. It's available here on Aliexpress.
http://www.aliexpress.com/item/Digital-Audio-Recorder-with-Playback-Function-2-PCS-A-lot-MP3-Sound-Recorder-Module-micro-SD/32603016265.html?spm=2114.01010208.3.1.7UHOP1&ws_ab_test=searchweb201556_6,searchweb201602_3_505_506_503_504_10020_502_10014_10001_10002_10017_10005_10006_10003_10021_10004_10022_10018_10019,searchweb201603_1&btsid=9ee0e5dc-21b1-41d5-9541-67a047a64b5f
In pursuit of top quality and professional services.

Lucario448

No that one is way too slow. It will only work at 1M samples per second. You have a 16MHz processor so to actually measure anything approaching accurately you need it 100 times better than this.
Oh well, I don't wanna spend a lot of money on this, so the micros timer is my only way I think.

By the way, the MP3 module can be useful for this purpose, but I just wanna use the Arduino itself if possible. But, because the MCU hasn't enough memory for record sounds, then the cheapest way to get more space, is by interacting with a SD card (in any form factor). However, thanks anyways...

CrossRoads

#17
Feb 26, 2016, 10:02 pm Last Edit: Feb 26, 2016, 10:02 pm by CrossRoads
Take a read thru here
http://forum.arduino.cc/index.php?topic=180769.0
I designed this card for the project, got hung up on integrating the ADC & DAC into it, but left myself some room to play some more when I had some time. You can see that fat16lib had the code working to record mono audio to SD card at CD quality speed/data (16 bit data, 44.1 KHz)
http://www.crossroadsfencing.com/BobuinoRev17/
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

(and I got carried away and added screw terminals too vs making them a shield to sit on top)
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Lucario448

Take a read thru here
http://forum.arduino.cc/index.php?topic=180769.0
I've read it. Is that the code for that board of yours?

Quote
I designed this card for the project, got hung up on integrating the ADC & DAC into it, but left myself some room to play some more when I had some time. You can see that fat16lib had the code working to record mono audio to SD card at CD quality speed/data (16 bit data, 44.1 KHz)
http://www.crossroadsfencing.com/BobuinoRev17/
Is that like "all-I-need-in-one" board? Yeah, it looks promising, but... I'm trying to keep up with the simple stuff.
By the way, how you can achieve a higher sampling rate? Because of the SRAM or the ADC?

And again, thank you for your replys!

Lucario448

Oh and one more thing. This is how my SD card module will look like:
http://www.amazon.com/gp/aw/d/B00JOBVQ8Q
Now my questions are:

  • The module has a 5V pin, would be actually safe, for the SD card, input that voltage in there? Or shall I use the 3.3V output of my board?
  • Is the MCU actually fully compatible with a 3.3V logic level for SPI communication? I mean, what if the MOSI pin receives 5V?
  • The pins of the module, are those labeled in pairs or just for a single one?


Thanks beforehand.

Lucario448

I've read in this page how to create the WAV file's header: http://www.topherlee.com/software/pcm-tut-wavformat.html
Now I have even more doubts (talking about the File class in the SD library):

  • I want to "preset" all this header in an array of unsigned bytes (because my only variable is the data-stream length, aka "data chunk"). Which function will put an exact copy of this array into the file? write or print?
  • The size count of the file is updated every time I write (not overwrite) a new byte into it, right?
  • The print function writes an unsigned int variable as a character string or as it is stored in memory?
  • Just in case, is there a way to convert an unsigned int type variable into an array of bytes? (in its "byte form")

Thanks again!

Grumpy_Mike

The big problem is there is a disconnect between the pictures and the words. The words say "ARM Arduino" that means a 3V3 one like the Due or the Zero. BUT the pictures show there is a restive divider on the logic lines meaning it is meant to be run with 5V signals.

Quote
The module has a 5V pin, would be actually safe, for the SD card, input that voltage in there? Or shall I use the 3.3V output of my board?
It looks like that module has an on board voltage regulator so connect the +5V and do not connect the 3V3.

Quote
Is the MCU actually fully compatible with a 3.3V logic level for SPI communication? I mean, what if the MOSI pin receives 5V?
It looks like the module has potential dividers on the pins.

Quote
The pins of the module, are those labeled in pairs or just for a single one?
Not at all sure what you mean. Why should anything be in pairs?

Quote
Which function will put an exact copy of this array into the file? write or print?
Nether. But write puts the actual byte in the file and print puts an ASCII representation of the value of the byte.

Quote
The size count of the file is updated every time I write (not overwrite) a new byte into it, right?
Don't know.

Quote
The print function writes an unsigned int variable as a character string
Yes.

Quote
is there a way to convert an unsigned int type variable into an array of bytes? (in its "byte form")
Yes
Code: [Select]

upperByte = variable >> 8;
lowerByte = variable && 0xff;




Lucario448

Not at all sure what you mean. Why should anything be in pairs?
Ok, then let me explain you better this time. If you notice, every couple of pins are labeled in an horizontal line. Take a closer look at... let's say, the MOSI label; next to it, there are two pins arranged horizontally. My question is: are those couple of pins connected together? What do you think? (I hope you have understood me this time)

PD: I don't know how to tag (post) a picture, that would be easier for you...

Quote
Nether. But write puts the actual byte in the file and print puts an ASCII representation of the value of the byte.
That's fine. I could simply write every single byte by using a for loop. But wait... is there a write function that receives an entire array of bytes? Isn't that the same thing?

Quote
Code: [Select]

upperByte = variable >> 8;
lowerByte = variable && 0xff;

There are some things that I'm worried about.

  • Will that pair of lines just extract two bytes? The int type isn't supposed to have 4 bytes? (aka 32 bits).
  • As the page mentioned before says, I need to fill up two values of 4 bytes each one before I can finalize the file. One is the "RIFF" chunk's length (file size minus 8), and the other one is the "data" chunk's length (file size minus 44). So I need to write down those values byte to byte.
  • I need it in the "little-endian" order (least significant byte first, most significant byte last; in the other way around it is called "big-endian").


I'm asking you all this because I think there is no function in the File class that writes any type of variable as a bunch of bytes (not in a character string form)

Grumpy_Mike

Quote
My question is: are those couple of pins connected together?
No look at the back, one row are connected to ground. This is normal practice.

Quote
is there a write function that receives an entire array of bytes?
Not that I know of.

Quote
Will that pair of lines just extract two bytes?
Yes.

Quote
The int type isn't supposed to have 4 bytes?
Correct the int type doesn't have four bytes it has two on an Arduino.


Quote
I need it in the "little-endian" order
So? I don't see the problem, just write it like that.


Lucario448

No look at the back, one row are connected to ground. This is normal practice.
If that is true, then this module will be nearly impossible to place in a "protoboard".

Quote
Correct the int type doesn't have four bytes it has two on an Arduino.
All right then. Let me see if I'm correct:

  • The byte type has... well, one byte... duh.
  • The short type has ? (unknown amount?) bytes.
  • The int type has two bytes, as you told me.
  • The long type has... 8 bytes I guess?
  • The float type has... 4 bytes?
  • I guess the double type doesn't exist in the Arduino IDE right?


So what can I do? I need an unsigned integer of 4 bytes. :/

Grumpy_Mike

Long int has four bytes, a long long has eight.

Lucario448

Long int has four bytes, a long long has eight.
So, what's the keyword? (on the Arduino IDE of course)
"int" or "long int"?


Lucario448

All right, so the unsigned long type is what I need. I don't think a 8 KHz sampling rate can be disrupted by long-type variable operations.
Now the thing is: how to extract every single byte from that variable, and in what order they will be extracted? I'll take care of the "byte order" part...

Go Up