Audio → MIDI

Audio to MIDI Converter

M4A to MIDI, FLAC to MIDI: the extension is not the codec

The short answer: the container changes nothing that survives the decode, because the extension cannot tell you what is inside it. FLAC is always lossless; an .m4a file can hold lossy AAC or lossless ALAC, and both are handed to this converter as the same plain PCM. We encoded one known-answer eight-note clip seven ways, decoded each with a real codec, and ran this site’s own detector on the samples: WAV, FLAC, ALAC-in-M4A, AAC 256 kbps and AAC 128 kbps all produced the byte-identical 125-byte .mid file (same SHA-256, same eight notes, same velocities). At 64 kbps three note boundaries moved by one 11.61 ms frame. At 32 kbps the same clip fell from eight notes to five in monophonic mode and invented six extra notes in polyphonic mode. So the honest question about M4A to MIDI and FLAC to MIDI is not “which extension” but “what codec, and at what bitrate” — and if your file is FLAC, ALAC or AAC at 128 kbps or better, you can convert it here as it is. The page runs entirely in your browser: no upload, no account, no re-encode on the way in.

1. Two files called .m4a, 9.38× apart in size

People treat M4A and FLAC as opposites: one compressed, one pristine. That is wrong at the level that matters. FLAC names one lossless codec. M4A names a container — the ISO base media format that also holds MP4 video — and the audio stream inside it is a separate choice. The two common ones are AAC-LC (lossy, perceptual) and ALAC (Apple Lossless, bit-exact). We made both, from the same audio, and read the stream tags:

scale_alac.m4a      Audio: alac, 44100 Hz, mono, s16p
scale_aac_128k.m4a  Audio: aac (LC), 44100 Hz, mono, fltp
scale.flac          Audio: flac, 44100 Hz, mono, s16

Same extension on the first two. One reconstructs every sample; the other throws information away. Here is what that costs on disk for a 2.96-second clip, and what each file decodes back to:

One 2.96 s, 44 100 Hz mono 16-bit clip, encoded seven ways. “PCM vs WAV” compares the decoded 44 100 Hz mono float samples, byte for byte.
FileCodec insideLossy?File sizeDecoded samplesPCM vs WAV
.wavPCMno261,116 B130,536baseline
.flacFLACno71,197 B130,536identical
.m4aALACno113,478 B130,536identical
.m4aAAC 256kyes57,905 B130,536differs
.m4aAAC 128kyes48,606 B130,536differs
.m4aAAC 64kyes25,304 B130,536differs
.m4aAAC 32kyes12,093 B130,536differs

The two .m4a extremes differ by 9.38× in size (113,478 B vs 12,093 B) while decoding to exactly the same sample count. Every one of them is 2.96 seconds long and 44,100 Hz when the decoder is done. If you judge a file by its last four characters, you cannot tell which of those two cases you have. FLAC, by contrast, has one meaning: the samples are exact. That is the whole reason “FLAC to MIDI” is a simpler question than “M4A to MIDI”.

2. What the converter actually reads

The page does not parse M4A, FLAC, MP3 or anything else. The file input is declared accept="audio/*" — it accepts by media type, not by extension — and the load path calls the browser’s own decodeAudioData, which returns an AudioBuffer of plain samples. From that moment the container and the codec name are gone. Only then does dsp.js see the audio:

So “M4A to MIDI” is really “the decoded PCM to MIDI”. This is the same decode path described in OGG to MIDI: what the container actually changes, and it is why a file’s own sample rate does not move the notes — we ran the same melody at 44.1k, 48k and 22.05k and got an identical note list each time.

There is one hard gate before any of that: the browser has to be able to decode the codec. If it cannot, decodeAudioData rejects the file, the converter shows no notes at all, and the failure looks like an empty result rather than a bad transcription. Which codecs a given browser ships varies by browser and operating system, so a file that opens on one machine may not open on another. That is a decode failure, not a detection difference — and it is the one case where the wrapper genuinely decides the outcome. A single conversion to WAV on your own machine settles it; mobile audio to MIDI covers the same decoder-dependent edge on phones.

3. How we measured it, so you can distrust it properly

