Audio Library Latency from SD Card

Status
Not open for further replies.
Hi, folks!

My goal is to use the Teensy 3.1 and SD adapter to loop a single raw file, and inject random raws on top of that under certain circumstances. From what I can see, the Audio Library does that just fine. My concern is with the latency in loading the secondary audio files. What's the typical delay between issuing the play command and actually hearing the audio?

Some things I've considered:
  • Audio adapter with the W25Q128FV memory addition, but the board is slightly too large (!!) for my application.
  • wav2sketch conversion, but I'm aiming to use 10-20 files, so it doesn't fit within the Teensy's memory.

The secondary question is attaching an amp to the Teensy. I'm assuming I can connect the DAC pin to something like Adafruit's 2.5W amp...but I haven't done my homework on this part, yet.

Thanks!
Nate
 
What's the typical delay between issuing the play command and actually hearing the audio?

it somewhat depends. a few ms from SD/FAT and a few ms from the audio engine. this thread has some pointers. generally speaking, latency is quite a bit better with spi flash.
 
Excellent link, thanks! An initial skimmed it look promising.

I'm considering flash, but it might be "too difficult" for the end result of the project (non-teensy user loading audio files). A hybrid might work, though. I assume it's possible to have the teensy copy files from the SD to flash during setup?
 
yep, take a look at the CopyFromSD example, it's basically doing that. the end user doesn't have to know really, except it'll take a while.
 
The SPI flash chips have lower latency. But unless there's some very special need for precise timing (like special waveform cancellation techniques), either way should have lower latency that humans can perceive. If it's just a matter of whether humans can perceive the delays, I'd recommend going with whatever approach is simplest.

If using a SD card, don't forget to run the benchmark, in File > Examples > Audio > HardwareTesting > SdCardTest. Do this first, so you can know if your card is fast enough when used with the (limited) Arduino SD library.

If you don't need to ever write to the card, and you're ok with trying experimental code, you can edit SD_t3.h to turn on the experimental optimizations.
 
Thanks, Paul!

This stuff is amazing...I'm surprised at how easy it is to get up and running. The SD Card was unexpectedly fast (I bought a cheapo off-brand from Target, and even opening 4 files, I was seeing less than 10ms latency).

Now, for playing WAVs through the DAC, I assume an amp is needed... Will a simple class D work? (like the adafruit one I linked above)
 
Yeah, almost any amp that takes a standard line-level signal should work fine.

That Adafruit one has 24 dB gain, which is a bit high. By default, Teensy's DAC output is 1.2V peak-to-peak with a full scale signal. You might have to turn the volume adjustment down quite a bit, but it should work.
 
If you don't need to ever write to the card, and you're ok with trying experimental code, you can edit SD_t3.h to turn on the experimental optimizations.

I wanted to check out the optimized version and downloaded from your github but I need to record audio files as well. Does this mean you do not have writing ability if optimized is enabled?
 
Does this mean you do not have writing ability if optimized is enabled?

Correct, there's absolutely no writing to the SD card with the optimizations compiled.

You don't get to have your cake and eat it too. Well, at least not until I do a *LOT* more work on the SD library. Someday.....
 
Status
Not open for further replies.
Back
Top