How to convert audio to Tone sound format ?

Hello i want to make some sounds for my Super Mario Bros game but all i can find on the web is the main tune and underground tune, while they both sound great i still need all the other sounds, like end of level, power up, tunnel noise ect...

I would like to think that there is a tool that converts audio to tone format but i have not found such ?
How are people making these Tone tunes, surly they are not just testing note by notes and delay by delay, that would takes ages?!?

Does anyone know how i can go about making some sound effects for Mario please, without using wav files which are massive?

I have no idea what the "tone format" is. Is that something like MIDI? You may need to do some more search or try some game-programming/game-customizing sites.

The basic Arduino doesn't have a DAC. Analog audio can be "simulated" with [u]TMRpcm[/u] but if you need to mix sounds (multiple sounds at once) or generate/synthesize music you'll need a more powerful processor and you'll want a DAC (and maybe a stereo DAC?).

Does anyone know how i can go about making some sound effects for Mario please, without using wav files which are massive?

There are other audio formats. High-quality MP3 & AAC (and other lossy compression formats) are about 1/5th the size of a "CD quality" WAV. Often you can get-away with more compression (lower bitrate = smaller files).

There are shields (add-on boards) for the Arduino that can play these compressed formats (or WAVs) but the basic shields play only one file at a time. The shield has a slot for an SDcard, a DAC, a sample rate clock, and a chip to do all of the work. The Arduino is just a controller, and in come cases you don't even need the Arduino.

MIDI files are much smaller because they are just "notes & timing" plus a little more information. Typically, the music is played on a MIDI keyboard and "captured" to the computer. Or it can be programmed (composed) note-by-note (or edited note-by-note after capture).

MIDI-to-Audio is done all the time. But it's not a job for the Arduino. You need a real computer, a MIDI instrument/keyboard, or a synthesizer chip.

Audio-to-MIDI is very difficult and not so common. There are a few PC & Mac applications that can do it. It's easier if the audio is a solo instrument playing one note at a time. Chords are more difficult and converting an entire band to MIDI is super complicated and although there are programs that can do it (or claim to do it) it will usually require some manual editing/correction (if it works at all).

I am using an ESP32 at 240Mhz clock speed and it has 2 DAC's and loads of memory '1310720 bytes', i have tried other formats but every one is very large in comparison to a simple tone example, which to be honest i do not know what the format is called, example below.

int melody[] = {
  NOTE_E7, NOTE_E7, 0, NOTE_E7,
  0, NOTE_C7, NOTE_E7, 0,
  NOTE_G7, 0, 0,  0,
  NOTE_G6, 0, 0, 0,

  NOTE_C7, 0, 0, NOTE_G6,
  0, 0, NOTE_E6, 0,
  0, NOTE_A6, 0, NOTE_B6,
  0, NOTE_AS6, NOTE_A6, 0,

  NOTE_G6, NOTE_E7, NOTE_G7,
  NOTE_A7, 0, NOTE_F7, NOTE_G7,
  0, NOTE_E7, 0, NOTE_C7,
  NOTE_D7, NOTE_B6, 0, 0,

  NOTE_C7, 0, 0, NOTE_G6,
  0, 0, NOTE_E6, 0,
  0, NOTE_A6, 0, NOTE_B6,
  0, NOTE_AS6, NOTE_A6, 0,

  NOTE_G6, NOTE_E7, NOTE_G7,
  NOTE_A7, 0, NOTE_F7, NOTE_G7,
  0, NOTE_E7, 0, NOTE_C7,
  NOTE_D7, NOTE_B6, 0, 0
};
//Mario main them tempo
int tempo[] = {
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,

  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,

  9, 9, 9,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,

  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,

  9, 9, 9,
  12, 12, 12, 12,
  12, 12, 12, 12,
  12, 12, 12, 12,
};

Otherwise I am using audacity and converting a WAV file down to Mono and from 44Khz to 8Khz sample rate, but still a 38 second long tune takes up 307,394 bytes :o which is like a quarter of my memory, and i want to keep it all contained in the ESP32. Maybe i am asking for to much but i was just hoping for a way to make the file even smaller. An yes it can play overlapping sounds which is a pro compared to Tone.

The tone() function isn't a "format." It just generates a square wave at one frequency and one volume. And, I guess you know what that sounds like... Probably not what you want. It's very compact because all you need is the note (frequency) and duration. If you use an array you can "address" the note with one byte and the duration with one byte.

Or, if you look at your example where notes (or patterns) are repeated you can use loops, or sometimes you can otherwise "generate" the tune with an algorithm so you don't actually have to store the whole song in memory.

i have tried other formats but every one is very large in comparison

CD audio (the same underlying uncompressed PCM format as WAV files) is 2-channels (stereo), 16-bits, and 44,100 samples per second. That's 176,400 bytes for each second of sound (or a bitrate of 1411kbps. kbps is kilobits-per-second, so that's 8 times the bytes-per-second. MP3 file vary depending on the amount of compression, but music MP3s are usually 128 or 256 kbps.

I would like to think that there is a tool that converts audio to tone format but i have not found such ?

I would like to think that someone is going to give me a very large amount of money but I have not found anyone that will.

Wishful thinking is silly.

How are people making these Tone tunes, surly they are not just testing note by notes and delay by delay, that would takes ages

No they don't test notes, they get the sheet music and look up what sequence of tones they need to use. Yes it does take time.

The ideal would be to convert audio into MIDI. MIDI is a list of notes you can then convert to Tone numbers.

However look up:-
audio to MIDI
for lots of high end software that has the feature. Also note how it dosn't "quite" work. Read the comments on any video you might come across, there are a lot of snake oil salesmen out there.

Is this what you're looking for? Welcome mariopiano.com - Justhost.com

You web searching can't have been very thorough I found this immediately.

Yes i have came across that site, my search has highlighted further sounds for Mario this week, I now have every sound except the jump noise, and that site to does not have the jump sounds. I have now finished the first level of Super Mario bros and i was just about to ask if anyone has the jump sound working with tone but i shall wait a few days to see if anyone here reply's with the Mario jump sound in MIDI - Tone format, though i see that MIDI is not exactly that same as what Tone uses, so i also came across this site Midi To Arduino but the timing and such are wrong. I have every sound in WAV too but they are way to large but i have attached the jump sound in .wav if anyone is able to convert it properly. :confused:

smb_jump-small.zip (20.4 KB)

1 Like

Hello everyone,

I am not sure that I have fully understood the question.
The Tone function takes a frequency and a duration as inputs.
On monophonic audio, this is related to pitch tracking, which outputs the pitch/frequency at each time step of a given audio.
If this is what you want to do and if you can do it offline, you could use Python and the librosa package.
It is really simple. You just need to

  1. install Python! and librosa,
  2. make a Python script that reads the file and that does pitch tracking using the function "piptrack" (https://librosa.github.io/librosa/generated/librosa.core.piptrack.html#librosa.core.piptrack),
  3. save the results
    If you have some basic knowledge in Python, this will be fairly simple.
    I hope this answer can help.

The main problem here is that a sound is simply not a succession of fixed frequency tones. A lot of the information in that sound the OP posted is also in the amplitude. When you plot this sound you get this waveform:-

You can see that as the sound progresses the amplitude also drops off. This will lead to a fading down as the sound progresses and this is what also affects the timbre ( or sound of the sound ) that gives it its recognisability.