audionimbus_sys/lib.rs
1/*!
2Rust bindings to the [Steam Audio](https://valvesoftware.github.io/steam-audio/) library.
3This crate is not meant to be used directly; most users should use [`audionimbus`](https://github.com/MaxenceMaire/audionimbus/tree/master/audionimbus), a safe wrapper built on top of `audionimbus-sys`.
4
5## Overview
6
7`audionimbus-sys` exposes raw bindings to the Steam Audio C library.
8It is inherently unsafe, as it interfaces with external C code; for a safe API, refer to [`audionimbus`](https://github.com/MaxenceMaire/audionimbus/tree/master/audionimbus).
9
10`audionimbus-sys` can also integrate with FMOD and Wwise.
11
12## Version compatibility
13
14`audionimbus-sys` mirrors the version of Steam Audio.
15
16## Installation
17
18### Automatic Installation (Recommended)
19
20The easiest way to use `audionimbus-sys` is with automatic installation. This will automatically download and set up the required Steam Audio libraries for your target platform.
21
22#### Requirements
23
24- **curl** or **wget** (for downloading)
25- **Clang 9.0 or later**
26
27#### Basic Usage
28
29Add `audionimbus-sys` to your `Cargo.toml` with the `auto-install` feature:
30
31```toml
32[dependencies]
33audionimbus-sys = { version = "4.8.0", features = ["auto-install"] }
34```
35
36#### With FMOD Studio Integration
37
38```toml
39[dependencies]
40audionimbus-sys = { version = "4.8.0", features = ["auto-install", "fmod"] }
41```
42
43You also need to set the `FMODSDK` environment variable to the path of the FMOD SDK installed on your system (e.g. `export FMOD="/path/to/FMOD"`).
44
45#### With Wwise Integration
46
47```toml
48[dependencies]
49audionimbus-sys = { version = "4.8.0", features = ["auto-install", "wwise"] }
50```
51
52You also need to set the `WWISESDK` environment variable to the path of the Wwise SDK installed on your system (e.g. `export WWISESDK="/path/to/Audiokinetic/Wwise2024.1.3.8749/SDK"`).
53
54#### How It Works
55
56When you build your project with the `auto-install` feature, the build script:
57
581. Automatically detects your target platform and architecture
592. Downloads the appropriate Steam Audio release zip file (cached to avoid re-downloading)
603. Extracts only the required shared libraries for your platform
614. Sets up the library search paths automatically
62
63The downloaded files are cached in `$OUT_DIR/steam_audio_cache` and won't be re-downloaded unless the version changes.
64If you need to force a re-download, you can delete this directory.
65
66> **Note**
67> The initial download can be quite large (≈180 MB for Steam Audio, ≈140 MB for the FMOD integration ≈52MB for the Wwise integration).
68> During this step, cargo build may look like it is stuck - it’s just downloading in the background.
69> The files are cached, so this only happens the first time (or when the version changes).
70
71### Manual Installation
72
73If you prefer manual installation or the automatic installation doesn't work for your setup, you can still install Steam Audio manually.
74
75#### Requirements
76
77Before installation, make sure that Clang 9.0 or later is installed on your system.
78
79#### Steps
80
81`audionimbus-sys` requires linking against the Steam Audio library during compilation.
82
83To do so, download `steamaudio_4.8.0.zip` from the [release page](https://github.com/ValveSoftware/steam-audio/releases).
84
85Locate the relevant library for your target platform (`SDKROOT` refers to the directory in which you extracted the zip file):
86
87| Platform | Library Directory | Library To Link |
88| --- | --- | --- |
89| Windows 32-bit | `SDKROOT/lib/windows-x86` | `phonon.dll` |
90| Windows 64-bit | `SDKROOT/lib/windows-x64` | `phonon.dll` |
91| Linux 32-bit | `SDKROOT/lib/linux-x86` | `libphonon.so` |
92| Linux 64-bit | `SDKROOT/lib/linux-x64` | `libphonon.so` |
93| macOS | `SDKROOT/lib/osx` | `libphonon.dylib` |
94| Android ARMv7 | `SDKROOT/lib/android-armv7` | `libphonon.so` |
95| Android ARMv8/AArch64 | `SDKROOT/lib/android-armv8` | `libphonon.so` |
96| Android x86 | `SDKROOT/lib/android-x86` | `libphonon.so` |
97| Android x64 | `SDKROOT/lib/android-x64` | `libphonon.so` |
98| iOS ARMv8/AArch64 | `SDKROOT/lib/ios` | `libphonon.a` |
99
100Ensure the library is placed in a location listed in the [dynamic library search paths](https://doc.rust-lang.org/cargo/reference/environment-variables.html#dynamic-library-paths) (e.g., `/usr/local/lib`).
101
102Finally, add `audionimbus-sys` to your `Cargo.toml`:
103
104```toml
105[dependencies]
106audionimbus-sys = "4.8.0"
107```
108
109#### Manual FMOD Studio Integration
110
111`audionimbus-sys` can be used to add spatial audio to an FMOD Studio project.
112
113It requires linking against both the Steam Audio library and the FMOD integration library during compilation:
114
1151. Download `steamaudio_fmod_4.8.0.zip` from the [release page](https://github.com/ValveSoftware/steam-audio/releases).
116
1172. Locate the two relevant libraries for your target platform (`SDKROOT` refers to the directory in which you extracted the zip file):
118
119| Platform | Library Directory | Library To Link |
120| --- | --- | --- |
121| Windows 32-bit | `SDKROOT/lib/windows-x86` | `phonon.dll`, `phonon_fmod.dll` |
122| Windows 64-bit | `SDKROOT/lib/windows-x64` | `phonon.dll`, `phonon_fmod.dll` |
123| Linux 32-bit | `SDKROOT/lib/linux-x86` | `libphonon.so`, `libphonon_fmod.so` |
124| Linux 64-bit | `SDKROOT/lib/linux-x64` | `libphonon.so`, `libphonon_fmod.so` |
125| macOS | `SDKROOT/lib/osx` | `libphonon.dylib`, `libphonon_fmod.dylib` |
126| Android ARMv7 | `SDKROOT/lib/android-armv7` | `libphonon.so`, `libphonon_fmod.so` |
127| Android ARMv8/AArch64 | `SDKROOT/lib/android-armv8` | `libphonon.so`, `libphonon_fmod.so` |
128| Android x86 | `SDKROOT/lib/android-x86` | `libphonon.so`, `libphonon_fmod.so` |
129| Android x64 | `SDKROOT/lib/android-x64` | `libphonon.so`, `libphonon_fmod.so` |
130| iOS ARMv8/AArch64 | `SDKROOT/lib/ios` | `libphonon.a`, `libphonon_fmod.a` |
131
1323. Ensure the libraries are placed in a location listed in the [dynamic library search paths](https://doc.rust-lang.org/cargo/reference/environment-variables.html#dynamic-library-paths) (e.g., `/usr/local/lib`).
133
1344. Set the `FMODSDK` environment variable to the path of the FMOD SDK installed on your system (e.g. `export FMOD="/path/to/FMOD"`).
135
1365. Finally, add `audionimbus-sys` with the `fmod` feature enabled to your `Cargo.toml`:
137
138```toml
139[dependencies]
140audionimbus-sys = { version = "4.8.0", features = ["fmod"] }
141```
142
143#### Manual Wwise Integration
144
145`audionimbus-sys` can be used to add spatial audio to a Wwise project.
146
147It requires linking against both the Steam Audio library and the Wwise integration library during compilation:
148
1491. Download `steamaudio_wwise_4.8.0.zip` from the [release page](https://github.com/ValveSoftware/steam-audio/releases).
150
1512. Locate the two relevant libraries for your target platform and place them in a location listed in [dynamic library search paths](https://doc.rust-lang.org/cargo/reference/environment-variables.html#dynamic-library-paths) (e.g., `/usr/local/lib`).
152
1533. Set the `WWISESDK` environment variable to the path of the Wwise SDK installed on your system (e.g. `export WWISESDK="/path/to/Audiokinetic/Wwise2024.1.3.8749/SDK"`).
154
1554. Finally, add `audionimbus-sys` with the `wwise` feature enabled to your `Cargo.toml`:
156
157```toml
158[dependencies]
159audionimbus-sys = { version = "4.8.0", features = ["wwise"] }
160```
161
162## Documentation
163
164Documentation is available at [docs.rs](https://docs.rs/audionimbus-sys/latest).
165
166Since this crate strictly follows Steam Audio’s C API, you can also refer to the [Steam Audio C API reference](https://valvesoftware.github.io/steam-audio/doc/capi/reference.html) for additional details.
167
168Note that because the FMOD and Wwise integrations depend on files that are local to your system, documentation for the `fmod` and `wwise` modules is not available on docs.rs.
169However, it can be generated locally using `cargo doc --open --features fmod` (resp. `wwise`).
170
171## License
172
173`audionimbus-sys` is dual-licensed under the [MIT License](https://github.com/MaxenceMaire/audionimbus/blob/master/LICENSE-MIT) and the [Apache-2.0 License](https://github.com/MaxenceMaire/audionimbus/blob/master/LICENSE-APACHE).
174You may choose either license when using the software.
175*/
176
177mod phonon;
178pub use phonon::*;
179
180#[cfg(feature = "fmod")]
181pub mod fmod;
182#[cfg(feature = "fmod")]
183pub use fmod::*;
184
185#[cfg(feature = "wwise")]
186pub mod wwise;
187#[cfg(feature = "wwise")]
188pub use wwise::*;