1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
//! fmod-oxide
//! Safe rust bindings to the FMOD sound engine.
//! This crate tries to be as rusty and low-cost as possible, without compromising on any APIs.
//! Certain APIs, such as loading banks from a pointer, are marked as unsafe, but are still available for use.
//!
//! Supports FMOD versions >2.0.2.28 and >2.0.3.07, and Windows/Linux/MacOS/HTML5 platforms.
//!
//! Any newer patch-level FMOD versions should compile but might have missing features.
//!
//! ### Using this crate
//!
//! Due to licensing restrictions this crate can't bundle FMOD, so you'll need to [download](https://www.fmod.com/download) a copy of FMOD yourself.
//!
//! Make sure to download from `FMOD Engine` specifically.
//! 
//!
//! After downloading FMOD, you have to tell this crate where FMOD is located.
//! **If you're on Windows and used the FMOD installer, you don't have to worry about this.**
//!
//! The easiest way is to create a cargo config in your project's root.
//!
//! ```toml
//! # `.cargo/config.toml`
//!
//! [env]
//! FMOD_SYS_FMOD_DIRECTORY = { value = "<absolute install path here>" }
//! ```
//!
//! You can also specify a relative install path like so:
//!
//! ```toml
//! # `.cargo/config.toml`
//!
//! [env]
//! FMOD_SYS_FMOD_DIRECTORY = { value = "<install path here>", relative = true }
//! ```
//!
//! (not recommended because rust-analyzer won't know this) Alternatively, you can specify `FMOD_SYS_FMOD_DIRECTORY` when building your project:
//!
//! `FMOD_SYS_FMOD_DIRECTORY=<path> cargo run`
//!
//! ### Cross compilation
//!
//! This crate supports cross compilation and will look for a target-specific FMOD install.
//!
//! The logic is quite basic at the moment, but it'll check if `<fmod install dir>/<target os>` exists and use that.
//!
//! If no target specific directory was found, it'll default to `<fmod install dir>`
//!
//! ### Using with webassembly
//!
//! Currently only `wasm32-unknown-emscripten` works well.
//! `wasm32-unknown-unknown` also works in some capacity but you have to essentially reimplement parts of libc and emscripten.
//!
//! Unfortunately `wasm-bindgen` doesn't work without patches right now, so your milage may vary
//!
//! The setup is roughly the same, except you'll need to add some arguments to `EMCC_FLAGS`.
//!
//! You can do this by editing `.cargo/config.toml`:
//! ```toml
//! # `.cargo/config.toml`
//!
//! [env]
//! EMCC_CFLAGS="-s EXPORTED_RUNTIME_METHODS=ccall,cwrap,setValue,getValue" # FMOD requires this
//! ```
//!
//! If you're using `wasm32-unknown-unknown`, you'll additionally need to add this until [this issue](https://github.com/rust-lang/rust/issues/138762) is closed.
//!
//! ```toml
//! # `.cargo/config.toml`
//!
//! [build]
//! rustflags="-Zwasm-c-abi=spec"
//! ```
//!
//! See [`web-examples/emscripten`](web-examples/emscripten) for a more detailed example.
//!
//! # Memory management & Copy types
//!
//! All FMOD objects are Copy, Clone, Send and Sync because it's possible to have multiple references to the same object. (e.g. loading a bank and then retrieving it by its path)
//! There are a lot of use-cases where you may want to fetch something (like a bank) and never use it again.
//! Implementing `Drop` to automatically release things would go against that particular use-case, so this crate opts to have manual `release()` methods instead.
//!
//! This crate does not currently guard against use-after-frees, *however* using most of FMOD's types (especially FMOD Studio's types) after calling `release()` is safe.
//! I'm still not 100% sure of what is and isn't safe and I'm actively trying to test this.
//!
//! # String types
//!
//! fmod-oxide aims to be as zero-cost as possible, and as such, it uses UTF-8 C strings from the `lanyard` crate as its string type.
//! This means that all FMOD functions take a `&Utf8CStr` instead of a `&str` or `&CStr`.
//! `&Utf8CStr` is pretty cheap to construct (and can even be done statically with the `c!` macro), so this should not be a problem
//!
//! When FMOD returns a string, it will always return a `Utf8CString` (the owned version of `Utf8CStr`) because it's difficult to encode lifetime requirements of FMOD strings.
//!
//! This applies to structs like `fmod::studio::AdvancedSettings` which store C strings.
//! Converting structs like `AdvancedSettings` to their FFI equivalents is done by reference as to not pass ownership of the string to FMOD
//!
//! # Basic example
//! ```ignore
//! // System creation is unsafe and must be performed prior to any other FMOD operations.
//! let mut builder = unsafe { fmod::studio::SystemBuilder::new() }?;
//! let system = builder.build()?;
//!
//! // Load a bank
//! let bank = system.load_bank_file("path/to/bank.bank", fmod::studio::LoadBankFlags::NORMAL)?;
//! // Query all events in the bank
//! for event in bank.get_event_list().unwrap() {
//! println!("Event: {}", event.get_path()?);
//! }
//!
//! // Releasing Systems is unsafe because it cannot be called concurrently, and all FMOD objects are rendered invalid.
//! unsafe { system.release() };
//! ```
//! # Feature flags
// Used to document cfgs (copied from https://docs.rs/winit/latest/src/winit/lib.rs.html#1-207)
/// How much of FMOD's API fmod-oxide covers.
pub use FmodResultExt;
pub use ;
// Not really practical to go no_std.
// FMOD requires libc on pretty much every platform (even webassembly!)
// If you're using libc you probably can use std too.
/// The low-level FMOD core API.
pub use *;
pub use *;
pub use fmod_sys as sys;
pub use *;
/// The FMOD Studio API.
///
/// The Studio API is a more high-level library which is tightly integrated with *FMOD Studio*, FMOD's production tool.
/// Current FMOD version number.
///
/// The version is a 32 bit hexadecimal value formatted as 16:8:8, with the upper 16 bits being the product version,
/// the middle 8 bits being the major version and the bottom 8 bits being the minor version.
/// For example a value of `0x00010203` is equal to `1.02.03`.
pub const VERSION: u32 = FMOD_VERSION;
/// The FMOD build number.
pub const BUILD_NUMBER: u32 = FMOD_BUILDNUMBER;
/// Maximum number of channels per sample of audio supported by audio files, buffers, connections and [`Dsp`]s.
pub const MAX_CHANNEL_WIDTH: u32 = FMOD_MAX_CHANNEL_WIDTH;
/// Maximum number of listeners supported.
pub const MAX_LISTENERS: u32 = FMOD_MAX_LISTENERS;
/// The maximum number of global reverb instances.
///
/// Each instance of a reverb is an instance of an [`DspType::SfxReverb`] DSP in the DSP graph.
/// This is unrelated to the number of possible [`Reverb3D`] objects, which is unlimited.
pub const MAX_REVERB_INSTANCES: u32 = FMOD_REVERB_MAXINSTANCES;
/// Maximum number of System objects allowed.
pub const MAX_SYSTEMS: u32 = FMOD_MAX_SYSTEMS;
pub
pub