NOTE: This project is based on zig version 0.13.0. Other versions of zig are not guaranteed to work and may require modifications.
First, run:
zig fetch --save git+https://github.com/hosackm/minimp3Next, update your build.zig:
const minimp3 = b.dependency("minimp3", .{});
exe.root_module.addImport("minimp3", minimp3.module("minimp3"));There's an example in the example directory. It shows you how you can decode an mp3 to PCM and access some information about each of the frames within it.
You can copy this code directly into your src/main.zig.
An example.mp3 is provided in the example directory.
zig build run -- example/example.mp3 output.pcmThe example writes an audio file as raw pcm. Use ffplay to play it:
Note: At the time of writing the current version of
ffmpegis 7.1.4. The options I'm providing may not work for your version offfplay.
ffplay -f s16le -ch_layout stereo -sample_rate 44100 output.pcm