MP3.jl

UNMAINTAINED - MP3 codec for Julia using JuliaAudio idioms. LAME and mpg123 working under the hood
Popularity
11 Stars
Updated Last
1 Year Ago
Started In
June 2016

MP3

This project is unmaintained

Tests codecov.io

MP3 is a Julia library for reading and writing MP3 files.

Usage

The API follows the idioms of FileIO, and uses SampleBuf type to store audio samples. This should supplement LibSndFile which does not support MP3 for patent issues.

Loading MP3

julia> using MP3

julia> audio = load("Sour_Tennessee_Red_Sting.mp3")
245376-frame, 2-channel SampleBuf{FixedPointNumbers.Fixed{Int16,15}, 2, SIUnits.SIQuantity{Int64,0,0,-1,0,0,0,0,0,0}}
5.564081632653061 s at 44100 s⁻¹
▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▆▆▆▇▇▇▇▆▆▅▄▄▄▄▄▄▇▇▇▇▇▆▇▇▇▇▇▆▅▅▄▄▃▃▃▃▃▂▂▂▁▂▁▁▁
▇▇▇▆▇▇▇▆▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▆▆▅▇▇▆▆▆▅▅▄▄▄▅▄▃▇▇▇▇▇▆▇▇▇▇▆▆▅▄▄▄▄▃▃▃▃▂▂▂▁▂▁▁▁

Saving MP3

Various options for encoding MP3 files can be specified using keyword arguments to save() function. An ID3v2 block will be added in front of the file, and the following tags can be optionally given as keyword arguments: title, artist, album, year, comment.

julia> save("mono.mp3", audio; nchannels = 1)           # save as mono audio

julia> save("small.mp3", audio; bitrate = 128)          # set bitrate to 128kbps

julia> save("vbr.mp3", audio; VBR = true, quality = 0)  # encode as highest-quality VBR

julia> save("down.mp3", audio; samplerate = 8kHz)       # downsample to 8 kHz

License

This Julia library is distributed under MIT license. It uses LAME for encoding and mpg123 for decoding mp3, which are dynamically linked, binding to the terms of their LGPL.