Tone lookup table on SD card

Is there a way to add a library on an SD card like the pitches.h file in the tone demo? I would like to make an extensive library/lookup table in a text document.

Hardware: Arduino Uno with SD card module. I ran demo files of SD library fine. Piezo speaker: Pin 8

5V 16mhz Uno, Tone can go up to what freq?

The pitches.h file needs to be compiled in with the sketch. That can not happen when the file is on the SD card of the Arduino, since compiling and linking doesn't happen on the Arduino.

You could put the notes and duration information in a file on the SD card, and then read that at run-time. There will be periodic pauses while data is fetched from the card that may be an issue.

PROGMEM might be a better option.

PaulS: The pitches.h file needs to be compiled in with the sketch. That can not happen when the file is on the SD card of the Arduino, since compiling and linking doesn't happen on the Arduino.

You could put the notes and duration information in a file on the SD card, and then read that at run-time. There will be periodic pauses while data is fetched from the card that may be an issue.

PROGMEM might be a better option.

I knew that on the pitches.h Once its in Flash, you cant edit it. PROGMEM is a great idea that stores everything in flash but I feel like I may be limited on data space. So I may have to stick with storing on SD card and then reading the information. If its simpler I can have multiple text files that have different information on it to lower my seek time in the text document? Any ideas would be great.

If its simpler I can have multiple text files that have different information on it to lower my seek time in the text document? Any ideas would be great.

The delay will be caused by reading a 512 byte block of data from the file. Same file as last time or a different file won't make a bit of difference.

PaulS:

If its simpler I can have multiple text files that have different information on it to lower my seek time in the text document? Any ideas would be great.

The delay will be caused by reading a 512 byte block of data from the file. Same file as last time or a different file won't make a bit of difference.

Regardless of the delay, Is there a way to do what I need using an SD card? If so, what is the best way to go about it

Regardless of the delay, Is there a way to do what I need using an SD card?

It isn't all that clear what you need to do. You mentioned pitches.h, which is not a candidate for storing on the SD card.

The notes and durations would be, but you haven't said that that is what you want to store there.

PaulS:

Regardless of the delay, Is there a way to do what I need using an SD card?

It isn't all that clear what you need to do. You mentioned pitches.h, which is not a candidate for storing on the SD card.

The notes and durations would be, but you haven't said that that is what you want to store there.

I will be storing Frequency data.

An example would be something like this: Category1 34000

The problem is if you put everything into one file it will be "big". Then you will open that one file and search through it for what you want. It is this searching that will be slow.

You have to think of a clever way to do this.

For example, you could break your data down into 512 (or less) blocks - multiple files. Then use IF or SWITCH logic to figure out which file you want, and read it in quickly.

That might lead to a lot of lines of logic in your program. Maybe more memory used by that than just storing the data in memory.

How about putting each value in its own file? This would result in a lot of files, but that will not affect speed.

This would also make your program logic easier, since the value you want becomes the file's name. You can even read-in the directory of file names and do some searching through that looking for the closest match.