For a project I would like to do, I asked a question about whether to use SD or EEPROM (see Question
I checked how much memory I would need without any restrictions which is like 2 MB (or more) so a SD card seems the best solution.
However, I'm a bit worried about the speed. In one of the answer comments is mentioned that 20 ms is an eternity for a microcontroller. However, I might need to do the following within 20 ms:
- Parse a MIDI event (CPU power only, does not take long)
- Read one or two SD pages (1/2 times block of 512 bytes)
- Change/add/remove the MIDI event (CPU power only, negligible)
- Send out MIDI data (barely no time, mostly hardware)
In worst case I can get like 10-20 MIDI events I need to handle within 20 ms. Especially for step 2 I don't know how much time it will. My plan is to create a big file with a PC program to be stored on the SD card. Than I can let the Arduino read pages of 512 bytes from predefined places (with seek in a file).
I'm intending to keep the file open at all times and use seeks to go to the right place and read 512 bytes every time (assuming it doesn't matter to read 1 or 512 bytes since the page size is 512 bytes anyway).
So my question: is 20 ms enough to read like 50 pages of 512 bytes from an SD card which are located on different (but known) file offsets within a 2+ MB file?
(btw, I want to try first on an Uno, but probably I will later go to a Mega (or add more SRAM to store temporary data).