Go Down

Topic: Voice recorder. (Read 13702 times) previous topic - next topic

AdrianusKundert

I would like to make a recording and playback system.(voice recorder) It should start recording by the sound-signal and record for 3 minutes beginning and ending with a bleep. Its also necessary to have a switch so you can listen back for at least half an hour.
I have been searching quite while how to make this but I get a bit lost in the information and don't know where to start or where to find a similar example. So what components do I need and does someone have some recommendations?

Mijn dank is groot.
AK



Grumpy_Mike

This is because what you ask is impossible on the normal Arduinos. it only 2K of memory you have about enough memory to record about a quarter of a second.

However if you get the new Due this will allow you to record sound but 3 minutes is out of the question again due to lack of memory. Have you worked out how much you need for that?

robtillaart


consider a wave shield like here - http://learn.adafruit.com/wave-shield-voice-changer -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Frédéric_Plante

Mike, of coarse like most you forget how easy it is to integrate a SDcard to the Arduino. Could people like you stop saying that all complicated task are imposible cause of lack of memory.

As we fight our way northward into the great unknown, only that one thing remains certain...

Grumpy_Mike


Mike, of coarse like most you forget how easy it is to integrate a SDcard to the Arduino. Could people like you stop saying that all complicated task are imposible cause of lack of memory.

So you dig up a post that is over nine months old to tell me off?

But it is you that is wrong.

Yes you can integrate a an SD card easily. But can you record 3 minutes of audio on it?
The SD card will require writing to, it can not sustain writing at audio rates and needs buffering. There is a lack of fast access memory to do that buffering.
So let's see what your solution is. I would be interested in seeing your code, unless of course you don't know what you are talking about. In which case an apology is in order.

Frédéric_Plante

#5
Jun 16, 2013, 06:14 am Last Edit: Jun 16, 2013, 11:52 pm by Frederic_Plante Reason: 1
Let's do some simple math(Corigé)

Let's say you record at 8bit mono at a frequency of 16 kiloHz. Cause 16 kiloHz, unless you a bat, is a normal hearing/speaking maximum(high pitch)

Well that mean that every second you need 8 bit × 16 kiloHz = 128 kilobitHz AND 128 kilobitHz × (1/1Sec) ÷ 1Hz = 128 kilobit/Sec or if you prefer 16 kilobyte/Sec.

On a Uno you have 32 kilobyte of flash(could do stéreo after all), and according to here: http://en.wikipedia.org/wiki/Flash_memory  A normal writing cycle for flash is 150 kilobyte/Sec, well your buffering point fall apart.

Here http://fr.wikipedia.org/wiki/Carte_SD they say that you can write at 150 kilobyte/Sec to 4 mégabyte/Sec to a SdCard, about 9,375 to 250 time faster then required.

So for a minute of recording you will need 128kilobit/Sec × 60 Sec/1 Minute  = 7,68 mégabit/Minute , so a little less than 1 mégabyte/Minute.

On a SDcard of 4 gigabyte you have 4000 mégabyte. So  4000 mégabyte ÷ 1 mégabyte/1 Minute. That mean, you have pretty much access to 4000 minutes of low quality sound or if you prefer voice recording quality. Since the point of this tread was to make a voice recorder, well...

Finally, for all i know, the Uno is running at 16 mégaHz, so we are way way above the 16 kiloHz required to sample and record, no?

To conclude, the codes already exist and the numbers talk for them self. So since i'm not a arrogant man, i'm not gonna ask for apology. :P By the way i'm into physic so math is my hobby.
As we fight our way northward into the great unknown, only that one thing remains certain...

Frédéric_Plante

#6
Jun 16, 2013, 11:37 pm Last Edit: Jun 17, 2013, 12:05 am by Frederic_Plante Reason: 1
If i may suggest some suplémentaire documentation about audio sampling:

http://en.wikipedia.org/wiki/Sampling_rate
http://en.wikipedia.org/wiki/Bit_rate#Audio

Here they suggest that 8kHz is sufficient AND 8bit/mono is over killing for voice recording. So any way's, by the end, following the math I proposed up there, you could quadruple the recording time on the SDcard, so about 16000 minutes  on a 4gigbyte SDcard. But at 4bit/mono 8kHz, I suspect that the sound might be very very crappy unless you are a baritone. ;)
As we fight our way northward into the great unknown, only that one thing remains certain...

sbright33

I have gotten it to work last year without any special audio library.  Sampling to RAM is trivial.  The only problem with my code is the skipping when it allocates another cluster on SD card.  This can be overcome with a simple to use library which pre-allocates the clusters.  What's the problem Mike?
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619


salomonsk8r2003

#9
Dec 23, 2014, 06:20 am Last Edit: Dec 29, 2014, 02:24 am by Coding Badly
So you dig up a post that is over nine months old to tell me off?

