Voice recorder.

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

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?

consider a wave shield like here - Overview | Wave Shield Voice Changer | Adafruit Learning System -

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.

Frederic_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.

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.

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: Flash memory - Wikipedia A normal writing cycle for flash is 150 kilobyte/Sec, well your buffering point fall apart.

Here Carte SD — Wikipédia 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. :stuck_out_tongue: By the way i'm into physic so math is my hobby.

If i may suggest some suplémentaire documentation about audio sampling:

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. :wink:

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?

Try this http://m.instructables.com/id/Arduino-Audio-Input/?ALLSTEPS

Grumpy_Mike:
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".

A helpful responce would have been a link or something.

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:

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:

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.

I just tested 2 more SD cards.

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

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:

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.

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