- Zig 100%
| src | Pedantic comment update to sample program | |
| build.zig | Lots of work on the bindings and build system; add README | |
| build.zig.zon | Lots of work on the bindings and build system; add README | |
| LICENSE.md | Now licensed under Apache 2.0 | |
| README.md | Update README.md with actually correct usage instructions | |
==== STEAM AUDIO ====
Steam Audio is an audio spatialization library built by Valve Corporation. "Audio spatialization" concerns audio effects such as stereo sound, distance attenuation and audio dampening for when sound is being heard through solid geometry.
This is a repackage of the Steam Audio Core SDK for the Zig build system. This package is built for Zig 0.16.0... for now.
Simple usage guide:
Add this package as a dependency in your build.zig.zon:
zig fetch --save GIT+https://codeberg.org/Tiftid/steam-audio
In your build.zig file, fetch the dependency and get the phonon module and libphonon lazy path:
const phonon_dep = b.dependency("steam_audio", .{
.target = target,
.optimize = optimize,
});
const phonon = phonon_dep.module("phonon");
const libphonon = phonon_dep.namedLazyPath("libphonon");
"libphonon" is the path to a dynamic library whose name and object format are determined by the target of the compilation. If Valve didn't provide a dynamic library for the given target, the configure phase of your build will error out.
In order for your executable to work, you MUST install libphonon next to it. To determine what name to install it under, you can use the following code:
const libphonon_name = std.fs.path.basename(libphonon.dependency.sub_path);
To install it next to your executable, you can then use the following code:
const libphonon_install = b.addInstallBinFile(libphonon, libphonon_name);
exe.step.dependOn(&libphonon_install.step);
Bindings
This package also provides hand-written Zig bindings over some parts of the Steam Audio C API. The pattern is mostly as follows:
- The various functions that could return errors and took an output pointer now return an error union so you can use them with the try/catch keywords
- All enumerations and bitflags now have a native Zig equivalent
- Any structure which had one of these enumerations or bitflags as one of its members now also has a native Zig equivalent
- Any function which took in one of this structures as input now takes in the native equivalent
- I also took the opportunity to put as many things in namespaces as possible
A quick example; here's how you create (and release) a context handle in the base C API:
IPLContextSettings contextSettings{};
contextSettings.version = STEAMAUDIO_VERSION;
IPLContext context = nullptr;
iplContextCreate(&contextSettings, &context);
// Your code here
iplContextRelease(&context);
And here's how you do it with the bindings:
var context: phonon.IPLContext = try bindings.context.create(.{});
defer phonon.iplContextRelease(&context);
// Your code here
You can access the bindings module by simply requesting it from your dependency like the phonon module:
const phonon_bindings = phonon_dep.module("bindings");
Original README
The Steam Audio README is reproduced below in its entirety:
Steam Audio 4.8.1
Valve Corporation
Supported Platforms
Steam Audio supports Windows (32 bit and 64 bit), Linux (32 bit and 64 bit), macOS, Android (armv7, arm64, x86, x64), and iOS platforms.
Supported Integrations
Steam Audio supports Unity 2017.3+, Unreal Engine 4.27+, FMOD Studio 2.0+, and Wwise 2023.1+.