2

I am an Arduino beginner and I am planning to make a musical instrument with it. I want to add record and playback functionalities into the instrument.

I figure I will have to store lots of data to meet this feature, but the Arduino I'm using (Uno/Nano) probably won't have enough memory to hold lots of songs.

My question is, is using an SD card with an SD shield a good way to expand memory? If not, what should I use to do so?

Thanks

  • 1
    As a beginner this MIGHT be a bit of a big thing to take on. Not that you shouldn't do it, just be aware that trying to write the code that will read and process data from SD is not trivial. Also don't think of this as EXPANDING the memory of the arduino, as the memory you are adding cannot be used for your program. – Chad G Mar 14 '18 at 22:57
  • they make hardware audio modules, for example with mp3 playback from sdcards or bluetooth, and that would be mounds eaiser than implementing it all yourself using low-lever hardware and from-scratch software. Checkout adafruit et al.'s offerings in that area before you spend week re-inventing a wheel. – dandavis Mar 15 '18 at 3:28
  • By "record and playback" do you mean audio recording, or something more akin to MIDI where you just record the instructions of what notes to play when? – Majenko Mar 15 '18 at 11:00
  • @Majenko I would be recording what note/pitch is being played, and playback would just play audio based on this data – NotAMonkey24 Mar 16 '18 at 17:01
  • 1
    So like MIDI then. Sure, you can do that with SD. – Majenko Mar 16 '18 at 17:06
2

There are different options:

  • SD shield: much memory (GB's), however keep in mind that it will take time to retrieve the data from the SD card. Also you can retrieve 512 bytes every time (which also means it costs 512 precious bytes of arduino SRAM).

  • External SRAM: There are external SRAM ICs, like 23LC1024 or 24K256. These are much faster and offer 128 or 32 KB. There are many others too, these are most 'common'. These are much faster than SD cards, you can get 1, 2 or more bytes per time. But it's not the same as Arduino SRAM, e.g. you cannot really store variables, so you have to copy data to internal SRAM to be used.

So first, check how much you need, and more important: what is the latency you can live with.

  • 2
    SRAM is probably not going to get the OP very far when it comes to audio, although it could be used as a buffer between "disk" and the arduino to improve latency issues. – Chad G Mar 14 '18 at 22:59
  • True, I now read playback and record. – Michel Keijzers Mar 14 '18 at 23:03
  • 1
    ESP32 modules have more RAM and 4mb of flash for less money than those ICs ;) – dandavis Mar 15 '18 at 3:32
  • For audio processing, you might better use a Raspberry PI. – Michel Keijzers Mar 15 '18 at 9:20
  • Thanks for the response! Based on your description I think an external SRAM would probably be better for the purpose. – NotAMonkey24 Mar 16 '18 at 16:55
1

Since you are working just with instructions on how to play audio, not the audio itself, you effectively have very small amounts of data (comparatively).

You can store that data in a file on SD card and read it back simply enough (there's plenty of examples for reading from and writing to SD).

You don't need the whole song in memory all the time - you only care about the note you're playing (or recording) at any one instance in time, so you don't need lots of memory.

How you format the data is entirely up to you, but I would suggest following the MIDI standard which will allow you to work with other tools to create and edit the files as well as the Arduino. You can also then export your music simply to other applications, such as MuseScore, Finale, Sibelius, Ardour, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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