3

I'm coding a music sampler device: for fast playback / minimal latency (only a few milliseconds), it's better to have all audio .wav samples we want to use in RAM, so that when some of them are played, the data arrays are immediately accessible. That's what I did for a Raspberry Pi project called SamplerBox. It was possible because RPi had 1 GB RAM.

Note: When using SDcard reading, and playing many notes at the same time (imagine a pianist playing a big chord), it's usually not good in terms of latency.

Now I'm thinking about porting this project to Arduino: in which extent can we add external RAM to an ATmega? Or if not "RAM", some volatile memory (let's call it "RAM2") that would be 10 times faster than reading an SD card.

What I'd like to achieve:

  • load 200 MB of audio samples into the "RAM2"

  • Max polyphony allowed = 100, so at a given time, all audio buffers that have to be mixed can be copied from "RAM2" to the "real" RAM of the microcontroller, and the mixing will be done with the (maximum 100 of them) buffers in the real RAM

1
  • I would think you'd want 100 Arduinos, each playing one sound indendently, each with it's on SRAM buffer that was very quickly played back via SPI bus and DAC, and then mix all the outputs in analog domain (vs digital). Latency from trigger to DAC output will be next to nothing. Could load each from an SD card before playing - have one 'controller' to read the SD card and send the file to each arduino to store in its locally controlled SRAM.
    – CrossRoads
    Oct 2, 2019 at 14:27

2 Answers 2

5

There are SRAM ICs / boards, however, don't expect 100 MB, more like 1 MB (with the pin numbers and connectivity / protocols that an Arduino offers).

With Flash you can get much further, but it can only be written a number of times; not sure if that suits your requirements.

Beyond that, I'm afraid the real problem is in the processing speed. Mixing 100 samples with 48 KHz stero would mean (48000 * 2) = 96 KSamples/s. Since the Arduino is only 16 MHz you have just 16e6/96e3 = 166 clock cycles to mix all those 100 samples. Probably way too less.

Update

Winbond is a brand that is supported by Arduino libraries and the biggest supported IC is e.g. W25Q128FVSSIG, which is 128 Mbit, thus 8 MB. For 200 MB you need 25 of them which is quite a lot, and not sure if there will be issues using so many (let alone the cost). For this you do not need a file system, however you need to write it per page (if you want to do it efficiently). Which should be ok, since the SD card also is read per page (maybe not the same page size though). However, you still have to copy the Flash memory into SRAM to be able to process it, so it's not the same as SRAM. Getting 200 MB SRAM will be very costly.

2
  • Thank you for your answer. Can we add a 200MB flash to an arduino? Can we use it as a RAM (just load arrays from a SD card to a memory buffer) or do we have to use a filesystem like a disk (then it's not really useful for audio buffers)
    – Basj
    Oct 2, 2019 at 10:14
  • 1
    @Basj I updated my answer with your additional questions. Oct 2, 2019 at 10:57
1

I'd also suggest looking into different microprocessors. The Teensy models often have an SD card socket, and the Teensy 4 (especially if they release one with a built-in SD socket) is extremely fast and capable (600MHZ, dual instructions/cycle). That would be far better suited than an Arduino, though you'll still have RAM limits. (Nowhere near 200 megs, but you'd have slightly less of an issue than with the Arduino's mere 2-8K of RAM. These have a few hundred K up to maybe a couple MB (note that I'm not sure if it actually goes that high))

There's also the RPI Zero, Zero W, and Compute Module to try using. Those are the Raspberry Pi system you are used to using at a low-ish cost or easily-integrated form factor.

In short, to do audio processing, you also need a better processor than a stock Arduino probably has. Lots of RAM is the easy-to-see issue, but having the computing power to do something with it is also important.

Do note that the Winbond chips mentioned in the other answer ARE a flash memory, so they may go bad on you if they see a lot of writes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.