Practical recording to SD card: channel count limits?

Status
Not open for further replies.

blahfoo

Active member
Hi all. A search of the forum didn't turn up a clear answer to this:
How many 44.1kHz 16b audio channels can one Teensy simultaneously record to SD card, *without dropouts*?

Working on donating to an art project and need to record OR play back 6 channels simultaneously. (Not both simultaneously.) And, need at least 1 GB of audio files. Of course, there's not enough time to make it a large software project, so I am asking What's fairly easy?

It also boils down to: how many Teensy's and audio boards are needed? 6, 3, or 1? I could synchronize multiple recorders, if it's a major software project to pack it into one device.

Paul's CS42448 Audio board (6 Inputs, 8 Outputs) looks like it has been tested and is supported enough for working from internal memory (YAY!), but from SD?
Failing that, three or six standard audio shields and three or six Teensy 3.2's, with SD cards on the audio boards?

The main problem is that SD cards write slowly and also in large blocks. Much buffering required and probably a queue of R/W commands? Hopefully the needed libraries are written for my lazy butt?
Another problem, in one post the CS42448 board's I/O appeared to be incompatible with the T3.6's built-in SD card interface, or was that just a temporary software configuration hurtle?

Assumptions:
Using the best Teensy flavor for the job: such as T3.5 or 3.6 for the SD card built-in and more buffer RAM, faster CPU.
Using the best flash cards available for this task
Using a Windows writable file format on the SD card(s)
Don't need processing except for variable gain control.

Related question: is there a standard audio file format supported by the Teensyduino world that can handle 6 channels, or would I need to open 3 or 6 files simultaneously and write to them "simultaneously" with a queue?

Resources found looking for the answers:
- https://forum.pjrc.com/threads/49232-6-inputs-audio-recorder-with-CS42448-audio-card-from-OSH-Park
- This project: https://github.com/WMXZ-EU/microSoundRecorder
- SdFat https://forum.pjrc.com/threads/36737-Try-SdFat-forTeensy-3-5-3-6
- https://www.sdcard.org/downloads/formatter_4/
- Audacity

Thanks for all the hard/great work you do,
-Philip
 
Actually, and AFAIK, the library supports writing 2-channel audio to SD. But I guess, this can easily be extended if the recording can be saved in the raw audio format, keeping all channels in one file. Just interleave data from 5 or 6 queues instead of 2. This will be much quicker than writing distinct files.
 
Thanks for the suggestion. The next question about that is, is a 5-channel RAW format understood by Audacity or some other free/cheap sound editor.
 
Audacity should handle it. In case it handled only pair numbers of channels, it would be easy tu stuff a 6th channel with 0 values.
 
OK, tried it, Audacity can do that! One detail is that you have to select Use Custom Mix in import/export preferences or it will mix down to stereo when exporting to multichannel RAW.
Thanks.
Now to answer the other questions (reliable raw write rate to SD on Teensy? Paul's Oshpark CS42448 board doesn't interfere with SD card comms?)
 
Hi all. A search of the forum didn't turn up a clear answer to this:
How many 44.1kHz 16b audio channels can one Teensy simultaneously record to SD card, *without dropouts*?

Assuming T3.6 and possibly some mods to audio SW you should be able to sustain 1.5 MByte/s (filling up a 200kByte buffer in 150 ms)
with your acquisition rate of 88.2 kByte/s you should be able to archive 17 channels.
This assumes using 200kB for audio queues and max latency of 150 ms in SD card. (you said WITHOUT dropouts, that is NO dropout until disk is full)
If you have a good card the sustained data rate may me higher, abs obviously, if you using less buffer, the sustained data rate may be lower.
 
Can do 17 Ch's !

Aah, so that sounds like you've written to SD on a T3.6, thanks. I'll take that for gospel until I learn otherwise, and I like the margin for error: about 3:1 bandwidth.
I'll have to assume the SD card library and the audio library play well together interrupt/real-time wise, and that the hardware has no conflicts.
I think I've done enough diligence here to ask Paul about that before building an experiment :)

Thanks again.

Assuming T3.6 and possibly some mods to audio SW you should be able to sustain 1.5 MByte/s (filling up a 200kByte buffer in 150 ms)
with your acquisition rate of 88.2 kByte/s you should be able to archive 17 channels.
This assumes using 200kB for audio queues and max latency of 150 ms in SD card. (you said WITHOUT dropouts, that is NO dropout until disk is full)
If you have a good card the sustained data rate may me higher, abs obviously, if you using less buffer, the sustained data rate may be lower.
 
Now to answer the other questions (reliable raw write rate to SD on Teensy? Paul's Oshpark CS42448 board doesn't interfere with SD card comms?)

Hardware-wise, the SD socket on Teensy 3.6 is completely separate from the audio input & output, using either I2S or TDM protocol. That socket connects to the processor using 6 dedicated signals which are not shared by anything else. This is only true of the built-in socket on 3.5 and 3.6. You can also connect a SD card to the SPI pins, which are shared with lots of other stuff. You can also use the SPI independently, if you select the proper alternate pins. But SPI (4 signals) is slower than the native SD protocol (6 signals), so I do not recommend attempting to use a SD card connected by SPI for this sort of project.

Not all SD cards are created equal. Many claim high performance, and may actually meet those claims when used in certain cameras. But when used in anything else, there is a huge difference in performance. Genuine Sandisk Ultra usually performs well, but beware the market is filled with counterfeits claiming to be Sandisk. Buyer beware...

Software-wise, whether the Arduino SD library is up to this task can be questionable. It very likely can be done with the higher performance but more complex SdFat library. The key to achieving better performance is using the special multi-sector read & write comments. The Arduino SD library is designed around a single 512 byte sector buffer.
 
I echo the chorus of experience that the performance of different SD cards is wildly different.

With the right card, I've done stereo recordings at 96 kHz at 16-bit for decently long (10s of minutes) recordings without hiccups. So, that'd be the equivalent of 4.3 channels at 44.1 kHz. This was using the guts from the SD library from Greiman: https://github.com/greiman/SdFat

I've never tried more than two channels, so I can't speak to going even faster. 17 channels would be pretty awesome to see, but it would take carefully written software to pump that much data while avoiding or accommodating the random delays imposed by the SD card itself.

I'd love to see you share your success!

Chip
 
Status
Not open for further replies.
Back
Top