But it is you that is wrong.

Yes you can integrate a an SD card easily. But can you record 3 minutes of audio on it?
The SD card will require writing to, it can not sustain writing at audio rates and needs buffering. There is a lack of fast access memory to do that buffering.
So let's see what your solution is. I would be interested in seeing your code, unless of course you don't know what you are talking about. In which case an apology is in order.
My friend made an audio recorder AND transmitter in one device using the Uno. It transmitted the audio over a radio frequency and recorded to an SD card at the same time. Sounded pretty decent too. The SD card was taken apart and wired straight to the Arduino setup he had. He recorded 8 gigs worth of audio. I agree with the other dude... just because it seems difficult doesn't mean it's impossible. 100 years ago computers were "impossible".

Grumpy_Mike

#10
Dec 29, 2014, 12:14 am Last Edit: Dec 29, 2014, 02:48 am by Coding Badly

A helpful responce would have been a link or something.


Paul Stoffregen

Different SD cards have different write latency.  Some cards are much faster than others.

I recently wrote a continuous 44.1 kHz, 16 bit recording to SD example on Teensy 3.1.  It was necessary to queue up incoming audio while the SD card writes.

Regarding a specific link, here's that code, with lines that can be uncommented to view the actual write latency:

https://github.com/PaulStoffregen/Audio/blob/master/examples/Recorder/Recorder.ino#L151

Now, I realize most of you probably don't have a Teensy 3.1 to actually run this code.  Since I don't want Grumpy Mike to say I'm not replying with a helpful response, I ran it just now with those 2 lines uncommented.

Here's a representative chunk of the output printed to the Arduino Serial Monitor:

Code: [Select]

SD write, us=1476
SD write, us=1475
SD write, us=10692
SD write, us=7370
SD write, us=6812
SD write, us=1437
SD write, us=1427
SD write, us=1430
SD write, us=1447
SD write, us=1435
SD write, us=1457


Virtually all the writes are under 1.5 ms.  Quite often, one write takes about 7 ms, and on rare occasions, a sequence of 2 or 3 writes takes about 8 to 10 ms.  I believe the 7 ms ones correspond to writing 2 blocks, one data and the other to update the FAT table.  I do now know why some take 10 ms, but it very likely could be internal block allocation inside the SD card.

In this example, Teensy 3.1 is recording a mono, 16 bit stream at 44.1 kHz sample rate.  In this example, Teensy 3.1 has a pool of 60 buffers, each capable of storing 128 samples, which is about 174 ms of audio.... much more than necessary to deal with the 10 ms latency, or groups of 2-3 such writes.

Arduino Uno might have slightly higher latency, since the SD library would use a slower SPI clock.  But let's neglect that, and assume buffering for approx 25 ms is enough to handle the worst SD write latency.

At a slow 8000 Hz sample rate, that's only 200 samples of buffering.  That's very easily achievable on Arduino Uno.  You could allocate about 1000 byes for a buffer where an ADC interrupt would store the incoming samples (assuming they're 8 bits each - discarding the low 2 bits from the ADC).  The main program could give that data to the SD library, which has another 512 byte buffer.  It may be a squeeze to get everything else to fit into Uno's limited memory, but I'm sure it could be done.

Of course, a lower-level approach that wrote directly to the RAW sectors on the SD card could have the ADC interrupt put the incoming bytes into either of two 512 byte buffers, and code could write either of those directly to the card without the FAT filesystem overhead.  Even if the card stalls for 25 ms to complete a write, you'd be less than half full on the other buffer (ADC interrupt filling it while the main program waits on the SD card) and be ready to write it when full.  Or you could expand to 3 such buffers, still within Arduino Uno's limited RAM, which might be necessary with lower quality SD cards.  But if you use a good quality card (I tested a SanDisk Ultra), so much buffering should not be needed at only 8000 Hz sample rate.


Paul Stoffregen

I just tested 2 more SD cards.

Here's write speeds from a generic SanDisk 8GB (not "Ultra" - might be a counterfeit):

Code: [Select]

SD write, us=1435
SD write, us=4199
SD write, us=1516
SD write, us=1423
SD write, us=1451
SD write, us=1427
SD write, us=1461
SD write, us=1433


It seems to perform very well, with only occasional 4.2 ms latency.


Here's measurements from a Transcend 128 MB card:

Code: [Select]

SD write, us=5284
SD write, us=7102
SD write, us=10068
SD write, us=4811
SD write, us=5911
SD write, us=8421
SD write, us=8177
SD write, us=6035


This card is really terrible.  In fact, the average time to write 512 byes is close to 5.8 ms, so this card is marginal for recording 44.1 kHz, 16 bit audio.

But at only 8000 Hz with 8 bits, the latency is still well under 25 ms.

Grumpy_Mike

Thanks Paul. A lot has changed since 2012 the date of the original question.

Go Up