Zig bindings for miniaudio library. Tested on Windows, Linux and macOS but should also work on mobile/web platforms.
As an example program please see audio experiments (wgpu).
Provided structs:
-
Device
-
Engine
-
Sound
-
SoundGroup
-
NodeGraph
-
Fence
-
Context
(missing methods) -
ResourceManager
(missing methods) -
Log
(missing methods) -
DataSource
(missing methods)-
Waveform
-
Noise
- custom data sources
-
-
Node
-
DataSourceNode
-
SplitterNode
-
BiquadNode
-
LpfNode // Low-Pass Filter
-
HpfNode // High-Pass Filter
-
NotchNode
-
PeakNode
-
LoshelfNode // Low Shelf Filter
-
HishelfNode // High Shelf Filter
-
DelayNode
- custom nodes
-
Copy zaudio
and system-sdk
folders to a libs
subdirectory of the root of your project.
Then in your build.zig
add:
const std = @import("std");
const zaudio = @import("libs/zaudio/build.zig");
pub fn build(b: *std.Build) void {
...
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
const zaudio_pkg = zaudio.package(b, target, optimize, .{});
zaudio_pkg.link(exe);
}
Now in your code you may import and use zaudio
:
const zaudio = @import("zaudio");
pub fn main() !void {
...
zaudio.init(allocator);
defer zaudio.deinit();
const engine = try zaudio.Engine.create(null);
const music = try engine.createSoundFromFile(
content_dir ++ "Broke For Free - Night Owl.mp3",
.{ .flags = .{ .stream = true } },
);
try music.start();
...
}