Playing audio files on arduino nano without additional external memory

I'm wanting to upload a v short piece of music, to an arduino nano, and then play it repeatedly.

The file length only needs to be 10ms, how do I do this? I'm unsure what format to put it in, where to put it in the code and also the size limits (Is it 2kb (RAM size) or 32kb (EEPROM) size that will decide how big a file I can put in?

I don't know how/where to put the code and how to get it to play. I found lots of information on running it off SD cards or other external memory, but these aren't an option at the moment as I am limited to what I currently have (currently - an arduino nano, a load of resistors, diodes and that's about it) I'm just wiring the speaker directly between pin4 and ground but could do more wiring if that's required.

I'm quite happy to reduce the sample rate of the file down to get it small enough to fit the 2kb or 32kb size - but I have no idea what to to/where to paste the code/even where to get the code from a .wav or .mp3 or whatever filetype.

Thanks very much

Put the file on an SD card and use an MP3 module to play it back.

10milliSeconds - that's not a very long sample.
Say you committed 200 bytes of memory for 8-bit sound.
Played back at 10,000 Hz rate (one byte every 100uS), would last 20mS.
Will that short of a period sound like much more than a tick or click or similar?

You could store a longer sample in flash memory (32K less the length of your sketch) and write the data direct to a port (D0 to D7 on an Uno, lose serial capability while doing so), with your resistors making an R2R ladder output for a DAC type output.
Using an opamp/buffer to drive the speaker would be needed to prevent the speaker from loading down the output.

fishy1:
I'm quite happy to reduce the sample rate of the file down to get it small enough to fit the 2kb or 32kb size - but I have no idea what to to/where to paste the code/even where to get the code from a .wav or .mp3 or whatever filetype.

Playing data from 8-bit PCM audio file at sample rate 8000 Hz would be possible.

EEPROM reading is too slow, but reading from PROGMEM would be possible, so the limit is at 64 KB or the available flash size of the controller, whichever is the lower value.

See: Arduino Playground - HomePage

Nano only has 32K flash.

CrossRoads:
Put the file on an SD card and use an MP3 module to play it back.
MDFLY - Search Results for "mp3"

10milliSeconds - that's not a very long sample.
Say you committed 200 bytes of memory for 8-bit sound.
Played back at 10,000 Hz rate (one byte every 100uS), would last 20mS.
Will that short of a period sound like much more than a tick or click or similar?

You could store a longer sample in flash memory (32K less the length of your sketch) and write the data direct to a port (D0 to D7 on an Uno, lose serial capability while doing so), with your resistors making an R2R ladder output for a DAC type output.
Using an opamp/buffer to drive the speaker would be needed to prevent the speaker from loading down the output.

I know it'll sound like a continuous noise, but that's fine, I only want it to loop continuously and sound like a constant tone - I.e like someone playing the recorder on the same note, looped indefinitely.

I really want to do it without additional parts if possible. The speaker output only draws 30mA which is fine for my purposes so doesn't need additional buffers.

Any ideas/links? I've seen the code to do it with SD card but I don't want that and am not sure how/what to do with the way file.

Thanks v much

fishy1:
Any ideas/links? I've seen the code to do it with SD card but I don't want that and am not sure how/what to do with the way file.

I already posted a link in reply #2.

If you need additional assistance, send the wav file as a file attachment during "Preview" of your message, and I might try to do the conversions needed before you can put the data into your Arduino sketch.