Skip to content

Latest commit

 

History

History

zaudio

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

zaudio v0.10.0 - Cross-platform audio

Zig build package and wrapper for miniaudio v0.11.21

As an example program please see audio experiments (wgpu).

Features

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

Getting started

Copy zaudio and system-sdk to a subdirectory of your project and add the following to your build.zig.zon .dependencies:

    .system_sdk = .{ .path = "local/path/to/system-sdk" },
    .zaudio = .{ .path = "local/path/to/zaudio" },

Then in your build.zig add:

pub fn build(b: *std.Build) void {
    const exe = b.addExecutable(.{ ... });

    const zaudio = b.dependency("zaudio", .{});
    exe.root_module.addImport("zaudio", zaudio.module("root"));
    exe.linkLibrary(zaudio.artifact("miniaudio"));
}

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);
    defer engine.destroy();

    const music = try engine.createSoundFromFile(
        content_dir ++ "Broke For Free - Night Owl.mp3",
        .{ .flags = .{ .stream = true } },
    );
    defer music.destroy();
    try music.start();
    ...
}