No vendor claims and no borrowed accuracy figures. We built a known-answer source: eight harmonic-rich notes, C4 through C5, 0.35 s each with a 20 ms gap, at 44,100 Hz mono 16-bit. Three more clips were used to stress the edges — a quiet bass line buried under a loud pad, four sustained triads, and a pure 55.00 Hz sine. Each was encoded with a real encoder, decoded back to 44,100 Hz mono float PCM, and fed to this site’s own dsp.js and midi.js with identical settings (mono and polyphonic, sensitivity 60, shortest note 60 ms, 120 BPM, no quantisation). Finally we hashed both the decoded PCM and the exported files.

SHA-256 prefix of the decoded PCM for the eight-note clip. Identical hashes mean the detector literally received the same samples; different hashes mean the codec changed them.
EncodingDecoded PCM SHA-256 (first 16 hex)Equal to WAV?
WAVd5f381e31d1bd66ebaseline
FLACd5f381e31d1bd66eyes, byte-for-byte
ALAC in .m4ad5f381e31d1bd66eyes, byte-for-byte
AAC 256kd2742dbc54c623f7no
AAC 128kc9ab2e351dd638e2no
AAC 64k34ab68c03d262cc6no
AAC 32kb81b3982fe073a3eno

That pattern held on all four clips: FLAC and ALAC decoded to a bit-exact copy of the WAV every time, and every AAC bitrate produced a different hash. Note what this proves and what it does not. It proves the lossless claim with bytes rather than adjectives. It does not say the AAC versions are worse at the note level — that is a separate measurement, below.

4. Five of seven encodings produce the exact same file you download

Here is the result that matters to anyone asking about M4A to MIDI or FLAC to MIDI. We took the monophonic note list from each decoded version, wrote it out with this site’s own MIDI writer, and hashed both the .mid and the .csv:

Eight-note clip, monophonic mode, 120 BPM. Same detector settings for every row.
EncodingNotes.mid bytes.mid SHA-256 prefix.csv bytes.csv SHA-256 prefix
WAV8125b6ad235136f1bbe23290787109d97f3c40c
FLAC8125b6ad235136f1bbe23290787109d97f3c40c
ALAC in .m4a8125b6ad235136f1bbe23290787109d97f3c40c
AAC 256k8125b6ad235136f1bbe23290787109d97f3c40c
AAC 128k8125b6ad235136f1bbe23290787109d97f3c40c
AAC 64k81254d384a26416a10613299137d3de8289e4af
AAC 32k5979c5f12ecc2378867230e6bea66c06ecf33c

Five rows are the same file, byte for byte: a 125-byte Standard MIDI File with eight C-major notes and the same velocities. The AAC 256k and 128k rows never had identical PCM to the WAV, yet the note list — every pitch, every start, every end, every velocity — came out the same. The detector quantises note boundaries to an 11.61 ms frame grid and velocity to an integer derived from frame RMS, so small codec noise is absorbed before it reaches the file. At 64 kbps the same eight notes survive, but three boundaries shift by exactly one frame (for example F4 moves from 1.103 s to 1.115 s), which is enough to change the bytes. At 32 kbps the clip returns only C4, D4, D4, A4, B4 — E4, F4, G4 and C5 are gone and one D4 is duplicated.

The audio to notes page explains why the CSV and the MIDI can disagree about timing even when they come from one note list; the MIDI file size page shows why an eight-note export lands near 125 bytes rather than near the size of the audio.

5. Where lossy coding finally shows up

AAC is a perceptual codec: it spends bits where a listener is likely to notice and discards the rest, leaving coding noise spread across the spectrum. We measured the whole-signal RMS of the difference between each decoded AAC version and the WAV, then counted notes in both modes:

Eight-note clip. Error is 10·log10 of the squared difference over the squared original. “Exact” means the note list matched the WAV baseline character for character.
EncodingError vs WAVMono notesMono resultPoly notesPoly result
FLAC / ALAC0 (bit-exact)8exact8exact
AAC 256k−47.49 dB8exact8exact
AAC 128k−31.60 dB8exact8one onset +1 frame
AAC 64k−31.61 dB83 boundaries ±1 frame8one onset +1 frame
AAC 32k−10.35 dB53 notes lost, 1 duplicated146 ghost notes added

The last row is the useful warning. A badly encoded M4A does not simply lose notes: it invents them. At 32 kbps the polyphonic result grew from 8 to 14 notes, adding an A6, an A#5, an A#4 and extra short D4/G4 fragments that are not in the source. The same pattern appeared on the other clips: the buried-bass clip went from 20 polyphonic notes to 26 at 64 kbps and 30 at 32 kbps; the four-triad clip went from 14 to 24. Coding noise perturbs the spectral peaks that the polyphonic path keeps, and the salience gate lets some of them through as notes.

