Giter VIP home page Giter VIP logo

zig-miniaudio's Introduction

zig-miniaudio

Zig wrapper for miniaudio. The low-level, direct miniaudio API is available by importing the "miniaudio" package. There is also a high-level API that wraps the miniaudio engine in Zig fashion. It consists of the following players:

  • AudioEngine: wraps up the ma_engine and provides convenience methods for setting engine-level properties and for creating Sounds and SoundGroups.
  • SoundGroup: optional construct that allows you to group multiple Sounds and control them
  • Sound: can be loaded with an audio file, waveform or any raw data source that you provide. Has playback, pan, gain, volume properties.
  • SfxrDataSource: a special helper for games. Exposes dynamic SFXR effects including all the usual presets: coin, laser, explosion, power_up, hurt, jump and blip.

Usage

For details using the low-level, direct miniaudio API check the miniaudio documentation. To get started with the AudioEngine, see the example below:

pub fn main() !void {
    var engine = try AudioEngine.create(std.testing.allocator);
    defer engine.deinit();
    
    // basic fire-and-forget playback
    try engine.playOneShot("clang.wav");
    
    // stream a sound from disk, fading it in
    var music = try engine.createSoundWithOptions("clang-beat.wav", .{ .stream = true });
    defer music.destroy();
    
    music.setFadePointInMilliseconds(0, 0, 0.3, 0, 1000);
    music.start();
    
    // loop a sound quietly
    var snd = try engine.createSound("loop.wav");
    defer snd.destroy();
    
    snd.setLooping(true);
    snd.setVolume(0.3)
    snd.start();
}

zig-miniaudio's People

Contributors

prime31 avatar mikedjc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.