arsd.mp3

Port of the C library minimp3 to D, with an added high-level API in the form of MP3Decoder.

You can use it through arsd.simpleaudio's playMp3 function for a very easy high-level api to just play the sound. If all you want is the mp3 sound to come out your computer's speakers, use that api. If you want to inspect a mp3 file's innards, play it through a different api, convert it to different formats, etc., this module may help you.

Members

Classes

MP3Decoder
class MP3Decoder

The high-level D api for mp3 decoding. You construct it with a read and seek function, then inspect the members for info about the mp3, then call decodeNextFrame and frameSamplesFloat in a loop to get the data until frameSamplesFloat returns an empty array, indicating you've hit the end of file.

Meta

Authors

Original C source: https://github.com/lieff/minimp3

To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. See <http://creativecommons.org/publicdomain/zero/1.0/>.

Translated to D by Guillaume Piolat. He stripped it down a bit for the needs of audio-formats.

Lightly modified by Adam for arsd inclusion and maintaining compatibility with the published interface of the old implementation. I added the MP3Decoder back from the old implementation and removed @nogc nothrow for being annoying. Of course, most things here don't do GC or throws at runtime anyway, with the exception of first call setups.

History

This module used to be based on a different minimp3, written in 2008 and based on ffmpeg code. On November 20, 2020, I replaced it with the newer implementation (which is the designated successor of the original minimp3). Since the implementation was all private previously, this meant little outside breakage, but some attribute qualifiers changed.

The new minimp3 implementation is public, but not part of the official arsd.mp3 API, so I reserve the right to change it again without notice. Only the MP3Decoder has stability guarantees. (Though I am unlikely to change what works.)