One more observation that belongs to the mode, not the format: on the three-note chord clip, monophonic mode returned 0 notes for all seven encodings, including flawless FLAC and ALAC. Three simultaneous pitches break the single-line assumption. If a whole conversion comes back empty, check monophonic vs polyphonic mode before blaming the file type, and then walk the order for fixing dropped notes.

6. The 55 Hz floor: worse audio can return more notes

A one-second pure 55.00 Hz sine sits exactly on this detector’s F_MIN = 55 floor. It is a useful torture test because the answer is already known, and because it shows why “more notes” is not the same as “better”:

Pure 55.00 Hz sine, 1.0 s, 44 100 Hz. Note counts from this site’s detector, identical settings throughout.
EncodingMono notesPoly notesWhat changed
WAV / FLAC / ALAC100baseline: A1, fragmented into ten short objects in mono
AAC 256k100same pitches, note boundaries drift
AAC 128k100first two velocities +1 step
AAC 64k60four fragments merged away
AAC 32k13mono collapses; poly invents three phantom A1 notes

The zero in the polyphonic column is not a codec failure — it is arithmetic. The 55 Hz tone lands mainly in FFT bin 5 (53.833 Hz). Parabolic interpolation across bins 4, 5 and 6 (magnitudes 107.507, 253.921, 148.888) puts the refined peak at about 54.72 Hz, which is 0.28 Hz below the floor. The polyphonic path keeps a peak only if pf >= F_MIN, so the clean file’s only real peak is discarded. At 32 kbps, codec noise smears enough energy around that boundary for three frames to squeak past the gate and be reported as notes. A cleaner file returned fewer notes than a damaged one.

This is the same low-frequency edge that bass line extraction and drum transcription limits run into, and the wider low-end resolution story is on MP3 to MIDI: below about 181 Hz, one 10.77 Hz bin is wider than a semitone. Codec noise sits on top of that limit; it does not create it.

7. The .mid file has no field for the format

Something people reasonably wonder: does the exported file remember that it came from an M4A? No. We parsed the 125-byte export produced by the WAV, FLAC, ALAC, AAC 256k and AAC 128k rows. It is one header (MThd, format 1, 2 tracks, 480 ticks per quarter note) and two tracks containing exactly these meta events:

There is nowhere to write “made from a FLAC”, and no byte does. A caveat for anyone reproducing this with a byte scan: the 480 ticks per quarter note are encoded as 0x01E0, so searching the raw bytes for 0xE0 will falsely suggest pitch-bend events. Parsing with running status gives 0 pitch-bend events. That matches the wider finding on how to make a MIDI file: whether the notes came from a recording, a hand-drawn piano roll or a score, the writer emits the same file shape with no source field. The anatomy of that shape is on MIDI converter.

8. When to convert here, and when to walk away

Not every job belongs on this page. Three honest exits, each tied to a number measured above:

Convert it right here. Your file is FLAC, ALAC, WAV, or AAC at 128 kbps or better, and you want a note list or a .mid from it. We measured a byte-identical 125-byte export from all five of those. No conversion to WAV first, no upload, no install — drop the file and convert.

Go install a dedicated tool. You need pitch bend, lyrics, or a single instrument pulled out of a mix. The 125-byte export carries 0 pitch-bend events and 0 lyric events, and the detector reads pitch from the whole signal rather than separating sources. See pitch bend detection, vocal to MIDI and lyrics and bass line extraction for exactly where that wall is.

You need a DAW or a score editor. You want an instrument assigned, a key signature, tempo detected from the audio, or notes edited by hand afterwards. The file has 0 program-change events, 0 key-signature events and one channel, and the written tempo is the number you typed, not a measurement. Start with cleaning up a converted MIDI or humanizing the result, then import it — FL Studio import is one worked example. If you want the tempo and key read from the audio, the BPM finder does that job on its own page.

9. How to check your own M4A or FLAC in two minutes

