Playing audio files with a speaker and arduino

Hello, I have a speaker that has only two wires, I was able to control it and playing simple tones using PWM.
That way I was able to make simple tones or even translate values to sound, but I'm interested in playing audio files with the arduino, but unlike the other projects I like to do that without the SD module.
I thought about using a library or a software that converts an audio file to tones and their frequency in Hz,
it's technically possible but I don't familiar with any of those software/libraries that I've mentioned.
So does somebody can tell me if they know this kind of software or something?
something that will convert an audio file into an array of tunes that I can easily put this array inside a void operator.

I like to do that without the SD module.

Where do plan on storing the audio?

I thought about using a library or a software that converts an audio file to tones and their frequency in Hz,
it's technically possible but I don't familiar with any of those software/libraries that I've mentioned.
So does somebody can tell me if they know this kind of software or something?

I guess you're talking about [u]FFT[/u]? FFT isn't file compression and it doesn't necessarily throw-away any data. An FFT file might actually be bigger than the normal PCM file. Then you have to do reverse FFT to play the audio, and that takes quite a bit of processing power.

Or, maybe you're thinking about [u]MIDI[/u]. MIDI files are very small because they essentially contain just the notes & timing. Again, it takes quite a fair amount of processing power to generate the instrument sounds (if you want realistic sounds).

something that will convert an audio file into an array of tunes that I can easily put this array inside a void operator.

What does array of tunes mean? Does it mean array of notes? I have no idea what "this array inside void operator" means.

There is a simple Arduino Nokia RTTTL ring tone player. But I do not think an MP3 or WAV file can be automatically converted. But there are lots of ringtones on the Internet.

DVDdoug:
Where do plan on storing the audio?
I guess you're talking about [u]FFT[/u]? FFT isn't file compression and it doesn't necessarily throw-away any data. An FFT file might actually be bigger than the normal PCM file. Then you have to do reverse FFT to play the audio, and that takes quite a bit of processing power.

Or, maybe you're thinking about [u]MIDI[/u]. MIDI files are very small because they essentially contain just the notes & timing. Again, it takes quite a fair amount of processing power to generate the instrument sounds (if you want realistic sounds).

gdsports:
What does array of tunes mean? Does it mean array of notes? I have no idea what "this array inside void operator" means.

There is a simple Arduino Nokia RTTTL ring tone player. But I do not think an MP3 or WAV file can be automatically converted. But there are lots of ringtones on the Internet.

Yes, I mean an array of notes and that's how I'm going to save the data of the audio file.
And I don't mean either to MIDI or FTT, what I'm trying to do is to convert any audio file to every single and individual note and then save this as the arduino note library syntax, for example,
a certain audio file will be converted to:

#include "pitches.h"

// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 8, 8, 4, 4, 4, 4, 4
};
//Example taken from: https://www.arduino.cc/en/Tutorial/ToneMelody?from=Tutorial.Tone

I know it's possible it's just a bit complicated and clumsy.

And I don't mean either to MIDI or FTT, what I'm trying to do is to convert any audio file to every single and individual note and then save this as the arduino note library syntax,

No... There is software that converts audio to MIDI, or tries to... It's not easy, especially with "real music" that has chords, polyphonic music, multiple instruments, vocals, etc. If you can find software that does that reliably, then, you can use MIDI software to read the notes. Then, you'd have to make the note-arrays "by hand".

Overall, it's probably easier to look-up the sheet music or to "plunk-out" the notes on a piano/keyboard.

I have a speaker that has only two wires,

BTW - You can drive a piezo transducer but you can't (or shouldn't) directly connect a 4-Ohm or 8-Ohm speaker. The minimum load is 125 Ohms for the absolute maximum current of 40mA. With anything lower you'll draw excess current, overheat your Arduino, and possibly damage it. If you want to drive a speaker, you need an amplifier or "powered" speakers.

RTTTL encodes notes and note durations as printable ASCII strings. Here is an example.

HauntHouse: d=4,o=5,b=108: 2a4, 2e, 2d#, 2b4, 2a4, 2c, 2d, 2a#4, 2e., e, 1f4, 1a4, 1d#, 2e., d, 2c., b4, 1a4, 1p, 2a4, 2e, 2d#, 2b4, 2a4, 2c, 2d, 2a#4, 2e., e, 1f4, 1a4, 1d#, 2e., d, 2c., b4, 1a4

Instead of arrays of binary notes and durations, RTTTL encodes the same information as ASCII chars. RTTTL can be stored in const char arrays.

The following library plays RTTTL strings using the Tone library for output. I have not tried it but I would if I had more time.