The measurement above is reproducible on your file, and you should not take any published accuracy figure on faith.

  1. Export the same take twice. Once as WAV or FLAC (lossless) and once in the M4A you actually plan to use. Do not re-encode an existing lossy file to make this comparison.
  2. Convert both here with identical settings. Same mode, same sensitivity, same shortest-note value. The mono/poly choice alone changes a three-note chord from 0 notes to 14 in our run.
  3. Download the .csv for each. Its columns are index,midi_note,note_name,start_sec,end_sec,duration_sec,velocity. Diff the note_name column first, then the velocity column.
  4. Read the differences correctly. A single onset moving about 11.61 ms is one analysis frame, not a dropped note. A spread of velocities by 1–2 steps is normal codec noise. Missing notes plus new high-register notes means the encode was aggressive — re-export from the lossless source at a higher bitrate.
  5. If nothing loads at all, it is a decode failure. No notes, no error about pitch: the browser did not have a decoder for the codec inside the container. Convert that one file to WAV once and try again.

And if you are coming from video rather than audio, MP4 to MIDI covers why the AAC audio track is the only part that reaches the detector, while WAV to MIDI covers the four things worth preparing before any conversion.

Questions people actually ask

Is FLAC better than M4A for audio to MIDI conversion?

FLAC is simpler, not automatically better. FLAC always decodes to bit-exact PCM; we confirmed identical hashes to the WAV on four different clips. An M4A can hold ALAC, which also decoded bit-exact, or AAC, which did not. But AAC at 256 and 128 kbps still produced the byte-identical 125-byte MIDI export on our eight-note clip. So: pick FLAC when you have the choice and want no variables, but do not re-encode a decent AAC file just to convert it.

Will an M4A file convert as well as a FLAC file?

At 128 kbps AAC or better, yes on our measurements: same eight notes, same velocities, same 125-byte .mid. At 64 kbps three note boundaries slipped by one 11.61 ms frame. At 32 kbps the clip returned five notes instead of eight and polyphonic mode added six ghost notes. The extension is not the variable; the bitrate is.

Do I need to convert M4A or FLAC to WAV before using this tool?

No. The browser decodes the file itself and the converter reads the resulting samples; the file input accepts audio/*. Re-encoding a lossy M4A to WAV cannot restore what the codec discarded, and re-encoding an MP3 into an M4A stacks two codecs’ worth of noise. The one exception is a codec your specific browser cannot decode, in which case a single local conversion to WAV is the fix — not a quality upgrade.

Why did a low-bitrate M4A give me more notes than the original?

Because the detector reads peaks, not music. At 32 kbps our eight-note clip went from 8 to 14 polyphonic notes, with an A6, an A#5 and an A#4 that are not in the source. Perceptual coding spreads noise across the spectrum; the polyphonic path keeps up to 6 peaks per 11.61 ms frame, and some of those peaks become notes. Extra notes at a low bitrate are an artefact, not extra information. The same effect gave a clean 55 Hz sine 0 notes in polyphonic mode but 3 notes at 32 kbps.

Does the converter read the .m4a extension at all?

No. It calls decodeAudioData, which returns an AudioBuffer, then dsp.js resamples to 22,050 Hz, averages to mono, and runs a 2048-point FFT every 256 samples. By the time pitch detection starts, the container name is gone. What the file extension does affect is whether your browser has a decoder for the stream inside — the one real container-dependent failure.

Can a lossless M4A still lose notes?

Its samples cannot be lost: ALAC decoded byte-for-byte identical to the WAV on every clip we ran. But note detection has its own limits that have nothing to do with the codec. Three simultaneous notes returned 0 notes in monophonic mode for FLAC and ALAC alike, and a pure 55 Hz sine returned 0 notes in polyphonic mode because the interpolated peak fell below the 55 Hz floor. Lossless input gives the detector its best chance, not a guarantee.

Does the .mid record that it came from an M4A?

No. The 125-byte export we dissected contains one tempo event, one 4/4 time-signature event, two end-of-track events and the note events — no track name, no text, no lyric, no key signature, no program change. Five different encodings produced the same file byte for byte. The format leaves no trace in the output, which is also why the ownership of a converted MIDI is a question about the source music, not about the container.

Why does the pitch come out wrong in the bass for both FLAC and M4A?

Below about 181 Hz, one 10.7666 Hz FFT bin is wider than a semitone, so parabolic interpolation has less than a bin to work with. That is set by the 22,050 Hz / 2048 analysis grid and is identical for every format. It is why MP3 to MIDI measured the same bass behaviour for WAV and MP3, and why pulling out just the bass line is not something this converter can do. A cleaner container cannot widen a bin.

Drop the M4A or FLAC you already have into the Audio to MIDI Converter and compare the piano roll with a lossless export of the same take. It runs in your browser, nothing is uploaded, and every number above is reproducible on your own audio in a couple of minutes.

Related guides