├── .gitignore ├── .travis.yml ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── al-sys ├── Cargo.toml ├── build.rs └── src │ ├── al.rs │ ├── alc.rs │ ├── efx.rs │ ├── efx_presets.rs │ └── lib.rs ├── examples ├── basic.rs ├── input.rs └── sine.rs ├── src ├── al │ ├── format.rs │ └── mod.rs ├── alc.rs ├── efx │ ├── mod.rs │ └── presets.rs ├── ext.rs └── lib.rs └── tests └── alto.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /al-sys/target 3 | /.cargo 4 | Cargo.lock 5 | 6 | *.vim 7 | *.sw[onp] 8 | *~ 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | cache: cargo 3 | rust: 4 | - nightly 5 | - stable 6 | env: 7 | - RUST_TEST_THREADS=1 8 | addons: 9 | apt: 10 | packages: 11 | - libopenal-dev 12 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "alto" 3 | description = "Idiomatic interface for OpenAL 1.1 and extensions (including EFX)" 4 | version = "3.0.3" 5 | authors = ["Jameson Ernst "] 6 | license = "MIT/Apache-2.0" 7 | repository = "https://github.com/jpernst/alto.git" 8 | documentation = "https://docs.rs/alto" 9 | homepage = "https://www.jpernst.com" 10 | keywords = ["openal", "al", "sound", "audio"] 11 | categories = ["multimedia::audio", "api-bindings"] 12 | 13 | [features] 14 | default = ["dynamic"] 15 | dynamic = ["al-sys/dynamic"] 16 | 17 | [dependencies] 18 | lazy_static = "0.2.1" 19 | parking_lot = "0.4.4" 20 | al-sys = { version = "0.6.0", path = "al-sys", default-features = false } 21 | -------------------------------------------------------------------------------- /LICENSE-APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Jameson Ernst 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # alto 2 | 3 | `alto` provides idiomatic Rust bindings for [OpenAL 1.1](http://connect.creativelabs.com/openal/) 4 | and extensions (including EFX). 5 | 6 | ## WARNING 7 | 8 | Because Alto interacts with global C state via dynamic linking, having multiple versions of Alto in one project could lead to unsafety. 9 | Please make sure only one version of Alto is in your dependency tree at any given time. 10 | 11 | ## API Usage 12 | 13 | ```rust 14 | let alto = Alto::load_default()?; 15 | 16 | for s in alto.enumerate_outputs() { 17 | println!("Found device: {}", s.to_str()?); 18 | } 19 | 20 | let device = alto.open(None)?; // Opens the default audio device 21 | let context = device.new_context(None)?; // Creates a default context 22 | 23 | // Configure listener 24 | context.set_position([1.0, 4.0, 5.0]); 25 | context.set_velocity([2.5, 0.0, 0.0]); 26 | context.set_orientation(([0.0, 0.0, 1.0], [0.0, 1.0, 0.0])); 27 | 28 | let source = context.new_static_source()?; 29 | 30 | // Now you can load your samples and store them in a buffer with 31 | // `context.new_buffer(samples, frequency)`; 32 | ``` 33 | -------------------------------------------------------------------------------- /al-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "al-sys" 3 | description = "Raw bindings for OpenAL 1.1" 4 | version = "0.6.0" 5 | authors = ["Jameson Ernst "] 6 | license = "MIT/Apache-2.0" 7 | repository = "https://github.com/jpernst/alto.git" 8 | documentation = "https://docs.rs/al-sys" 9 | homepage = "https://www.jpernst.com" 10 | keywords = ["openal", "al", "sound", "audio"] 11 | categories = ["multimedia::audio", "external-ffi-bindings"] 12 | 13 | [features] 14 | default = ["dynamic"] 15 | dynamic = ["libloading", "rental"] 16 | 17 | [dependencies] 18 | 19 | [build-dependencies] 20 | cmake = "0.1.40" 21 | 22 | [target.'cfg(not(target_os = "emscripten"))'.dependencies] 23 | libloading = { version = "0.5", optional = true } 24 | rental = { version = "0.5.0", optional = true } 25 | -------------------------------------------------------------------------------- /al-sys/build.rs: -------------------------------------------------------------------------------- 1 | extern crate cmake; 2 | 3 | use cmake::Config; 4 | use std::{env, path::PathBuf, process::Command}; 5 | 6 | // can be overridden by setting the env var ANDROID_NATIVE_API_LEVEL 7 | const DEFAULT_ANDROID_API_LEVEL: &'static str = "16"; 8 | 9 | const OPENAL_SOFT_TAG: &'static str = "openal-soft-1.19.1"; 10 | 11 | const OPENAL_REPO: &'static str = "https://github.com/kcat/openal-soft.git"; 12 | 13 | fn clone_openalsoft() -> PathBuf { 14 | let out = PathBuf::from(env::var("OUT_DIR").unwrap()).join("openal-soft"); 15 | let status = Command::new("git") 16 | .arg("clone") 17 | .args(&["--branch", OPENAL_SOFT_TAG]) 18 | .args(&["--depth", "1"]) 19 | .arg(OPENAL_REPO) 20 | .arg(&out) 21 | .status() 22 | .unwrap(); 23 | if !status.success() { 24 | let status = Command::new("git") 25 | .arg("clean") 26 | .arg("-fdx") 27 | .current_dir(&out) 28 | .status() 29 | .unwrap(); 30 | assert!(status.success(), "failed to clone openal-soft"); 31 | let status = Command::new("git") 32 | .arg("checkout") 33 | .arg(format!("tags/{}", OPENAL_SOFT_TAG)) 34 | .current_dir(&out) 35 | .status() 36 | .unwrap(); 37 | assert!(status.success(), "failed to clone openal-soft"); 38 | } 39 | out 40 | } 41 | 42 | fn build_openalsoft(openal_dir: PathBuf) { 43 | let target = &*env::var("TARGET").unwrap(); 44 | let ndk_dir = &*env::var("NDK_HOME").expect("set the environment variable `NDK_HOME` to the ndk directory to build `al-sys` for android"); 45 | 46 | let toolchain_file = PathBuf::from(ndk_dir).join("build/cmake/android.toolchain.cmake"); 47 | let abi = match target { 48 | "aarch64-linux-android" => "arm64-v8a", 49 | "armv7-linux-androideabi" => "armeabi-v7a", 50 | "arm-linux-androideabi" => "armeabi", 51 | "thumbv7neon-linux-androideabi" => "armeabi", // TODO: is this correct? 52 | "i686-linux-android" => "x86", 53 | "x86_64-linux-android" => "x86_64", 54 | _ => unreachable!(), 55 | }; 56 | let libtype = match env::var("CARGO_FEATURE_DYNAMIC") { 57 | Ok(_) => "SHARED", 58 | _ => "STATIC" 59 | }; 60 | let api_level = env::var("ANDROID_NATIVE_API_LEVEL").unwrap_or(DEFAULT_ANDROID_API_LEVEL.to_owned()); 61 | let platform = &*format!("android-{}", api_level); 62 | 63 | let dst = Config::new(openal_dir) 64 | .define("CMAKE_TOOLCHAIN_FILE", toolchain_file) 65 | .define("ANDROID_ABI", abi) 66 | .define("ALSOFT_UTILS", "OFF") 67 | .define("ALSOFT_EXAMPLES", "OFF") 68 | .define("ALSOFT_TESTS", "OFF") 69 | .define("ANDROID_NDK", ndk_dir) 70 | .define("LIBTYPE", libtype) 71 | .define("ANDROID_NATIVE_API_LEVEL", api_level) 72 | .define("ANDROID_PLATFORM", platform) 73 | .no_build_target(true) 74 | .build(); 75 | println!("cargo:rerun-if-env-changed=ANDROID_NATIVE_API_LEVEL"); 76 | println!("cargo:rerun-if-env-changed=NDK_HOME"); 77 | println!("cargo:rustc-link-search=native={}/build", dst.display()); 78 | 79 | let link_type = match env::var("CARGO_FEATURE_DYNAMIC") { 80 | Ok(_) => "dylib", 81 | _ => "static" 82 | }; 83 | println!("cargo:rustc-link-lib={}=common", link_type); 84 | println!("cargo:rustc-link-lib={}=openal", link_type); 85 | } 86 | 87 | fn main() { 88 | let target = &*env::var("TARGET").unwrap(); 89 | match target { 90 | "aarch64-linux-android" 91 | | "armv7-linux-androideabi" 92 | | "arm-linux-androideabi" 93 | | "thumbv7neon-linux-androideabi" 94 | | "i686-linux-android" 95 | | "x86_64-linux-android" => { 96 | let repo_path = clone_openalsoft(); 97 | build_openalsoft(repo_path) 98 | }, 99 | _ => {} 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /al-sys/src/al.rs: -------------------------------------------------------------------------------- 1 | /* automatically generated by rust-bindgen */ 2 | 3 | #![allow(dead_code, 4 | non_camel_case_types, 5 | non_upper_case_globals, 6 | non_snake_case)] 7 | pub const AL_INVALID: ::std::os::raw::c_int = -1; 8 | pub const AL_NONE: ::std::os::raw::c_int = 0; 9 | pub const AL_FALSE: ::std::os::raw::c_char = 0; 10 | pub const AL_TRUE: ::std::os::raw::c_char = 1; 11 | pub const AL_SOURCE_RELATIVE: ::std::os::raw::c_int = 514; 12 | pub const AL_CONE_INNER_ANGLE: ::std::os::raw::c_int = 4097; 13 | pub const AL_CONE_OUTER_ANGLE: ::std::os::raw::c_int = 4098; 14 | pub const AL_PITCH: ::std::os::raw::c_int = 4099; 15 | pub const AL_POSITION: ::std::os::raw::c_int = 4100; 16 | pub const AL_DIRECTION: ::std::os::raw::c_int = 4101; 17 | pub const AL_VELOCITY: ::std::os::raw::c_int = 4102; 18 | pub const AL_LOOPING: ::std::os::raw::c_int = 4103; 19 | pub const AL_BUFFER: ::std::os::raw::c_int = 4105; 20 | pub const AL_GAIN: ::std::os::raw::c_int = 4106; 21 | pub const AL_MIN_GAIN: ::std::os::raw::c_int = 4109; 22 | pub const AL_MAX_GAIN: ::std::os::raw::c_int = 4110; 23 | pub const AL_ORIENTATION: ::std::os::raw::c_int = 4111; 24 | pub const AL_SOURCE_STATE: ::std::os::raw::c_int = 4112; 25 | pub const AL_INITIAL: ::std::os::raw::c_int = 4113; 26 | pub const AL_PLAYING: ::std::os::raw::c_int = 4114; 27 | pub const AL_PAUSED: ::std::os::raw::c_int = 4115; 28 | pub const AL_STOPPED: ::std::os::raw::c_int = 4116; 29 | pub const AL_BUFFERS_QUEUED: ::std::os::raw::c_int = 4117; 30 | pub const AL_BUFFERS_PROCESSED: ::std::os::raw::c_int = 4118; 31 | pub const AL_REFERENCE_DISTANCE: ::std::os::raw::c_int = 4128; 32 | pub const AL_ROLLOFF_FACTOR: ::std::os::raw::c_int = 4129; 33 | pub const AL_CONE_OUTER_GAIN: ::std::os::raw::c_int = 4130; 34 | pub const AL_MAX_DISTANCE: ::std::os::raw::c_int = 4131; 35 | pub const AL_SEC_OFFSET: ::std::os::raw::c_int = 4132; 36 | pub const AL_SAMPLE_OFFSET: ::std::os::raw::c_int = 4133; 37 | pub const AL_BYTE_OFFSET: ::std::os::raw::c_int = 4134; 38 | pub const AL_SOURCE_TYPE: ::std::os::raw::c_int = 4135; 39 | pub const AL_STATIC: ::std::os::raw::c_int = 4136; 40 | pub const AL_STREAMING: ::std::os::raw::c_int = 4137; 41 | pub const AL_UNDETERMINED: ::std::os::raw::c_int = 4144; 42 | pub const AL_FORMAT_MONO8: ::std::os::raw::c_int = 4352; 43 | pub const AL_FORMAT_MONO16: ::std::os::raw::c_int = 4353; 44 | pub const AL_FORMAT_STEREO8: ::std::os::raw::c_int = 4354; 45 | pub const AL_FORMAT_STEREO16: ::std::os::raw::c_int = 4355; 46 | pub const AL_FREQUENCY: ::std::os::raw::c_int = 8193; 47 | pub const AL_BITS: ::std::os::raw::c_int = 8194; 48 | pub const AL_CHANNELS: ::std::os::raw::c_int = 8195; 49 | pub const AL_SIZE: ::std::os::raw::c_int = 8196; 50 | pub const AL_UNUSED: ::std::os::raw::c_int = 8208; 51 | pub const AL_PENDING: ::std::os::raw::c_int = 8209; 52 | pub const AL_PROCESSED: ::std::os::raw::c_int = 8210; 53 | pub const AL_NO_ERROR: ::std::os::raw::c_int = 0; 54 | pub const AL_INVALID_NAME: ::std::os::raw::c_int = 40961; 55 | pub const AL_INVALID_ENUM: ::std::os::raw::c_int = 40962; 56 | pub const AL_INVALID_VALUE: ::std::os::raw::c_int = 40963; 57 | pub const AL_INVALID_OPERATION: ::std::os::raw::c_int = 40964; 58 | pub const AL_OUT_OF_MEMORY: ::std::os::raw::c_int = 40965; 59 | pub const AL_VENDOR: ::std::os::raw::c_int = 45057; 60 | pub const AL_VERSION: ::std::os::raw::c_int = 45058; 61 | pub const AL_RENDERER: ::std::os::raw::c_int = 45059; 62 | pub const AL_EXTENSIONS: ::std::os::raw::c_int = 45060; 63 | pub const AL_DOPPLER_FACTOR: ::std::os::raw::c_int = 49152; 64 | pub const AL_DOPPLER_VELOCITY: ::std::os::raw::c_int = 49153; 65 | pub const AL_SPEED_OF_SOUND: ::std::os::raw::c_int = 49155; 66 | pub const AL_DISTANCE_MODEL: ::std::os::raw::c_int = 53248; 67 | pub const AL_INVERSE_DISTANCE: ::std::os::raw::c_int = 53249; 68 | pub const AL_INVERSE_DISTANCE_CLAMPED: ::std::os::raw::c_int = 53250; 69 | pub const AL_LINEAR_DISTANCE: ::std::os::raw::c_int = 53251; 70 | pub const AL_LINEAR_DISTANCE_CLAMPED: ::std::os::raw::c_int = 53252; 71 | pub const AL_EXPONENT_DISTANCE: ::std::os::raw::c_int = 53253; 72 | pub const AL_EXPONENT_DISTANCE_CLAMPED: ::std::os::raw::c_int = 53254; 73 | pub type ALboolean = ::std::os::raw::c_char; 74 | pub type ALchar = ::std::os::raw::c_char; 75 | pub type ALbyte = ::std::os::raw::c_char; 76 | pub type ALubyte = ::std::os::raw::c_uchar; 77 | pub type ALshort = ::std::os::raw::c_short; 78 | pub type ALushort = ::std::os::raw::c_ushort; 79 | pub type ALint = ::std::os::raw::c_int; 80 | pub type ALuint = ::std::os::raw::c_uint; 81 | pub type ALsizei = ::std::os::raw::c_int; 82 | pub type ALenum = ::std::os::raw::c_int; 83 | pub type ALfloat = f32; 84 | pub type ALdouble = f64; 85 | pub type ALvoid = ::std::os::raw::c_void; 86 | pub type LPALENABLE = 87 | ::std::option::Option; 88 | pub type LPALDISABLE = 89 | ::std::option::Option; 90 | pub type LPALISENABLED = 91 | ::std::option::Option ALboolean>; 92 | pub type LPALGETSTRING = 93 | ::std::option::Option *const ALchar>; 94 | pub type LPALGETBOOLEANV = 95 | ::std::option::Option; 97 | pub type LPALGETINTEGERV = 98 | ::std::option::Option; 100 | pub type LPALGETFLOATV = 101 | ::std::option::Option; 103 | pub type LPALGETDOUBLEV = 104 | ::std::option::Option; 106 | pub type LPALGETBOOLEAN = 107 | ::std::option::Option ALboolean>; 108 | pub type LPALGETINTEGER = 109 | ::std::option::Option ALint>; 110 | pub type LPALGETFLOAT = 111 | ::std::option::Option ALfloat>; 112 | pub type LPALGETDOUBLE = 113 | ::std::option::Option ALdouble>; 114 | pub type LPALGETERROR = ::std::option::Option ALenum>; 115 | pub type LPALISEXTENSIONPRESENT = 116 | ::std::option::Option ALboolean>; 118 | pub type LPALGETPROCADDRESS = 119 | ::std::option::Option *mut ::std::os::raw::c_void>; 121 | pub type LPALGETENUMVALUE = 122 | ::std::option::Option ALenum>; 124 | pub type LPALLISTENERF = 125 | ::std::option::Option; 126 | pub type LPALLISTENER3F = 127 | ::std::option::Option; 129 | pub type LPALLISTENERFV = 130 | ::std::option::Option; 132 | pub type LPALLISTENERI = 133 | ::std::option::Option; 134 | pub type LPALLISTENER3I = 135 | ::std::option::Option; 137 | pub type LPALLISTENERIV = 138 | ::std::option::Option; 140 | pub type LPALGETLISTENERF = 141 | ::std::option::Option; 143 | pub type LPALGETLISTENER3F = 144 | ::std::option::Option; 148 | pub type LPALGETLISTENERFV = 149 | ::std::option::Option; 151 | pub type LPALGETLISTENERI = 152 | ::std::option::Option; 154 | pub type LPALGETLISTENER3I = 155 | ::std::option::Option; 159 | pub type LPALGETLISTENERIV = 160 | ::std::option::Option; 162 | pub type LPALGENSOURCES = 163 | ::std::option::Option; 165 | pub type LPALDELETESOURCES = 166 | ::std::option::Option; 168 | pub type LPALISSOURCE = 169 | ::std::option::Option ALboolean>; 170 | pub type LPALSOURCEF = 171 | ::std::option::Option; 173 | pub type LPALSOURCE3F = 174 | ::std::option::Option; 177 | pub type LPALSOURCEFV = 178 | ::std::option::Option; 180 | pub type LPALSOURCEI = 181 | ::std::option::Option; 183 | pub type LPALSOURCE3I = 184 | ::std::option::Option; 187 | pub type LPALSOURCEIV = 188 | ::std::option::Option; 190 | pub type LPALGETSOURCEF = 191 | ::std::option::Option; 193 | pub type LPALGETSOURCE3F = 194 | ::std::option::Option; 198 | pub type LPALGETSOURCEFV = 199 | ::std::option::Option; 201 | pub type LPALGETSOURCEI = 202 | ::std::option::Option; 204 | pub type LPALGETSOURCE3I = 205 | ::std::option::Option; 209 | pub type LPALGETSOURCEIV = 210 | ::std::option::Option; 212 | pub type LPALSOURCEPLAYV = 213 | ::std::option::Option; 215 | pub type LPALSOURCESTOPV = 216 | ::std::option::Option; 218 | pub type LPALSOURCEREWINDV = 219 | ::std::option::Option; 221 | pub type LPALSOURCEPAUSEV = 222 | ::std::option::Option; 224 | pub type LPALSOURCEPLAY = 225 | ::std::option::Option; 226 | pub type LPALSOURCESTOP = 227 | ::std::option::Option; 228 | pub type LPALSOURCEREWIND = 229 | ::std::option::Option; 230 | pub type LPALSOURCEPAUSE = 231 | ::std::option::Option; 232 | pub type LPALSOURCEQUEUEBUFFERS = 233 | ::std::option::Option; 235 | pub type LPALSOURCEUNQUEUEBUFFERS = 236 | ::std::option::Option; 238 | pub type LPALGENBUFFERS = 239 | ::std::option::Option; 241 | pub type LPALDELETEBUFFERS = 242 | ::std::option::Option; 244 | pub type LPALISBUFFER = 245 | ::std::option::Option ALboolean>; 246 | pub type LPALBUFFERDATA = 247 | ::std::option::Option; 250 | pub type LPALBUFFERF = 251 | ::std::option::Option; 253 | pub type LPALBUFFER3F = 254 | ::std::option::Option; 257 | pub type LPALBUFFERFV = 258 | ::std::option::Option; 260 | pub type LPALBUFFERI = 261 | ::std::option::Option; 263 | pub type LPALBUFFER3I = 264 | ::std::option::Option; 267 | pub type LPALBUFFERIV = 268 | ::std::option::Option; 270 | pub type LPALGETBUFFERF = 271 | ::std::option::Option; 273 | pub type LPALGETBUFFER3F = 274 | ::std::option::Option; 278 | pub type LPALGETBUFFERFV = 279 | ::std::option::Option; 281 | pub type LPALGETBUFFERI = 282 | ::std::option::Option; 284 | pub type LPALGETBUFFER3I = 285 | ::std::option::Option; 289 | pub type LPALGETBUFFERIV = 290 | ::std::option::Option; 292 | pub type LPALDOPPLERFACTOR = 293 | ::std::option::Option; 294 | pub type LPALDOPPLERVELOCITY = 295 | ::std::option::Option; 296 | pub type LPALSPEEDOFSOUND = 297 | ::std::option::Option; 298 | pub type LPALDISTANCEMODEL = 299 | ::std::option::Option; 300 | -------------------------------------------------------------------------------- /al-sys/src/alc.rs: -------------------------------------------------------------------------------- 1 | /* automatically generated by rust-bindgen */ 2 | 3 | #![allow(dead_code, 4 | non_camel_case_types, 5 | non_upper_case_globals, 6 | non_snake_case)] 7 | pub const ALC_INVALID: ::std::os::raw::c_int = 0; 8 | pub const ALC_VERSION_0_1: ::std::os::raw::c_int = 1; 9 | pub const ALC_FALSE: ::std::os::raw::c_char = 0; 10 | pub const ALC_TRUE: ::std::os::raw::c_char = 1; 11 | pub const ALC_FREQUENCY: ::std::os::raw::c_int = 4103; 12 | pub const ALC_REFRESH: ::std::os::raw::c_int = 4104; 13 | pub const ALC_SYNC: ::std::os::raw::c_int = 4105; 14 | pub const ALC_MONO_SOURCES: ::std::os::raw::c_int = 4112; 15 | pub const ALC_STEREO_SOURCES: ::std::os::raw::c_int = 4113; 16 | pub const ALC_NO_ERROR: ::std::os::raw::c_int = 0; 17 | pub const ALC_INVALID_DEVICE: ::std::os::raw::c_int = 40961; 18 | pub const ALC_INVALID_CONTEXT: ::std::os::raw::c_int = 40962; 19 | pub const ALC_INVALID_ENUM: ::std::os::raw::c_int = 40963; 20 | pub const ALC_INVALID_VALUE: ::std::os::raw::c_int = 40964; 21 | pub const ALC_OUT_OF_MEMORY: ::std::os::raw::c_int = 40965; 22 | pub const ALC_MAJOR_VERSION: ::std::os::raw::c_int = 4096; 23 | pub const ALC_MINOR_VERSION: ::std::os::raw::c_int = 4097; 24 | pub const ALC_ATTRIBUTES_SIZE: ::std::os::raw::c_int = 4098; 25 | pub const ALC_ALL_ATTRIBUTES: ::std::os::raw::c_int = 4099; 26 | pub const ALC_DEFAULT_DEVICE_SPECIFIER: ::std::os::raw::c_int = 4100; 27 | pub const ALC_DEVICE_SPECIFIER: ::std::os::raw::c_int = 4101; 28 | pub const ALC_EXTENSIONS: ::std::os::raw::c_int = 4102; 29 | pub const ALC_EXT_CAPTURE: ::std::os::raw::c_int = 1; 30 | pub const ALC_CAPTURE_DEVICE_SPECIFIER: ::std::os::raw::c_int = 784; 31 | pub const ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER: ::std::os::raw::c_int = 785; 32 | pub const ALC_CAPTURE_SAMPLES: ::std::os::raw::c_int = 786; 33 | pub const ALC_ENUMERATE_ALL_EXT: ::std::os::raw::c_int = 1; 34 | pub const ALC_DEFAULT_ALL_DEVICES_SPECIFIER: ::std::os::raw::c_int = 4114; 35 | pub const ALC_ALL_DEVICES_SPECIFIER: ::std::os::raw::c_int = 4115; 36 | pub struct ALCdevice_struct { _priv: () } 37 | pub type ALCdevice = ALCdevice_struct; 38 | pub struct ALCcontext_struct { _priv: () } 39 | pub type ALCcontext = ALCcontext_struct; 40 | pub type ALCboolean = ::std::os::raw::c_char; 41 | pub type ALCchar = ::std::os::raw::c_char; 42 | pub type ALCbyte = ::std::os::raw::c_char; 43 | pub type ALCubyte = ::std::os::raw::c_uchar; 44 | pub type ALCshort = ::std::os::raw::c_short; 45 | pub type ALCushort = ::std::os::raw::c_ushort; 46 | pub type ALCint = ::std::os::raw::c_int; 47 | pub type ALCuint = ::std::os::raw::c_uint; 48 | pub type ALCsizei = ::std::os::raw::c_int; 49 | pub type ALCenum = ::std::os::raw::c_int; 50 | pub type ALCfloat = f32; 51 | pub type ALCdouble = f64; 52 | pub type ALCvoid = ::std::os::raw::c_void; 53 | pub type LPALCCREATECONTEXT = 54 | ::std::option::Option *mut ALCcontext>; 57 | pub type LPALCMAKECONTEXTCURRENT = 58 | ::std::option::Option ALCboolean>; 60 | pub type LPALCPROCESSCONTEXT = 61 | ::std::option::Option; 62 | pub type LPALCSUSPENDCONTEXT = 63 | ::std::option::Option; 64 | pub type LPALCDESTROYCONTEXT = 65 | ::std::option::Option; 66 | pub type LPALCGETCURRENTCONTEXT = 67 | ::std::option::Option *mut ALCcontext>; 68 | pub type LPALCGETCONTEXTSDEVICE = 69 | ::std::option::Option *mut ALCdevice>; 71 | pub type LPALCOPENDEVICE = 72 | ::std::option::Option *mut ALCdevice>; 74 | pub type LPALCCLOSEDEVICE = 75 | ::std::option::Option ALCboolean>; 77 | pub type LPALCGETERROR = 78 | ::std::option::Option ALCenum>; 80 | pub type LPALCISEXTENSIONPRESENT = 81 | ::std::option::Option ALCboolean>; 84 | pub type LPALCGETPROCADDRESS = 85 | ::std::option::Option *mut ::std::os::raw::c_void>; 88 | pub type LPALCGETENUMVALUE = 89 | ::std::option::Option ALCenum>; 92 | pub type LPALCGETSTRING = 93 | ::std::option::Option *const ALCchar>; 96 | pub type LPALCGETINTEGERV = 97 | ::std::option::Option; 100 | pub type LPALCCAPTUREOPENDEVICE = 101 | ::std::option::Option *mut ALCdevice>; 106 | pub type LPALCCAPTURECLOSEDEVICE = 107 | ::std::option::Option ALCboolean>; 109 | pub type LPALCCAPTURESTART = 110 | ::std::option::Option; 111 | pub type LPALCCAPTURESTOP = 112 | ::std::option::Option; 113 | pub type LPALCCAPTURESAMPLES = 114 | ::std::option::Option; 117 | -------------------------------------------------------------------------------- /al-sys/src/efx.rs: -------------------------------------------------------------------------------- 1 | /* automatically generated by rust-bindgen */ 2 | 3 | #![allow(dead_code, 4 | non_camel_case_types, 5 | non_upper_case_globals, 6 | non_snake_case)] 7 | 8 | use al::*; 9 | 10 | pub const ALC_EFX_MAJOR_VERSION: ::std::os::raw::c_uint = 131073; 11 | pub const ALC_EFX_MINOR_VERSION: ::std::os::raw::c_uint = 131074; 12 | pub const ALC_MAX_AUXILIARY_SENDS: ::std::os::raw::c_uint = 131075; 13 | pub const AL_METERS_PER_UNIT: ::std::os::raw::c_uint = 131076; 14 | pub const AL_DIRECT_FILTER: ::std::os::raw::c_uint = 131077; 15 | pub const AL_AUXILIARY_SEND_FILTER: ::std::os::raw::c_uint = 131078; 16 | pub const AL_AIR_ABSORPTION_FACTOR: ::std::os::raw::c_uint = 131079; 17 | pub const AL_ROOM_ROLLOFF_FACTOR: ::std::os::raw::c_uint = 131080; 18 | pub const AL_CONE_OUTER_GAINHF: ::std::os::raw::c_uint = 131081; 19 | pub const AL_DIRECT_FILTER_GAINHF_AUTO: ::std::os::raw::c_uint = 131082; 20 | pub const AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: ::std::os::raw::c_uint = 131083; 21 | pub const AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: ::std::os::raw::c_uint = 22 | 131084; 23 | pub const AL_REVERB_DENSITY: ::std::os::raw::c_int = 1; 24 | pub const AL_REVERB_DIFFUSION: ::std::os::raw::c_int = 2; 25 | pub const AL_REVERB_GAIN: ::std::os::raw::c_int = 3; 26 | pub const AL_REVERB_GAINHF: ::std::os::raw::c_int = 4; 27 | pub const AL_REVERB_DECAY_TIME: ::std::os::raw::c_int = 5; 28 | pub const AL_REVERB_DECAY_HFRATIO: ::std::os::raw::c_int = 6; 29 | pub const AL_REVERB_REFLECTIONS_GAIN: ::std::os::raw::c_int = 7; 30 | pub const AL_REVERB_REFLECTIONS_DELAY: ::std::os::raw::c_int = 8; 31 | pub const AL_REVERB_LATE_REVERB_GAIN: ::std::os::raw::c_int = 9; 32 | pub const AL_REVERB_LATE_REVERB_DELAY: ::std::os::raw::c_int = 10; 33 | pub const AL_REVERB_AIR_ABSORPTION_GAINHF: ::std::os::raw::c_int = 11; 34 | pub const AL_REVERB_ROOM_ROLLOFF_FACTOR: ::std::os::raw::c_int = 12; 35 | pub const AL_REVERB_DECAY_HFLIMIT: ::std::os::raw::c_int = 13; 36 | pub const AL_EAXREVERB_DENSITY: ::std::os::raw::c_int = 1; 37 | pub const AL_EAXREVERB_DIFFUSION: ::std::os::raw::c_int = 2; 38 | pub const AL_EAXREVERB_GAIN: ::std::os::raw::c_int = 3; 39 | pub const AL_EAXREVERB_GAINHF: ::std::os::raw::c_int = 4; 40 | pub const AL_EAXREVERB_GAINLF: ::std::os::raw::c_int = 5; 41 | pub const AL_EAXREVERB_DECAY_TIME: ::std::os::raw::c_int = 6; 42 | pub const AL_EAXREVERB_DECAY_HFRATIO: ::std::os::raw::c_int = 7; 43 | pub const AL_EAXREVERB_DECAY_LFRATIO: ::std::os::raw::c_int = 8; 44 | pub const AL_EAXREVERB_REFLECTIONS_GAIN: ::std::os::raw::c_int = 9; 45 | pub const AL_EAXREVERB_REFLECTIONS_DELAY: ::std::os::raw::c_int = 10; 46 | pub const AL_EAXREVERB_REFLECTIONS_PAN: ::std::os::raw::c_int = 11; 47 | pub const AL_EAXREVERB_LATE_REVERB_GAIN: ::std::os::raw::c_int = 12; 48 | pub const AL_EAXREVERB_LATE_REVERB_DELAY: ::std::os::raw::c_int = 13; 49 | pub const AL_EAXREVERB_LATE_REVERB_PAN: ::std::os::raw::c_int = 14; 50 | pub const AL_EAXREVERB_ECHO_TIME: ::std::os::raw::c_int = 15; 51 | pub const AL_EAXREVERB_ECHO_DEPTH: ::std::os::raw::c_int = 16; 52 | pub const AL_EAXREVERB_MODULATION_TIME: ::std::os::raw::c_int = 17; 53 | pub const AL_EAXREVERB_MODULATION_DEPTH: ::std::os::raw::c_int = 18; 54 | pub const AL_EAXREVERB_AIR_ABSORPTION_GAINHF: ::std::os::raw::c_int = 19; 55 | pub const AL_EAXREVERB_HFREFERENCE: ::std::os::raw::c_int = 20; 56 | pub const AL_EAXREVERB_LFREFERENCE: ::std::os::raw::c_int = 21; 57 | pub const AL_EAXREVERB_ROOM_ROLLOFF_FACTOR: ::std::os::raw::c_int = 22; 58 | pub const AL_EAXREVERB_DECAY_HFLIMIT: ::std::os::raw::c_int = 23; 59 | pub const AL_CHORUS_WAVEFORM: ::std::os::raw::c_int = 1; 60 | pub const AL_CHORUS_PHASE: ::std::os::raw::c_int = 2; 61 | pub const AL_CHORUS_RATE: ::std::os::raw::c_int = 3; 62 | pub const AL_CHORUS_DEPTH: ::std::os::raw::c_int = 4; 63 | pub const AL_CHORUS_FEEDBACK: ::std::os::raw::c_int = 5; 64 | pub const AL_CHORUS_DELAY: ::std::os::raw::c_int = 6; 65 | pub const AL_DISTORTION_EDGE: ::std::os::raw::c_int = 1; 66 | pub const AL_DISTORTION_GAIN: ::std::os::raw::c_int = 2; 67 | pub const AL_DISTORTION_LOWPASS_CUTOFF: ::std::os::raw::c_int = 3; 68 | pub const AL_DISTORTION_EQCENTER: ::std::os::raw::c_int = 4; 69 | pub const AL_DISTORTION_EQBANDWIDTH: ::std::os::raw::c_int = 5; 70 | pub const AL_ECHO_DELAY: ::std::os::raw::c_int = 1; 71 | pub const AL_ECHO_LRDELAY: ::std::os::raw::c_int = 2; 72 | pub const AL_ECHO_DAMPING: ::std::os::raw::c_int = 3; 73 | pub const AL_ECHO_FEEDBACK: ::std::os::raw::c_int = 4; 74 | pub const AL_ECHO_SPREAD: ::std::os::raw::c_int = 5; 75 | pub const AL_FLANGER_WAVEFORM: ::std::os::raw::c_int = 1; 76 | pub const AL_FLANGER_PHASE: ::std::os::raw::c_int = 2; 77 | pub const AL_FLANGER_RATE: ::std::os::raw::c_int = 3; 78 | pub const AL_FLANGER_DEPTH: ::std::os::raw::c_int = 4; 79 | pub const AL_FLANGER_FEEDBACK: ::std::os::raw::c_int = 5; 80 | pub const AL_FLANGER_DELAY: ::std::os::raw::c_int = 6; 81 | pub const AL_FREQUENCY_SHIFTER_FREQUENCY: ::std::os::raw::c_int = 1; 82 | pub const AL_FREQUENCY_SHIFTER_LEFT_DIRECTION: ::std::os::raw::c_int = 2; 83 | pub const AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION: ::std::os::raw::c_int = 3; 84 | pub const AL_VOCAL_MORPHER_PHONEMEA: ::std::os::raw::c_int = 1; 85 | pub const AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING: ::std::os::raw::c_int = 2; 86 | pub const AL_VOCAL_MORPHER_PHONEMEB: ::std::os::raw::c_int = 3; 87 | pub const AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING: ::std::os::raw::c_int = 4; 88 | pub const AL_VOCAL_MORPHER_WAVEFORM: ::std::os::raw::c_int = 5; 89 | pub const AL_VOCAL_MORPHER_RATE: ::std::os::raw::c_int = 6; 90 | pub const AL_PITCH_SHIFTER_COARSE_TUNE: ::std::os::raw::c_int = 1; 91 | pub const AL_PITCH_SHIFTER_FINE_TUNE: ::std::os::raw::c_int = 2; 92 | pub const AL_RING_MODULATOR_FREQUENCY: ::std::os::raw::c_int = 1; 93 | pub const AL_RING_MODULATOR_HIGHPASS_CUTOFF: ::std::os::raw::c_int = 2; 94 | pub const AL_RING_MODULATOR_WAVEFORM: ::std::os::raw::c_int = 3; 95 | pub const AL_AUTOWAH_ATTACK_TIME: ::std::os::raw::c_int = 1; 96 | pub const AL_AUTOWAH_RELEASE_TIME: ::std::os::raw::c_int = 2; 97 | pub const AL_AUTOWAH_RESONANCE: ::std::os::raw::c_int = 3; 98 | pub const AL_AUTOWAH_PEAK_GAIN: ::std::os::raw::c_int = 4; 99 | pub const AL_COMPRESSOR_ONOFF: ::std::os::raw::c_int = 1; 100 | pub const AL_EQUALIZER_LOW_GAIN: ::std::os::raw::c_int = 1; 101 | pub const AL_EQUALIZER_LOW_CUTOFF: ::std::os::raw::c_int = 2; 102 | pub const AL_EQUALIZER_MID1_GAIN: ::std::os::raw::c_int = 3; 103 | pub const AL_EQUALIZER_MID1_CENTER: ::std::os::raw::c_int = 4; 104 | pub const AL_EQUALIZER_MID1_WIDTH: ::std::os::raw::c_int = 5; 105 | pub const AL_EQUALIZER_MID2_GAIN: ::std::os::raw::c_int = 6; 106 | pub const AL_EQUALIZER_MID2_CENTER: ::std::os::raw::c_int = 7; 107 | pub const AL_EQUALIZER_MID2_WIDTH: ::std::os::raw::c_int = 8; 108 | pub const AL_EQUALIZER_HIGH_GAIN: ::std::os::raw::c_int = 9; 109 | pub const AL_EQUALIZER_HIGH_CUTOFF: ::std::os::raw::c_int = 10; 110 | pub const AL_EFFECT_FIRST_PARAMETER: ::std::os::raw::c_int = 0; 111 | pub const AL_EFFECT_LAST_PARAMETER: ::std::os::raw::c_int = 32768; 112 | pub const AL_EFFECT_TYPE: ::std::os::raw::c_int = 32769; 113 | pub const AL_EFFECT_NULL: ::std::os::raw::c_int = 0; 114 | pub const AL_EFFECT_REVERB: ::std::os::raw::c_int = 1; 115 | pub const AL_EFFECT_CHORUS: ::std::os::raw::c_int = 2; 116 | pub const AL_EFFECT_DISTORTION: ::std::os::raw::c_int = 3; 117 | pub const AL_EFFECT_ECHO: ::std::os::raw::c_int = 4; 118 | pub const AL_EFFECT_FLANGER: ::std::os::raw::c_int = 5; 119 | pub const AL_EFFECT_FREQUENCY_SHIFTER: ::std::os::raw::c_int = 6; 120 | pub const AL_EFFECT_VOCAL_MORPHER: ::std::os::raw::c_int = 7; 121 | pub const AL_EFFECT_PITCH_SHIFTER: ::std::os::raw::c_int = 8; 122 | pub const AL_EFFECT_RING_MODULATOR: ::std::os::raw::c_int = 9; 123 | pub const AL_EFFECT_AUTOWAH: ::std::os::raw::c_int = 10; 124 | pub const AL_EFFECT_COMPRESSOR: ::std::os::raw::c_int = 11; 125 | pub const AL_EFFECT_EQUALIZER: ::std::os::raw::c_int = 12; 126 | pub const AL_EFFECT_EAXREVERB: ::std::os::raw::c_int = 32768; 127 | pub const AL_EFFECTSLOT_EFFECT: ::std::os::raw::c_int = 1; 128 | pub const AL_EFFECTSLOT_GAIN: ::std::os::raw::c_int = 2; 129 | pub const AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: ::std::os::raw::c_int = 3; 130 | pub const AL_EFFECTSLOT_NULL: ::std::os::raw::c_int = 0; 131 | pub const AL_LOWPASS_GAIN: ::std::os::raw::c_int = 1; 132 | pub const AL_LOWPASS_GAINHF: ::std::os::raw::c_int = 2; 133 | pub const AL_HIGHPASS_GAIN: ::std::os::raw::c_int = 1; 134 | pub const AL_HIGHPASS_GAINLF: ::std::os::raw::c_int = 2; 135 | pub const AL_BANDPASS_GAIN: ::std::os::raw::c_int = 1; 136 | pub const AL_BANDPASS_GAINLF: ::std::os::raw::c_int = 2; 137 | pub const AL_BANDPASS_GAINHF: ::std::os::raw::c_int = 3; 138 | pub const AL_FILTER_FIRST_PARAMETER: ::std::os::raw::c_int = 0; 139 | pub const AL_FILTER_LAST_PARAMETER: ::std::os::raw::c_int = 32768; 140 | pub const AL_FILTER_TYPE: ::std::os::raw::c_int = 32769; 141 | pub const AL_FILTER_NULL: ::std::os::raw::c_int = 0; 142 | pub const AL_FILTER_LOWPASS: ::std::os::raw::c_int = 1; 143 | pub const AL_FILTER_HIGHPASS: ::std::os::raw::c_int = 2; 144 | pub const AL_FILTER_BANDPASS: ::std::os::raw::c_int = 3; 145 | pub const AL_CHORUS_WAVEFORM_SINUSOID: ::std::os::raw::c_int = 0; 146 | pub const AL_CHORUS_WAVEFORM_TRIANGLE: ::std::os::raw::c_int = 1; 147 | pub const AL_CHORUS_MIN_WAVEFORM: ::std::os::raw::c_int = 0; 148 | pub const AL_CHORUS_MAX_WAVEFORM: ::std::os::raw::c_int = 1; 149 | pub const AL_CHORUS_DEFAULT_WAVEFORM: ::std::os::raw::c_int = 1; 150 | pub const AL_CHORUS_MIN_PHASE: ::std::os::raw::c_int = -180; 151 | pub const AL_CHORUS_MAX_PHASE: ::std::os::raw::c_int = 180; 152 | pub const AL_CHORUS_DEFAULT_PHASE: ::std::os::raw::c_int = 90; 153 | pub const AL_FLANGER_WAVEFORM_SINUSOID: ::std::os::raw::c_int = 0; 154 | pub const AL_FLANGER_WAVEFORM_TRIANGLE: ::std::os::raw::c_int = 1; 155 | pub const AL_FLANGER_MIN_WAVEFORM: ::std::os::raw::c_int = 0; 156 | pub const AL_FLANGER_MAX_WAVEFORM: ::std::os::raw::c_int = 1; 157 | pub const AL_FLANGER_DEFAULT_WAVEFORM: ::std::os::raw::c_int = 1; 158 | pub const AL_FLANGER_MIN_PHASE: ::std::os::raw::c_int = -180; 159 | pub const AL_FLANGER_MAX_PHASE: ::std::os::raw::c_int = 180; 160 | pub const AL_FLANGER_DEFAULT_PHASE: ::std::os::raw::c_int = 0; 161 | pub const AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION: ::std::os::raw::c_int = 0; 162 | pub const AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION: ::std::os::raw::c_int = 2; 163 | pub const AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION: ::std::os::raw::c_int = 164 | 0; 165 | pub const AL_FREQUENCY_SHIFTER_DIRECTION_DOWN: ::std::os::raw::c_int = 0; 166 | pub const AL_FREQUENCY_SHIFTER_DIRECTION_UP: ::std::os::raw::c_int = 1; 167 | pub const AL_FREQUENCY_SHIFTER_DIRECTION_OFF: ::std::os::raw::c_int = 2; 168 | pub const AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION: ::std::os::raw::c_int = 0; 169 | pub const AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION: ::std::os::raw::c_int = 2; 170 | pub const AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION: ::std::os::raw::c_int 171 | = 172 | 0; 173 | pub const AL_VOCAL_MORPHER_MIN_PHONEMEA: ::std::os::raw::c_int = 0; 174 | pub const AL_VOCAL_MORPHER_MAX_PHONEMEA: ::std::os::raw::c_int = 29; 175 | pub const AL_VOCAL_MORPHER_DEFAULT_PHONEMEA: ::std::os::raw::c_int = 0; 176 | pub const AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING: ::std::os::raw::c_int = 177 | -24; 178 | pub const AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING: ::std::os::raw::c_int = 179 | 24; 180 | pub const AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING: 181 | ::std::os::raw::c_int = 182 | 0; 183 | pub const AL_VOCAL_MORPHER_MIN_PHONEMEB: ::std::os::raw::c_int = 0; 184 | pub const AL_VOCAL_MORPHER_MAX_PHONEMEB: ::std::os::raw::c_int = 29; 185 | pub const AL_VOCAL_MORPHER_DEFAULT_PHONEMEB: ::std::os::raw::c_int = 10; 186 | pub const AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING: ::std::os::raw::c_int = 187 | -24; 188 | pub const AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING: ::std::os::raw::c_int = 189 | 24; 190 | pub const AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING: 191 | ::std::os::raw::c_int = 192 | 0; 193 | pub const AL_VOCAL_MORPHER_PHONEME_A: ::std::os::raw::c_int = 0; 194 | pub const AL_VOCAL_MORPHER_PHONEME_E: ::std::os::raw::c_int = 1; 195 | pub const AL_VOCAL_MORPHER_PHONEME_I: ::std::os::raw::c_int = 2; 196 | pub const AL_VOCAL_MORPHER_PHONEME_O: ::std::os::raw::c_int = 3; 197 | pub const AL_VOCAL_MORPHER_PHONEME_U: ::std::os::raw::c_int = 4; 198 | pub const AL_VOCAL_MORPHER_PHONEME_AA: ::std::os::raw::c_int = 5; 199 | pub const AL_VOCAL_MORPHER_PHONEME_AE: ::std::os::raw::c_int = 6; 200 | pub const AL_VOCAL_MORPHER_PHONEME_AH: ::std::os::raw::c_int = 7; 201 | pub const AL_VOCAL_MORPHER_PHONEME_AO: ::std::os::raw::c_int = 8; 202 | pub const AL_VOCAL_MORPHER_PHONEME_EH: ::std::os::raw::c_int = 9; 203 | pub const AL_VOCAL_MORPHER_PHONEME_ER: ::std::os::raw::c_int = 10; 204 | pub const AL_VOCAL_MORPHER_PHONEME_IH: ::std::os::raw::c_int = 11; 205 | pub const AL_VOCAL_MORPHER_PHONEME_IY: ::std::os::raw::c_int = 12; 206 | pub const AL_VOCAL_MORPHER_PHONEME_UH: ::std::os::raw::c_int = 13; 207 | pub const AL_VOCAL_MORPHER_PHONEME_UW: ::std::os::raw::c_int = 14; 208 | pub const AL_VOCAL_MORPHER_PHONEME_B: ::std::os::raw::c_int = 15; 209 | pub const AL_VOCAL_MORPHER_PHONEME_D: ::std::os::raw::c_int = 16; 210 | pub const AL_VOCAL_MORPHER_PHONEME_F: ::std::os::raw::c_int = 17; 211 | pub const AL_VOCAL_MORPHER_PHONEME_G: ::std::os::raw::c_int = 18; 212 | pub const AL_VOCAL_MORPHER_PHONEME_J: ::std::os::raw::c_int = 19; 213 | pub const AL_VOCAL_MORPHER_PHONEME_K: ::std::os::raw::c_int = 20; 214 | pub const AL_VOCAL_MORPHER_PHONEME_L: ::std::os::raw::c_int = 21; 215 | pub const AL_VOCAL_MORPHER_PHONEME_M: ::std::os::raw::c_int = 22; 216 | pub const AL_VOCAL_MORPHER_PHONEME_N: ::std::os::raw::c_int = 23; 217 | pub const AL_VOCAL_MORPHER_PHONEME_P: ::std::os::raw::c_int = 24; 218 | pub const AL_VOCAL_MORPHER_PHONEME_R: ::std::os::raw::c_int = 25; 219 | pub const AL_VOCAL_MORPHER_PHONEME_S: ::std::os::raw::c_int = 26; 220 | pub const AL_VOCAL_MORPHER_PHONEME_T: ::std::os::raw::c_int = 27; 221 | pub const AL_VOCAL_MORPHER_PHONEME_V: ::std::os::raw::c_int = 28; 222 | pub const AL_VOCAL_MORPHER_PHONEME_Z: ::std::os::raw::c_int = 29; 223 | pub const AL_VOCAL_MORPHER_WAVEFORM_SINUSOID: ::std::os::raw::c_int = 0; 224 | pub const AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE: ::std::os::raw::c_int = 1; 225 | pub const AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH: ::std::os::raw::c_int = 2; 226 | pub const AL_VOCAL_MORPHER_MIN_WAVEFORM: ::std::os::raw::c_int = 0; 227 | pub const AL_VOCAL_MORPHER_MAX_WAVEFORM: ::std::os::raw::c_int = 2; 228 | pub const AL_VOCAL_MORPHER_DEFAULT_WAVEFORM: ::std::os::raw::c_int = 0; 229 | pub const AL_PITCH_SHIFTER_MIN_COARSE_TUNE: ::std::os::raw::c_int = -12; 230 | pub const AL_PITCH_SHIFTER_MAX_COARSE_TUNE: ::std::os::raw::c_int = 12; 231 | pub const AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE: ::std::os::raw::c_int = 12; 232 | pub const AL_PITCH_SHIFTER_MIN_FINE_TUNE: ::std::os::raw::c_int = -50; 233 | pub const AL_PITCH_SHIFTER_MAX_FINE_TUNE: ::std::os::raw::c_int = 50; 234 | pub const AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE: ::std::os::raw::c_int = 0; 235 | pub const AL_RING_MODULATOR_SINUSOID: ::std::os::raw::c_int = 0; 236 | pub const AL_RING_MODULATOR_SAWTOOTH: ::std::os::raw::c_int = 1; 237 | pub const AL_RING_MODULATOR_SQUARE: ::std::os::raw::c_int = 2; 238 | pub const AL_RING_MODULATOR_MIN_WAVEFORM: ::std::os::raw::c_int = 0; 239 | pub const AL_RING_MODULATOR_MAX_WAVEFORM: ::std::os::raw::c_int = 2; 240 | pub const AL_RING_MODULATOR_DEFAULT_WAVEFORM: ::std::os::raw::c_int = 0; 241 | pub const AL_COMPRESSOR_MIN_ONOFF: ::std::os::raw::c_int = 0; 242 | pub const AL_COMPRESSOR_MAX_ONOFF: ::std::os::raw::c_int = 1; 243 | pub const AL_COMPRESSOR_DEFAULT_ONOFF: ::std::os::raw::c_int = 1; 244 | pub type LPALGENEFFECTS = 245 | ::std::option::Option; 247 | pub type LPALDELETEEFFECTS = 248 | ::std::option::Option; 250 | pub type LPALISEFFECT = 251 | ::std::option::Option ALboolean>; 252 | pub type LPALEFFECTI = 253 | ::std::option::Option; 255 | pub type LPALEFFECTIV = 256 | ::std::option::Option; 258 | pub type LPALEFFECTF = 259 | ::std::option::Option; 261 | pub type LPALEFFECTFV = 262 | ::std::option::Option; 264 | pub type LPALGETEFFECTI = 265 | ::std::option::Option; 267 | pub type LPALGETEFFECTIV = 268 | ::std::option::Option; 270 | pub type LPALGETEFFECTF = 271 | ::std::option::Option; 273 | pub type LPALGETEFFECTFV = 274 | ::std::option::Option; 276 | pub type LPALGENFILTERS = 277 | ::std::option::Option; 279 | pub type LPALDELETEFILTERS = 280 | ::std::option::Option; 282 | pub type LPALISFILTER = 283 | ::std::option::Option ALboolean>; 284 | pub type LPALFILTERI = 285 | ::std::option::Option; 287 | pub type LPALFILTERIV = 288 | ::std::option::Option; 290 | pub type LPALFILTERF = 291 | ::std::option::Option; 293 | pub type LPALFILTERFV = 294 | ::std::option::Option; 296 | pub type LPALGETFILTERI = 297 | ::std::option::Option; 299 | pub type LPALGETFILTERIV = 300 | ::std::option::Option; 302 | pub type LPALGETFILTERF = 303 | ::std::option::Option; 305 | pub type LPALGETFILTERFV = 306 | ::std::option::Option; 308 | pub type LPALGENAUXILIARYEFFECTSLOTS = 309 | ::std::option::Option; 311 | pub type LPALDELETEAUXILIARYEFFECTSLOTS = 312 | ::std::option::Option; 314 | pub type LPALISAUXILIARYEFFECTSLOT = 315 | ::std::option::Option ALboolean>; 316 | pub type LPALAUXILIARYEFFECTSLOTI = 317 | ::std::option::Option; 319 | pub type LPALAUXILIARYEFFECTSLOTIV = 320 | ::std::option::Option; 322 | pub type LPALAUXILIARYEFFECTSLOTF = 323 | ::std::option::Option; 325 | pub type LPALAUXILIARYEFFECTSLOTFV = 326 | ::std::option::Option; 328 | pub type LPALGETAUXILIARYEFFECTSLOTI = 329 | ::std::option::Option; 331 | pub type LPALGETAUXILIARYEFFECTSLOTIV = 332 | ::std::option::Option; 334 | pub type LPALGETAUXILIARYEFFECTSLOTF = 335 | ::std::option::Option; 337 | pub type LPALGETAUXILIARYEFFECTSLOTFV = 338 | ::std::option::Option; 340 | -------------------------------------------------------------------------------- /al-sys/src/efx_presets.rs: -------------------------------------------------------------------------------- 1 | /* automatically generated by rust-bindgen */ 2 | 3 | #![allow(dead_code, 4 | non_camel_case_types, 5 | non_upper_case_globals, 6 | non_snake_case)] 7 | #[repr(C)] 8 | #[derive(Copy, Clone)] 9 | #[derive(Debug)] 10 | pub struct EFXEAXREVERBPROPERTIES { 11 | pub flDensity: f32, 12 | pub flDiffusion: f32, 13 | pub flGain: f32, 14 | pub flGainHF: f32, 15 | pub flGainLF: f32, 16 | pub flDecayTime: f32, 17 | pub flDecayHFRatio: f32, 18 | pub flDecayLFRatio: f32, 19 | pub flReflectionsGain: f32, 20 | pub flReflectionsDelay: f32, 21 | pub flReflectionsPan: [f32; 3usize], 22 | pub flLateReverbGain: f32, 23 | pub flLateReverbDelay: f32, 24 | pub flLateReverbPan: [f32; 3usize], 25 | pub flEchoTime: f32, 26 | pub flEchoDepth: f32, 27 | pub flModulationTime: f32, 28 | pub flModulationDepth: f32, 29 | pub flAirAbsorptionGainHF: f32, 30 | pub flHFReference: f32, 31 | pub flLFReference: f32, 32 | pub flRoomRolloffFactor: f32, 33 | pub iDecayHFLimit: ::std::os::raw::c_int, 34 | } 35 | impl ::std::default::Default for EFXEAXREVERBPROPERTIES { 36 | fn default() -> Self { unsafe { ::std::mem::zeroed() } } 37 | } 38 | pub type LPEFXEAXREVERBPROPERTIES = *mut EFXEAXREVERBPROPERTIES; 39 | -------------------------------------------------------------------------------- /al-sys/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(all(not(target_os = "emscripten"), feature = "dynamic"))] 2 | #[macro_use] 3 | extern crate rental; 4 | 5 | 6 | mod alc; 7 | mod al; 8 | mod efx; 9 | mod efx_presets; 10 | 11 | pub use alc::*; 12 | pub use al::*; 13 | pub use efx::*; 14 | pub use efx_presets::*; 15 | 16 | 17 | #[cfg(all(not(target_os = "emscripten"), feature = "dynamic"))] 18 | macro_rules! al_api { 19 | { 20 | $($sym:ident: unsafe extern "C" fn ($($param:ident: $param_ty:ty),*) -> $ret_ty:ty,)* 21 | } => { 22 | mod al_api { 23 | extern crate libloading; 24 | 25 | use std::io; 26 | use std::path::Path; 27 | 28 | use super::*; 29 | 30 | 31 | #[allow(non_snake_case)] 32 | pub struct AlSymbols<'lib> { 33 | $(pub $sym: libloading::Symbol<'lib, unsafe extern "C" fn ($($param: $param_ty),*) -> $ret_ty>,)* 34 | } 35 | 36 | rental!{ 37 | mod rent { 38 | use super::libloading; 39 | 40 | #[rental] 41 | pub struct RentSymbols { 42 | lib: Box, 43 | syms: super::AlSymbols<'lib>, 44 | } 45 | } 46 | } 47 | 48 | use self::rent::RentSymbols; 49 | 50 | 51 | pub struct AlApi(rent::RentSymbols); 52 | 53 | 54 | impl AlApi { 55 | pub fn load_default() -> io::Result { 56 | AlApi::from_lib(libloading::Library::new("libopenal.so") 57 | .or_else(|_| libloading::Library::new("libopenal.dylib")) 58 | .or_else(|_| libloading::Library::new("OpenAL.framework/OpenAL")) 59 | .or_else(|_| libloading::Library::new("soft_oal.dll")) 60 | .or_else(|_| libloading::Library::new("OpenAL32.dll")) 61 | ?) 62 | } 63 | 64 | 65 | pub fn load>(path: P) -> io::Result { 66 | AlApi::from_lib(libloading::Library::new(path.as_ref())?) 67 | } 68 | 69 | 70 | fn from_lib(lib: libloading::Library) -> io::Result { 71 | match RentSymbols::try_new(Box::new(lib), |lib| Ok(AlSymbols{ 72 | $($sym: unsafe { lib.get(stringify!($sym).as_bytes())? },)* 73 | })) { 74 | Ok(syms) => Ok(AlApi(syms)), 75 | Err(rental::RentalError(e, _)) => return Err(e), 76 | } 77 | } 78 | 79 | 80 | $(#[allow(non_snake_case)] 81 | #[inline] 82 | pub unsafe fn $sym(&self, $($param: $param_ty),*) -> $ret_ty { 83 | self.0.rent(|s| (s.$sym)($($param),*)) 84 | })* 85 | } 86 | } 87 | 88 | pub use al_api::AlApi; 89 | }; 90 | } 91 | 92 | 93 | #[cfg(any(target_os = "emscripten", not(feature = "dynamic")))] 94 | macro_rules! al_api { 95 | { 96 | $($sym:ident: unsafe extern "C" fn ($($param:ident: $param_ty:ty),*) -> $ret_ty:ty,)* 97 | } => { 98 | mod al_api { 99 | use std::io; 100 | use std::path::Path; 101 | use super::*; 102 | 103 | 104 | #[allow(non_snake_case)] 105 | pub mod al_symbols { 106 | use super::*; 107 | 108 | extern "C" { 109 | $(pub fn $sym ($($param: $param_ty),*) -> $ret_ty;)* 110 | } 111 | } 112 | 113 | 114 | pub struct AlApi; 115 | 116 | 117 | impl AlApi { 118 | pub fn load_default() -> io::Result { 119 | Ok(AlApi) 120 | } 121 | 122 | 123 | pub fn load>(_path: P) -> io::Result { 124 | Err(io::Error::new(io::ErrorKind::Other, "Dynamic loading is not supported on emscripten")) 125 | } 126 | 127 | 128 | $(#[allow(non_snake_case)] 129 | #[inline] 130 | pub unsafe fn $sym(&self, $($param: $param_ty),*) -> $ret_ty { 131 | al_symbols::$sym($($param),*) 132 | })* 133 | } 134 | } 135 | 136 | pub use al_api::AlApi; 137 | }; 138 | } 139 | 140 | 141 | al_api! { 142 | alcCreateContext: unsafe extern "C" fn(device: *mut ALCdevice, attrlist: *const ALCint) -> *mut ALCcontext, 143 | alcMakeContextCurrent: unsafe extern "C" fn(context: *mut ALCcontext) -> ALCboolean, 144 | alcProcessContext: unsafe extern "C" fn(context: *mut ALCcontext) -> (), 145 | alcSuspendContext: unsafe extern "C" fn(context: *mut ALCcontext) -> (), 146 | alcDestroyContext: unsafe extern "C" fn(context: *mut ALCcontext) -> (), 147 | alcGetCurrentContext: unsafe extern "C" fn() -> *mut ALCcontext, 148 | alcGetContextsDevice: unsafe extern "C" fn(context: *mut ALCcontext) -> *mut ALCdevice, 149 | alcOpenDevice: unsafe extern "C" fn(devicename: *const ALCchar) -> *mut ALCdevice, 150 | alcCloseDevice: unsafe extern "C" fn(device: *mut ALCdevice) -> ALCboolean, 151 | alcGetError: unsafe extern "C" fn(device: *mut ALCdevice) -> ALCenum, 152 | alcIsExtensionPresent: unsafe extern "C" fn(device: *mut ALCdevice, extname: *const ALCchar) -> ALCboolean, 153 | alcGetProcAddress: unsafe extern "C" fn(device: *mut ALCdevice, funcname: *const ALCchar) -> *mut ::std::os::raw::c_void, 154 | alcGetEnumValue: unsafe extern "C" fn(device: *mut ALCdevice, enumname: *const ALCchar) -> ALCenum, 155 | alcGetString: unsafe extern "C" fn(device: *mut ALCdevice, param: ALCenum) -> *const ALCchar, 156 | alcGetIntegerv: unsafe extern "C" fn(device: *mut ALCdevice, param: ALCenum, size: ALCsizei, values: *mut ALCint) -> (), 157 | alcCaptureOpenDevice: unsafe extern "C" fn(devicename: *const ALCchar, frequency: ALCuint, format: ALCenum, buffersize: ALCsizei) -> *mut ALCdevice, 158 | alcCaptureCloseDevice: unsafe extern "C" fn(device: *mut ALCdevice) -> ALCboolean, 159 | alcCaptureStart: unsafe extern "C" fn(device: *mut ALCdevice) -> (), 160 | alcCaptureStop: unsafe extern "C" fn(device: *mut ALCdevice) -> (), 161 | alcCaptureSamples: unsafe extern "C" fn(device: *mut ALCdevice, buffer: *mut ALCvoid, samples: ALCsizei) -> (), 162 | 163 | alDopplerFactor: unsafe extern "C" fn(value: ALfloat) -> (), 164 | alDopplerVelocity: unsafe extern "C" fn(value: ALfloat) -> (), 165 | alSpeedOfSound: unsafe extern "C" fn(value: ALfloat) -> (), 166 | alDistanceModel: unsafe extern "C" fn(distanceModel: ALenum) -> (), 167 | alEnable: unsafe extern "C" fn(capability: ALenum) -> (), 168 | alDisable: unsafe extern "C" fn(capability: ALenum) -> (), 169 | alIsEnabled: unsafe extern "C" fn(capability: ALenum) -> ALboolean, 170 | alGetString: unsafe extern "C" fn(param: ALenum) -> *const ALchar, 171 | alGetBooleanv: unsafe extern "C" fn(param: ALenum, values: *mut ALboolean) -> (), 172 | alGetIntegerv: unsafe extern "C" fn(param: ALenum, values: *mut ALint) -> (), 173 | alGetFloatv: unsafe extern "C" fn(param: ALenum, values: *mut ALfloat) -> (), 174 | alGetDoublev: unsafe extern "C" fn(param: ALenum, values: *mut ALdouble) -> (), 175 | alGetBoolean: unsafe extern "C" fn(param: ALenum) -> ALboolean, 176 | alGetInteger: unsafe extern "C" fn(param: ALenum) -> ALint, 177 | alGetFloat: unsafe extern "C" fn(param: ALenum) -> ALfloat, 178 | alGetDouble: unsafe extern "C" fn(param: ALenum) -> ALdouble, 179 | alGetError: unsafe extern "C" fn() -> ALenum, 180 | alIsExtensionPresent: unsafe extern "C" fn(extname: *const ALchar) -> ALboolean, 181 | alGetProcAddress: unsafe extern "C" fn(fname: *const ALchar) -> *mut ::std::os::raw::c_void, 182 | alGetEnumValue: unsafe extern "C" fn(ename: *const ALchar) -> ALenum, 183 | alListenerf: unsafe extern "C" fn(param: ALenum, value: ALfloat) -> (), 184 | alListener3f: unsafe extern "C" fn(param: ALenum, value1: ALfloat, value2: ALfloat, value3: ALfloat) -> (), 185 | alListenerfv: unsafe extern "C" fn(param: ALenum, values: *const ALfloat) -> (), 186 | alListeneri: unsafe extern "C" fn(param: ALenum, value: ALint) -> (), 187 | alListener3i: unsafe extern "C" fn(param: ALenum, value1: ALint, value2: ALint, value3: ALint) -> (), 188 | alListeneriv: unsafe extern "C" fn(param: ALenum, values: *const ALint) -> (), 189 | alGetListenerf: unsafe extern "C" fn(param: ALenum, value: *mut ALfloat) -> (), 190 | alGetListener3f: unsafe extern "C" fn(param: ALenum, value1: *mut ALfloat, value2: *mut ALfloat, value3: *mut ALfloat) -> (), 191 | alGetListenerfv: unsafe extern "C" fn(param: ALenum, values: *mut ALfloat) -> (), 192 | alGetListeneri: unsafe extern "C" fn(param: ALenum, value: *mut ALint) -> (), 193 | alGetListener3i: unsafe extern "C" fn(param: ALenum, value1: *mut ALint, value2: *mut ALint, value3: *mut ALint) -> (), 194 | alGetListeneriv: unsafe extern "C" fn(param: ALenum, values: *mut ALint) -> (), 195 | alGenSources: unsafe extern "C" fn(n: ALsizei, sources: *mut ALuint) -> (), 196 | alDeleteSources: unsafe extern "C" fn(n: ALsizei, sources: *const ALuint) -> (), 197 | alIsSource: unsafe extern "C" fn(source: ALuint) -> ALboolean, 198 | alSourcef: unsafe extern "C" fn(source: ALuint, param: ALenum, value: ALfloat) -> (), 199 | alSource3f: unsafe extern "C" fn(source: ALuint, param: ALenum, value1: ALfloat, value2: ALfloat, value3: ALfloat) -> (), 200 | alSourcefv: unsafe extern "C" fn(source: ALuint, param: ALenum, values: *const ALfloat) -> (), 201 | alSourcei: unsafe extern "C" fn(source: ALuint, param: ALenum, value: ALint) -> (), 202 | alSource3i: unsafe extern "C" fn(source: ALuint, param: ALenum, value1: ALint, value2: ALint, value3: ALint) -> (), 203 | alSourceiv: unsafe extern "C" fn(source: ALuint, param: ALenum, values: *const ALint) -> (), 204 | alGetSourcef: unsafe extern "C" fn(source: ALuint, param: ALenum, value: *mut ALfloat) -> (), 205 | alGetSource3f: unsafe extern "C" fn(source: ALuint, param: ALenum, value1: *mut ALfloat, value2: *mut ALfloat, value3: *mut ALfloat) -> (), 206 | alGetSourcefv: unsafe extern "C" fn(source: ALuint, param: ALenum, values: *mut ALfloat) -> (), 207 | alGetSourcei: unsafe extern "C" fn(source: ALuint, param: ALenum, value: *mut ALint) -> (), 208 | alGetSource3i: unsafe extern "C" fn(source: ALuint, param: ALenum, value1: *mut ALint, value2: *mut ALint, value3: *mut ALint) -> (), 209 | alGetSourceiv: unsafe extern "C" fn(source: ALuint, param: ALenum, values: *mut ALint) -> (), 210 | alSourcePlayv: unsafe extern "C" fn(n: ALsizei, sources: *const ALuint) -> (), 211 | alSourceStopv: unsafe extern "C" fn(n: ALsizei, sources: *const ALuint) -> (), 212 | alSourceRewindv: unsafe extern "C" fn(n: ALsizei, sources: *const ALuint) -> (), 213 | alSourcePausev: unsafe extern "C" fn(n: ALsizei, sources: *const ALuint) -> (), 214 | alSourcePlay: unsafe extern "C" fn(source: ALuint) -> (), 215 | alSourceStop: unsafe extern "C" fn(source: ALuint) -> (), 216 | alSourceRewind: unsafe extern "C" fn(source: ALuint) -> (), 217 | alSourcePause: unsafe extern "C" fn(source: ALuint) -> (), 218 | alSourceQueueBuffers: unsafe extern "C" fn(source: ALuint, nb: ALsizei, buffers: *const ALuint) -> (), 219 | alSourceUnqueueBuffers: unsafe extern "C" fn(source: ALuint, nb: ALsizei, buffers: *mut ALuint) -> (), 220 | alGenBuffers: unsafe extern "C" fn(n: ALsizei, buffers: *mut ALuint) -> (), 221 | alDeleteBuffers: unsafe extern "C" fn(n: ALsizei, buffers: *const ALuint) -> (), 222 | alIsBuffer: unsafe extern "C" fn(buffer: ALuint) -> ALboolean, 223 | alBufferData: unsafe extern "C" fn(buffer: ALuint, format: ALenum, data: *const ALvoid, size: ALsizei, freq: ALsizei) -> (), 224 | alBufferf: unsafe extern "C" fn(buffer: ALuint, param: ALenum, value: ALfloat) -> (), 225 | alBuffer3f: unsafe extern "C" fn(buffer: ALuint, param: ALenum, value1: ALfloat, value2: ALfloat, value3: ALfloat) -> (), 226 | alBufferfv: unsafe extern "C" fn(buffer: ALuint, param: ALenum, values: *const ALfloat) -> (), 227 | alBufferi: unsafe extern "C" fn(buffer: ALuint, param: ALenum, value: ALint) -> (), 228 | alBuffer3i: unsafe extern "C" fn(buffer: ALuint, param: ALenum, value1: ALint, value2: ALint, value3: ALint) -> (), 229 | alBufferiv: unsafe extern "C" fn(buffer: ALuint, param: ALenum, values: *const ALint) -> (), 230 | alGetBufferf: unsafe extern "C" fn(buffer: ALuint, param: ALenum, value: *mut ALfloat) -> (), 231 | alGetBuffer3f: unsafe extern "C" fn(buffer: ALuint, param: ALenum, value1: *mut ALfloat, value2: *mut ALfloat, value3: *mut ALfloat) -> (), 232 | alGetBufferfv: unsafe extern "C" fn(buffer: ALuint, param: ALenum, values: *mut ALfloat) -> (), 233 | alGetBufferi: unsafe extern "C" fn(buffer: ALuint, param: ALenum, value: *mut ALint) -> (), 234 | alGetBuffer3i: unsafe extern "C" fn(buffer: ALuint, param: ALenum, value1: *mut ALint, value2: *mut ALint, value3: *mut ALint) -> (), 235 | alGetBufferiv: unsafe extern "C" fn(buffer: ALuint, param: ALenum, values: *mut ALint) -> (), 236 | } 237 | -------------------------------------------------------------------------------- /examples/basic.rs: -------------------------------------------------------------------------------- 1 | extern crate alto; 2 | 3 | use alto::{Alto, AltoResult}; 4 | 5 | fn run() -> AltoResult<()> { 6 | let alto = Alto::load_default()?; 7 | 8 | for s in alto.enumerate_outputs() { 9 | println!("Found device: {}", s.to_str().unwrap()); 10 | } 11 | 12 | let device = alto.open(None)?; // Opens the default audio device 13 | let context = device.new_context(None)?; // Creates a default context 14 | 15 | // Configure listener 16 | context.set_position([1.0, 4.0, 5.0])?; 17 | context.set_velocity([2.5, 0.0, 0.0])?; 18 | context.set_orientation(([0.0, 0.0, 1.0], [0.0, 1.0, 0.0]))?; 19 | 20 | let _source = context.new_static_source()?; 21 | 22 | // Now you can load your samples and store them in a buffer with 23 | // `context.new_buffer(samples, frequency)`; 24 | 25 | Ok(()) 26 | } 27 | 28 | fn main() { 29 | use std::process::exit; 30 | 31 | if let Err(e) = run() { 32 | println!("Failed to run basic example: {}", e); 33 | exit(1); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/input.rs: -------------------------------------------------------------------------------- 1 | extern crate alto; 2 | 3 | use std::ffi::CStr; 4 | use alto::*; 5 | 6 | type MyCapture = Capture>; 7 | 8 | 9 | fn main() { 10 | let a = load_alto(); 11 | let devices = a.enumerate_captures(); 12 | 13 | for device in devices { 14 | let dev = open_cap(&a, Some(&device)); 15 | assert_eq!(dev.specifier().unwrap(), device.as_ref()); 16 | } 17 | } 18 | 19 | fn load_alto() -> Alto { 20 | Alto::load_default().unwrap() 21 | } 22 | 23 | fn open_cap(a: &Alto, spec: Option<&CStr>) -> MyCapture { 24 | a.open_capture(spec, 4096, 1024).unwrap() 25 | } 26 | 27 | -------------------------------------------------------------------------------- /examples/sine.rs: -------------------------------------------------------------------------------- 1 | extern crate alto; 2 | 3 | use std::sync::Arc; 4 | use alto::*; 5 | 6 | 7 | fn main() { 8 | let alto = if let Ok(alto) = Alto::load_default() { 9 | alto 10 | } else { 11 | println!("No OpenAL implementation present!"); 12 | return; 13 | }; 14 | 15 | println!("Using output: {:?}", alto.default_output().unwrap()); 16 | let dev = alto.open(None).unwrap(); 17 | let ctx = dev.new_context(None).unwrap(); 18 | 19 | let mut slot = if dev.is_extension_present(alto::ext::Alc::Efx) { 20 | println!("Using EFX reverb"); 21 | if let Ok(slot) = (|| -> AltoResult<_> { 22 | let mut slot = ctx.new_aux_effect_slot()?; 23 | let mut reverb: efx::EaxReverbEffect = ctx.new_effect()?; 24 | reverb.set_preset(&efx::REVERB_PRESET_GENERIC)?; 25 | slot.set_effect(&reverb)?; 26 | Ok(slot) 27 | })() { 28 | Some(slot) 29 | } else { 30 | println!("Broken router detected; disabling EFX"); 31 | None 32 | } 33 | } else { 34 | println!("EFX not present"); 35 | None 36 | }; 37 | 38 | { 39 | let buf = ctx.new_buffer(SinWave::new(44_000 / 440, 0.25).render().take(44_000 / 440).collect::>(), 44_000).unwrap(); 40 | let buf = Arc::new(buf); 41 | 42 | let mut src = ctx.new_static_source().unwrap(); 43 | src.set_buffer(buf).unwrap(); 44 | src.set_looping(true); 45 | if let Some(ref mut slot) = slot { 46 | src.set_aux_send(0, slot).unwrap(); 47 | } 48 | 49 | println!("Playing static 440hz sine wave..."); 50 | src.play(); 51 | 52 | std::thread::sleep(std::time::Duration::new(2, 0)); 53 | } 54 | 55 | std::thread::sleep(std::time::Duration::new(1, 0)); 56 | 57 | { 58 | let mut wave = SinWave::new(44_000 / 220, 0.25); 59 | 60 | let mut src = ctx.new_streaming_source().unwrap(); 61 | if let Some(ref mut slot) = slot { 62 | src.set_aux_send(0, slot).unwrap(); 63 | } 64 | for _ in 0 .. 5 { 65 | let buf = ctx.new_buffer(wave.render().take(44_000 / 10).collect::>(), 44_000).unwrap(); 66 | src.queue_buffer(buf).unwrap(); 67 | } 68 | 69 | println!("Playing streaming 220hz sine wave..."); 70 | src.play(); 71 | 72 | for _ in 0 .. 15 { 73 | while src.buffers_processed() == 0 { } 74 | 75 | let mut buf = src.unqueue_buffer().unwrap(); 76 | buf.set_data(wave.render().take(44_000 / 10).collect::>(), 44_000).unwrap(); 77 | src.queue_buffer(buf).unwrap(); 78 | } 79 | 80 | while src.buffers_processed() < 5 { } 81 | } 82 | 83 | std::thread::sleep(std::time::Duration::new(1, 0)); 84 | } 85 | 86 | 87 | struct SinWave { 88 | len: i32, 89 | vol: f32, 90 | cursor: i32, 91 | } 92 | 93 | struct SinWaveRenderer<'w>(&'w mut SinWave); 94 | 95 | 96 | impl SinWave { 97 | pub fn new(len: i32, vol: f32) -> SinWave { 98 | SinWave{len: len, vol: vol, cursor: 0} 99 | } 100 | 101 | 102 | pub fn render(&mut self) -> SinWaveRenderer { 103 | SinWaveRenderer(self) 104 | } 105 | } 106 | 107 | 108 | impl<'w> Iterator for SinWaveRenderer<'w> { 109 | type Item = Mono; 110 | 111 | fn next(&mut self) -> Option> { 112 | let cursor = self.0.cursor; 113 | self.0.cursor += 1; 114 | if self.0.cursor == self.0.len { self.0.cursor = 0 } 115 | 116 | Some(Mono{center: ((cursor as f32 / self.0.len as f32 * 2.0 * std::f32::consts::PI).sin() * self.0.vol * std::i16::MAX as f32) as i16}) 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/al/format.rs: -------------------------------------------------------------------------------- 1 | use std::ops::{Deref, DerefMut}; 2 | 3 | use ::{AltoError, AltoResult}; 4 | use sys; 5 | use alc::*; 6 | use al::*; 7 | use ext; 8 | 9 | 10 | /// Audio formats supported by OpenAL. 11 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 12 | pub enum Format { 13 | Standard(StandardFormat), 14 | ExtALaw(ExtALawFormat), 15 | ExtBFormat(ExtBFormat), 16 | ExtDouble(ExtDoubleFormat), 17 | ExtFloat32(ExtFloat32Format), 18 | ExtIma4(ExtIma4Format), 19 | ExtMcFormats(ExtMcFormat), 20 | ExtMuLaw(ExtMuLawFormat), 21 | ExtMuLawBFormat(ExtMuLawBFormat), 22 | ExtMuLawMcFormats(ExtMuLawMcFormat), 23 | SoftMsadpcm(SoftMsadpcmFormat), 24 | } 25 | 26 | 27 | /// Standard formats defined in the base specification. 28 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 29 | pub enum StandardFormat { 30 | /// `AL_FORMAT_MONO8` 31 | MonoU8, 32 | /// `AL_FORMAT_MONO16` 33 | MonoI16, 34 | /// `AL_FORMAT_STEREO8` 35 | StereoU8, 36 | /// `AL_FORMAT_STEREO16` 37 | StereoI16, 38 | } 39 | 40 | 41 | /// Formats provided by `AL_EXT_ALAW`. 42 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 43 | pub enum ExtALawFormat { 44 | /// `AL_FORMAT_MONO_ALAW_EXT` 45 | Mono, 46 | /// `AL_FORMAT_STEREO_ALAW_EXT` 47 | Stereo, 48 | } 49 | 50 | 51 | /// Formats provided by `AL_EXT_BFORMAT`. 52 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 53 | pub enum ExtBFormat { 54 | /// `AL_FORMAT_BFORMAT2D_8` 55 | B2DU8, 56 | /// `AL_FORMAT_BFORMAT2D_16` 57 | B2DI16, 58 | /// `AL_FORMAT_BFORMAT2D_FLOAT32` 59 | B2DF32, 60 | /// `AL_FORMAT_BFORMAT3D_8` 61 | B3DU8, 62 | /// `AL_FORMAT_BFORMAT3D_16` 63 | B3DI16, 64 | /// `AL_FORMAT_BFORMAT3D_FLOAT32` 65 | B3DF32, 66 | } 67 | 68 | 69 | /// Formats provided by `AL_EXT_double`. 70 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 71 | pub enum ExtDoubleFormat { 72 | /// `AL_FORMAT_MONO_DOUBLE_EXT` 73 | Mono, 74 | /// `AL_FORMAT_STEREO_DOUBLE_EXT` 75 | Stereo, 76 | } 77 | 78 | 79 | /// Formats provided by `AL_EXT_float32`. 80 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 81 | pub enum ExtFloat32Format { 82 | /// `AL_FORMAT_MONO_FLOAT32` 83 | Mono, 84 | /// `AL_FORMAT_STEREO_FLOAT32` 85 | Stereo, 86 | } 87 | 88 | 89 | /// Formats provided by `AL_EXT_IMA4`. 90 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 91 | pub enum ExtIma4Format { 92 | /// `AL_FORMAT_MONO_IMA4` 93 | Mono, 94 | /// `AL_FORMAT_STEREO_IMA4` 95 | Stereo, 96 | } 97 | 98 | 99 | /// Formats provided by `AL_EXT_MCFORMATS`. 100 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 101 | pub enum ExtMcFormat { 102 | /// `AL_FORMAT_QUAD8` 103 | QuadU8, 104 | /// `AL_FORMAT_QUAD16` 105 | QuadI16, 106 | /// `AL_FORMAT_QUAD32` 107 | QuadF32, 108 | /// `AL_FORMAT_REAR8` 109 | RearU8, 110 | /// `AL_FORMAT_REAR16` 111 | RearI16, 112 | /// `AL_FORMAT_REAR32` 113 | RearF32, 114 | /// `AL_FORMAT_51CHN8` 115 | Mc51ChnU8, 116 | /// `AL_FORMAT_51CHN16` 117 | Mc51ChnI16, 118 | /// `AL_FORMAT_51CHN32` 119 | Mc51ChnF32, 120 | /// `AL_FORMAT_61CHN8` 121 | Mc61ChnU8, 122 | /// `AL_FORMAT_61CHN16` 123 | Mc61ChnI16, 124 | /// `AL_FORMAT_61CHN32` 125 | Mc61ChnF32, 126 | /// `AL_FORMAT_71CHN8` 127 | Mc71ChnU8, 128 | /// `AL_FORMAT_71CHN16` 129 | Mc71ChnI16, 130 | /// `AL_FORMAT_71CHN32` 131 | Mc71ChnF32, 132 | } 133 | 134 | 135 | /// Formats provided by `AL_EXT_MULAW`. 136 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 137 | pub enum ExtMuLawFormat { 138 | /// `AL_FORMAT_MONO_MULAW_EXT` 139 | Mono, 140 | /// `AL_FORMAT_STEREO_MULAW_EXT` 141 | Stereo, 142 | } 143 | 144 | 145 | /// Formats provided by `AL_EXT_MULAW_BFORMAT`. 146 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 147 | pub enum ExtMuLawBFormat { 148 | /// `AL_FORMAT_BFORMAT2D_MULAW` 149 | B2D, 150 | /// `AL_FORMAT_BFORMAT3D_MULAW` 151 | B3D, 152 | } 153 | 154 | 155 | /// Formats provided by `AL_EXT_MULAW_MCFORMATS`. 156 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 157 | pub enum ExtMuLawMcFormat { 158 | /// `AL_FORMAT_MONO_MULAW` 159 | Mono, 160 | /// `AL_FORMAT_STEREO_MULAW` 161 | Stereo, 162 | /// `AL_FORMAT_QUAD_MULAW` 163 | Quad, 164 | /// `AL_FORMAT_REAR_MULAW` 165 | Rear, 166 | /// `AL_FORMAT_51CHN_MULAW` 167 | Mc51Chn, 168 | /// `AL_FORMAT_61CHN_MULAW` 169 | Mc61Chn, 170 | /// `AL_FORMAT_71CHN_MULAW` 171 | Mc71Chn, 172 | } 173 | 174 | 175 | /// Formats provided by `AL_SOFT_MSADPCM`. 176 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 177 | pub enum SoftMsadpcmFormat { 178 | /// `AL_FORMAT_MONO_MSADPCM_SOFT` 179 | Mono, 180 | /// `AL_FORMAT_STEREO_MSADPCM_SOFT` 181 | Stereo, 182 | } 183 | 184 | 185 | /// Implemented by structs that represent a frame of audio samples. 186 | /// A sample frame is a grouping of audio samples from each channel 187 | /// of an output format. 188 | pub unsafe trait SampleFrame: Copy + 'static { 189 | /// Underlying sample type. 190 | type Sample: Copy; 191 | 192 | 193 | /// Length of the frame in samples. 194 | fn len() -> usize; 195 | /// The exact format described by this struct. 196 | fn format() -> Format; 197 | } 198 | 199 | 200 | /// Implemented for sample frames specified by the base standard. 201 | pub unsafe trait StandardFrame: SampleFrame { } 202 | 203 | 204 | /// Implemented for types that represent a shared buffer of audio data. 205 | pub unsafe trait AsBufferData { 206 | #[doc(hidden)] 207 | fn as_buffer_data(&self) -> (*const sys::ALvoid, usize); 208 | } 209 | 210 | 211 | /// Implemented for types that represent a mutable buffer of audio data. 212 | pub unsafe trait AsBufferDataMut { 213 | #[doc(hidden)] 214 | fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize); 215 | } 216 | 217 | 218 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 219 | #[repr(C)] 220 | pub struct ALawSample(pub u8); 221 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 222 | #[repr(C)] 223 | pub struct MuLawSample(pub u8); 224 | 225 | 226 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 227 | #[repr(C)] 228 | pub struct Mono { 229 | pub center: S, 230 | } 231 | 232 | 233 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 234 | #[repr(C)] 235 | pub struct Stereo { 236 | pub left: S, 237 | pub right: S, 238 | } 239 | 240 | 241 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 242 | #[repr(C)] 243 | pub struct McRear { 244 | pub rear: S, 245 | } 246 | 247 | 248 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 249 | #[repr(C)] 250 | pub struct McQuad { 251 | pub front_left: S, 252 | pub front_right: S, 253 | pub back_left: S, 254 | pub back_right: S, 255 | } 256 | 257 | 258 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 259 | #[repr(C)] 260 | pub struct Mc51Chn { 261 | pub front_left: S, 262 | pub front_right: S, 263 | pub front_center: S, 264 | pub low_freq: S, 265 | pub back_left: S, 266 | pub back_right: S, 267 | } 268 | 269 | 270 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 271 | #[repr(C)] 272 | pub struct Mc61Chn { 273 | pub front_left: S, 274 | pub front_right: S, 275 | pub front_center: S, 276 | pub low_freq: S, 277 | pub back_left: S, 278 | pub back_right: S, 279 | pub back_center: S, 280 | } 281 | 282 | 283 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 284 | #[repr(C)] 285 | pub struct Mc71Chn { 286 | pub front_left: S, 287 | pub front_right: S, 288 | pub front_center: S, 289 | pub low_freq: S, 290 | pub back_left: S, 291 | pub back_right: S, 292 | pub side_left: S, 293 | pub side_right: S, 294 | } 295 | 296 | 297 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 298 | #[repr(C)] 299 | pub struct BFormat2D { 300 | pub w: S, 301 | pub x: S, 302 | pub y: S, 303 | } 304 | 305 | 306 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 307 | #[repr(C)] 308 | pub struct BFormat3D { 309 | pub w: S, 310 | pub x: S, 311 | pub y: S, 312 | pub z: S, 313 | } 314 | 315 | 316 | impl Format { 317 | pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult { 318 | match self { 319 | Format::Standard(f) => Ok(f.into_raw()), 320 | Format::ExtALaw(f) => f.into_raw(ctx), 321 | Format::ExtBFormat(f) => f.into_raw(ctx), 322 | Format::ExtDouble(f) => f.into_raw(ctx), 323 | Format::ExtFloat32(f) => f.into_raw(ctx), 324 | Format::ExtIma4(f) => f.into_raw(ctx), 325 | Format::ExtMcFormats(f) => f.into_raw(ctx), 326 | Format::ExtMuLaw(f) => f.into_raw(ctx), 327 | Format::ExtMuLawBFormat(f) => f.into_raw(ctx), 328 | Format::ExtMuLawMcFormats(f) => f.into_raw(ctx), 329 | Format::SoftMsadpcm(f) => f.into_raw(ctx), 330 | } 331 | } 332 | } 333 | 334 | 335 | impl StandardFormat { 336 | pub fn into_raw(self) -> sys::ALint { 337 | match self { 338 | StandardFormat::MonoU8 => sys::AL_FORMAT_MONO8, 339 | StandardFormat::MonoI16 => sys::AL_FORMAT_MONO16, 340 | StandardFormat::StereoU8 => sys::AL_FORMAT_STEREO8, 341 | StandardFormat::StereoI16 => sys::AL_FORMAT_STEREO16, 342 | } 343 | } 344 | } 345 | 346 | 347 | impl ExtALawFormat { 348 | pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult { 349 | ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self { 350 | ExtALawFormat::Mono => Ok(ctx.0.exts.AL_EXT_ALAW()?.AL_FORMAT_MONO_ALAW_EXT?), 351 | ExtALawFormat::Stereo => Ok(ctx.0.exts.AL_EXT_ALAW()?.AL_FORMAT_STEREO_ALAW_EXT?), 352 | }) 353 | } 354 | } 355 | 356 | 357 | impl ExtBFormat { 358 | pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult { 359 | ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self { 360 | ExtBFormat::B2DU8 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT2D_8?), 361 | ExtBFormat::B2DI16 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT2D_16?), 362 | ExtBFormat::B2DF32 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT2D_FLOAT32?), 363 | ExtBFormat::B3DU8 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT3D_8?), 364 | ExtBFormat::B3DI16 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT3D_16?), 365 | ExtBFormat::B3DF32 => Ok(ctx.0.exts.AL_EXT_BFORMAT()?.AL_FORMAT_BFORMAT3D_FLOAT32?), 366 | }) 367 | } 368 | } 369 | 370 | 371 | impl ExtDoubleFormat { 372 | pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult { 373 | ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self { 374 | ExtDoubleFormat::Mono => Ok(ctx.0.exts.AL_EXT_double()?.AL_FORMAT_MONO_DOUBLE_EXT?), 375 | ExtDoubleFormat::Stereo => Ok(ctx.0.exts.AL_EXT_double()?.AL_FORMAT_STEREO_DOUBLE_EXT?), 376 | }) 377 | } 378 | } 379 | 380 | 381 | impl ExtFloat32Format { 382 | pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult { 383 | ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self { 384 | ExtFloat32Format::Mono => Ok(ctx.0.exts.AL_EXT_float32()?.AL_FORMAT_MONO_FLOAT32?), 385 | ExtFloat32Format::Stereo => Ok(ctx.0.exts.AL_EXT_float32()?.AL_FORMAT_STEREO_FLOAT32?), 386 | }) 387 | } 388 | } 389 | 390 | 391 | impl ExtIma4Format { 392 | pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult { 393 | ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self { 394 | ExtIma4Format::Mono => Ok(ctx.0.exts.AL_EXT_IMA4()?.AL_FORMAT_MONO_IMA4?), 395 | ExtIma4Format::Stereo => Ok(ctx.0.exts.AL_EXT_IMA4()?.AL_FORMAT_STEREO_IMA4?), 396 | }) 397 | } 398 | } 399 | 400 | 401 | impl ExtMcFormat { 402 | pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult { 403 | ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self { 404 | ExtMcFormat::QuadU8 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_QUAD8?), 405 | ExtMcFormat::QuadI16 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_QUAD16?), 406 | ExtMcFormat::QuadF32 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_QUAD32?), 407 | ExtMcFormat::RearU8 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_REAR8?), 408 | ExtMcFormat::RearI16 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_REAR16?), 409 | ExtMcFormat::RearF32 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_REAR32?), 410 | ExtMcFormat::Mc51ChnU8 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_51CHN8?), 411 | ExtMcFormat::Mc51ChnI16 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_51CHN16?), 412 | ExtMcFormat::Mc51ChnF32 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_51CHN32?), 413 | ExtMcFormat::Mc61ChnU8 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_61CHN8?), 414 | ExtMcFormat::Mc61ChnI16 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_61CHN16?), 415 | ExtMcFormat::Mc61ChnF32 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_61CHN32?), 416 | ExtMcFormat::Mc71ChnU8 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_71CHN8?), 417 | ExtMcFormat::Mc71ChnI16 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_71CHN16?), 418 | ExtMcFormat::Mc71ChnF32 => Ok(ctx.0.exts.AL_EXT_MCFORMATS()?.AL_FORMAT_71CHN32?), 419 | }) 420 | } 421 | } 422 | 423 | 424 | impl ExtMuLawFormat { 425 | pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult { 426 | ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self { 427 | ExtMuLawFormat::Mono => Ok(ctx.0.exts.AL_EXT_MULAW()?.AL_FORMAT_MONO_MULAW_EXT?), 428 | ExtMuLawFormat::Stereo => Ok(ctx.0.exts.AL_EXT_MULAW()?.AL_FORMAT_STEREO_MULAW_EXT?), 429 | }) 430 | } 431 | } 432 | 433 | 434 | impl ExtMuLawBFormat { 435 | pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult { 436 | ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self { 437 | ExtMuLawBFormat::B2D => Ok(ctx.0.exts.AL_EXT_MULAW_BFORMAT()?.AL_FORMAT_BFORMAT2D_MULAW?), 438 | ExtMuLawBFormat::B3D => Ok(ctx.0.exts.AL_EXT_MULAW_BFORMAT()?.AL_FORMAT_BFORMAT3D_MULAW?), 439 | }) 440 | } 441 | } 442 | 443 | 444 | impl ExtMuLawMcFormat { 445 | pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult { 446 | ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self { 447 | ExtMuLawMcFormat::Mono => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_MONO_MULAW?), 448 | ExtMuLawMcFormat::Stereo => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_STEREO_MULAW?), 449 | ExtMuLawMcFormat::Quad => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_QUAD_MULAW?), 450 | ExtMuLawMcFormat::Rear => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_REAR_MULAW?), 451 | ExtMuLawMcFormat::Mc51Chn => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_51CHN_MULAW?), 452 | ExtMuLawMcFormat::Mc61Chn => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_61CHN_MULAW?), 453 | ExtMuLawMcFormat::Mc71Chn => Ok(ctx.0.exts.AL_EXT_MULAW_MCFORMATS()?.AL_FORMAT_71CHN_MULAW?), 454 | }) 455 | } 456 | } 457 | 458 | 459 | impl SoftMsadpcmFormat { 460 | pub fn into_raw(self, ctx: Option<&Context>) -> AltoResult { 461 | ctx.ok_or(AltoError::ExtensionNotPresent).and_then(|ctx| match self { 462 | SoftMsadpcmFormat::Mono => Ok(ctx.0.exts.AL_SOFT_MSADPCM()?.AL_FORMAT_MONO_MSADPCM_SOFT?), 463 | SoftMsadpcmFormat::Stereo => Ok(ctx.0.exts.AL_SOFT_MSADPCM()?.AL_FORMAT_STEREO_MSADPCM_SOFT?), 464 | }) 465 | } 466 | } 467 | 468 | 469 | unsafe impl SampleFrame for Mono { 470 | type Sample = u8; 471 | 472 | #[inline] fn len() -> usize { 1 } 473 | #[inline] fn format() -> Format { Format::Standard(StandardFormat::MonoU8) } 474 | } 475 | unsafe impl SampleFrame for Mono { 476 | type Sample = i16; 477 | 478 | #[inline] fn len() -> usize { 1 } 479 | #[inline] fn format() -> Format { Format::Standard(StandardFormat::MonoI16) } 480 | } 481 | unsafe impl SampleFrame for Mono { 482 | type Sample = f32; 483 | 484 | #[inline] fn len() -> usize { 1 } 485 | #[inline] fn format() -> Format { Format::ExtFloat32(ExtFloat32Format::Mono) } 486 | } 487 | unsafe impl SampleFrame for Mono { 488 | type Sample = f64; 489 | 490 | #[inline] fn len() -> usize { 1 } 491 | #[inline] fn format() -> Format { Format::ExtDouble(ExtDoubleFormat::Mono) } 492 | } 493 | unsafe impl SampleFrame for Mono { 494 | type Sample = ALawSample; 495 | 496 | #[inline] fn len() -> usize { 1 } 497 | #[inline] fn format() -> Format { Format::ExtALaw(ExtALawFormat::Mono) } 498 | } 499 | unsafe impl SampleFrame for Mono { 500 | type Sample = MuLawSample; 501 | 502 | #[inline] fn len() -> usize { 1 } 503 | #[inline] fn format() -> Format { Format::ExtMuLaw(ExtMuLawFormat::Mono) } 504 | } 505 | 506 | 507 | unsafe impl SampleFrame for Stereo { 508 | type Sample = u8; 509 | 510 | #[inline] fn len() -> usize { 2 } 511 | #[inline] fn format() -> Format { Format::Standard(StandardFormat::StereoU8) } 512 | } 513 | unsafe impl SampleFrame for Stereo { 514 | type Sample = i16; 515 | 516 | #[inline] fn len() -> usize { 2 } 517 | #[inline] fn format() -> Format { Format::Standard(StandardFormat::StereoI16) } 518 | } 519 | unsafe impl SampleFrame for Stereo { 520 | type Sample = f32; 521 | 522 | #[inline] fn len() -> usize { 2 } 523 | #[inline] fn format() -> Format { Format::ExtFloat32(ExtFloat32Format::Stereo) } 524 | } 525 | unsafe impl SampleFrame for Stereo { 526 | type Sample = f64; 527 | 528 | #[inline] fn len() -> usize { 2 } 529 | #[inline] fn format() -> Format { Format::ExtDouble(ExtDoubleFormat::Stereo) } 530 | } 531 | unsafe impl SampleFrame for Stereo { 532 | type Sample = ALawSample; 533 | 534 | #[inline] fn len() -> usize { 2 } 535 | #[inline] fn format() -> Format { Format::ExtALaw(ExtALawFormat::Stereo) } 536 | } 537 | unsafe impl SampleFrame for Stereo { 538 | type Sample = MuLawSample; 539 | 540 | #[inline] fn len() -> usize { 2 } 541 | #[inline] fn format() -> Format { Format::ExtMuLaw(ExtMuLawFormat::Stereo) } 542 | } 543 | 544 | 545 | unsafe impl SampleFrame for McRear { 546 | type Sample = u8; 547 | 548 | #[inline] fn len() -> usize { 1 } 549 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::RearU8) } 550 | } 551 | unsafe impl SampleFrame for McRear { 552 | type Sample = i16; 553 | 554 | #[inline] fn len() -> usize { 1 } 555 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::RearI16) } 556 | } 557 | unsafe impl SampleFrame for McRear { 558 | type Sample = f32; 559 | 560 | #[inline] fn len() -> usize { 1 } 561 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::RearF32) } 562 | } 563 | unsafe impl SampleFrame for McRear { 564 | type Sample = MuLawSample; 565 | 566 | #[inline] fn len() -> usize { 1 } 567 | #[inline] fn format() -> Format { Format::ExtMuLawMcFormats(ExtMuLawMcFormat::Rear) } 568 | } 569 | 570 | 571 | unsafe impl SampleFrame for McQuad { 572 | type Sample = u8; 573 | 574 | #[inline] fn len() -> usize { 4 } 575 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::QuadU8) } 576 | } 577 | unsafe impl SampleFrame for McQuad { 578 | type Sample = i16; 579 | 580 | #[inline] fn len() -> usize { 4 } 581 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::QuadI16) } 582 | } 583 | unsafe impl SampleFrame for McQuad { 584 | type Sample = f32; 585 | 586 | #[inline] fn len() -> usize { 4 } 587 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::QuadF32) } 588 | } 589 | unsafe impl SampleFrame for McQuad { 590 | type Sample = MuLawSample; 591 | 592 | #[inline] fn len() -> usize { 4 } 593 | #[inline] fn format() -> Format { Format::ExtMuLawMcFormats(ExtMuLawMcFormat::Quad) } 594 | } 595 | 596 | 597 | unsafe impl SampleFrame for Mc51Chn { 598 | type Sample = u8; 599 | 600 | #[inline] fn len() -> usize { 6 } 601 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc51ChnU8) } 602 | } 603 | unsafe impl SampleFrame for Mc51Chn { 604 | type Sample = i16; 605 | 606 | #[inline] fn len() -> usize { 6 } 607 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc51ChnI16) } 608 | } 609 | unsafe impl SampleFrame for Mc51Chn { 610 | type Sample = f32; 611 | 612 | #[inline] fn len() -> usize { 6 } 613 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc51ChnF32) } 614 | } 615 | unsafe impl SampleFrame for Mc51Chn { 616 | type Sample = MuLawSample; 617 | 618 | #[inline] fn len() -> usize { 6 } 619 | #[inline] fn format() -> Format { Format::ExtMuLawMcFormats(ExtMuLawMcFormat::Mc51Chn) } 620 | } 621 | 622 | 623 | unsafe impl SampleFrame for Mc61Chn { 624 | type Sample = u8; 625 | 626 | #[inline] fn len() -> usize { 7 } 627 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc61ChnU8) } 628 | } 629 | unsafe impl SampleFrame for Mc61Chn { 630 | type Sample = i16; 631 | 632 | #[inline] fn len() -> usize { 7 } 633 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc61ChnI16) } 634 | } 635 | unsafe impl SampleFrame for Mc61Chn { 636 | type Sample = f32; 637 | 638 | #[inline] fn len() -> usize { 7 } 639 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc61ChnF32) } 640 | } 641 | unsafe impl SampleFrame for Mc61Chn { 642 | type Sample = MuLawSample; 643 | 644 | #[inline] fn len() -> usize { 7 } 645 | #[inline] fn format() -> Format { Format::ExtMuLawMcFormats(ExtMuLawMcFormat::Mc61Chn) } 646 | } 647 | 648 | 649 | unsafe impl SampleFrame for Mc71Chn { 650 | type Sample = u8; 651 | 652 | #[inline] fn len() -> usize { 8 } 653 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc71ChnU8) } 654 | } 655 | unsafe impl SampleFrame for Mc71Chn { 656 | type Sample = i16; 657 | 658 | #[inline] fn len() -> usize { 8 } 659 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc71ChnI16) } 660 | } 661 | unsafe impl SampleFrame for Mc71Chn { 662 | type Sample = f32; 663 | 664 | #[inline] fn len() -> usize { 8 } 665 | #[inline] fn format() -> Format { Format::ExtMcFormats(ExtMcFormat::Mc71ChnF32) } 666 | } 667 | unsafe impl SampleFrame for Mc71Chn { 668 | type Sample = MuLawSample; 669 | 670 | #[inline] fn len() -> usize { 8 } 671 | #[inline] fn format() -> Format { Format::ExtMuLawMcFormats(ExtMuLawMcFormat::Mc71Chn) } 672 | } 673 | 674 | 675 | unsafe impl SampleFrame for BFormat2D { 676 | type Sample = u8; 677 | 678 | #[inline] fn len() -> usize { 3 } 679 | #[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B2DU8) } 680 | } 681 | unsafe impl SampleFrame for BFormat2D { 682 | type Sample = i16; 683 | 684 | #[inline] fn len() -> usize { 3 } 685 | #[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B2DI16) } 686 | } 687 | unsafe impl SampleFrame for BFormat2D { 688 | type Sample = f32; 689 | 690 | #[inline] fn len() -> usize { 3 } 691 | #[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B2DF32) } 692 | } 693 | unsafe impl SampleFrame for BFormat2D { 694 | type Sample = MuLawSample; 695 | 696 | #[inline] fn len() -> usize { 3 } 697 | #[inline] fn format() -> Format { Format::ExtMuLawBFormat(ExtMuLawBFormat::B2D) } 698 | } 699 | 700 | 701 | unsafe impl SampleFrame for BFormat3D { 702 | type Sample = u8; 703 | 704 | #[inline] fn len() -> usize { 4 } 705 | #[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B3DU8) } 706 | } 707 | unsafe impl SampleFrame for BFormat3D { 708 | type Sample = i16; 709 | 710 | #[inline] fn len() -> usize { 4 } 711 | #[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B3DI16) } 712 | } 713 | unsafe impl SampleFrame for BFormat3D { 714 | type Sample = f32; 715 | 716 | #[inline] fn len() -> usize { 4 } 717 | #[inline] fn format() -> Format { Format::ExtBFormat(ExtBFormat::B3DF32) } 718 | } 719 | unsafe impl SampleFrame for BFormat3D { 720 | type Sample = MuLawSample; 721 | 722 | #[inline] fn len() -> usize { 4 } 723 | #[inline] fn format() -> Format { Format::ExtMuLawBFormat(ExtMuLawBFormat::B3D) } 724 | } 725 | 726 | 727 | unsafe impl StandardFrame for Mono { } 728 | unsafe impl StandardFrame for Mono { } 729 | unsafe impl StandardFrame for Stereo { } 730 | unsafe impl StandardFrame for Stereo { } 731 | 732 | 733 | unsafe impl LoopbackFrame for Mono 734 | { 735 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_MONO_SOFT?) } 736 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) } 737 | } 738 | unsafe impl LoopbackFrame for Mono 739 | { 740 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_MONO_SOFT?) } 741 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_SHORT_SOFT?) } 742 | } 743 | unsafe impl LoopbackFrame for Mono 744 | { 745 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_MONO_SOFT?) } 746 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_FLOAT_SOFT?) } 747 | } 748 | 749 | 750 | unsafe impl LoopbackFrame for Stereo 751 | { 752 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_STEREO_SOFT?) } 753 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) } 754 | } 755 | unsafe impl LoopbackFrame for Stereo 756 | { 757 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_STEREO_SOFT?) } 758 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_SHORT_SOFT?) } 759 | } 760 | unsafe impl LoopbackFrame for Stereo 761 | { 762 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_STEREO_SOFT?) } 763 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_FLOAT_SOFT?) } 764 | } 765 | 766 | 767 | unsafe impl LoopbackFrame for McQuad 768 | { 769 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_QUAD_SOFT?) } 770 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) } 771 | } 772 | unsafe impl LoopbackFrame for McQuad 773 | { 774 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_QUAD_SOFT?) } 775 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_SHORT_SOFT?) } 776 | } 777 | unsafe impl LoopbackFrame for McQuad 778 | { 779 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_QUAD_SOFT?) } 780 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_FLOAT_SOFT?) } 781 | } 782 | 783 | 784 | unsafe impl LoopbackFrame for Mc51Chn 785 | { 786 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_5POINT1_SOFT?) } 787 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) } 788 | } 789 | unsafe impl LoopbackFrame for Mc51Chn 790 | { 791 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_5POINT1_SOFT?) } 792 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_SHORT_SOFT?) } 793 | } 794 | unsafe impl LoopbackFrame for Mc51Chn 795 | { 796 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_5POINT1_SOFT?) } 797 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_FLOAT_SOFT?) } 798 | } 799 | 800 | 801 | unsafe impl LoopbackFrame for Mc61Chn 802 | { 803 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_6POINT1_SOFT?) } 804 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) } 805 | } 806 | unsafe impl LoopbackFrame for Mc61Chn 807 | { 808 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_6POINT1_SOFT?) } 809 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_SHORT_SOFT?) } 810 | } 811 | unsafe impl LoopbackFrame for Mc61Chn 812 | { 813 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_6POINT1_SOFT?) } 814 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_FLOAT_SOFT?) } 815 | } 816 | 817 | 818 | unsafe impl LoopbackFrame for Mc71Chn 819 | { 820 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_7POINT1_SOFT?) } 821 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_UNSIGNED_BYTE_SOFT?) } 822 | } 823 | unsafe impl LoopbackFrame for Mc71Chn 824 | { 825 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_7POINT1_SOFT?) } 826 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_SHORT_SOFT?) } 827 | } 828 | unsafe impl LoopbackFrame for Mc71Chn 829 | { 830 | fn channels(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_7POINT1_SOFT?) } 831 | fn sample_ty(sl: &ext::ALC_SOFT_loopback) -> AltoResult { Ok(sl.ALC_FLOAT_SOFT?) } 832 | } 833 | 834 | 835 | unsafe impl AsBufferData for [F] where F: SampleFrame { 836 | fn as_buffer_data(&self) -> (*const sys::ALvoid, usize) { 837 | (self.as_ptr() as *const _, self.len() * mem::size_of::()) 838 | } 839 | } 840 | unsafe impl AsBufferData for [u8] where F: SampleFrame { 841 | fn as_buffer_data(&self) -> (*const sys::ALvoid, usize) { 842 | (self.as_ptr() as *const _, self.len() * mem::size_of::()) 843 | } 844 | } 845 | unsafe impl AsBufferData for [i16] where F: SampleFrame { 846 | fn as_buffer_data(&self) -> (*const sys::ALvoid, usize) { 847 | (self.as_ptr() as *const _, self.len() * mem::size_of::()) 848 | } 849 | } 850 | unsafe impl AsBufferData for [f32] where F: SampleFrame { 851 | fn as_buffer_data(&self) -> (*const sys::ALvoid, usize) { 852 | (self.as_ptr() as *const _, self.len() * mem::size_of::()) 853 | } 854 | } 855 | unsafe impl AsBufferData for T where 856 | F: SampleFrame, 857 | T: Deref, 858 | ::Target: AsBufferData, 859 | { 860 | fn as_buffer_data(&self) -> (*const sys::ALvoid, usize) { (**self).as_buffer_data() } 861 | } 862 | 863 | 864 | unsafe impl AsBufferDataMut for [F] where F: SampleFrame { 865 | fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize) { 866 | (self.as_mut_ptr() as *mut _, self.len() * mem::size_of::()) 867 | } 868 | } 869 | unsafe impl AsBufferDataMut for [u8] where F: SampleFrame { 870 | fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize) { 871 | (self.as_mut_ptr() as *mut _, self.len() * mem::size_of::()) 872 | } 873 | } 874 | unsafe impl AsBufferDataMut for [i16] where F: SampleFrame { 875 | fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize) { 876 | (self.as_mut_ptr() as *mut _, self.len() * mem::size_of::()) 877 | } 878 | } 879 | unsafe impl AsBufferDataMut for [f32] where F: SampleFrame { 880 | fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize) { 881 | (self.as_mut_ptr() as *mut _, self.len() * mem::size_of::()) 882 | } 883 | } 884 | unsafe impl AsBufferDataMut for T where 885 | F: SampleFrame, 886 | T: DerefMut, 887 | ::Target: AsBufferDataMut, 888 | { 889 | fn as_buffer_data_mut(&mut self) -> (*mut sys::ALvoid, usize) { (**self).as_buffer_data_mut() } 890 | } 891 | -------------------------------------------------------------------------------- /src/alc.rs: -------------------------------------------------------------------------------- 1 | use std::cmp; 2 | use std::any::Any; 3 | use std::ptr; 4 | use std::mem; 5 | use std::ffi::{CString, CStr}; 6 | use std::sync::Arc; 7 | use std::path::Path; 8 | use std::marker::PhantomData; 9 | 10 | use ::{AltoError, AltoResult}; 11 | use sys; 12 | use al::*; 13 | use ext; 14 | 15 | 16 | /// Attributes that may be supplied during context creation. 17 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Default, Debug)] 18 | pub struct ContextAttrs { 19 | /// `ALC_FREQUENCY` 20 | pub frequency: Option, 21 | /// `ALC_REFRESH` 22 | pub refresh: Option, 23 | /// `ALC_MONO_SOURCES` 24 | pub mono_sources: Option, 25 | /// `ALC_STEREO_SOURCES` 26 | pub stereo_sources: Option, 27 | /// `ALC_HRTF_SOFT` 28 | /// Requires `ALC_SOFT_HRTF` 29 | pub soft_hrtf: Option, 30 | /// `ALC_HRTF_ID_SOFT` 31 | /// Requires `ALC_SOFT_HRTF` 32 | pub soft_hrtf_id: Option, 33 | /// `ALC_OUTPUT_LIMITER_SOFT` 34 | /// Requires `ALC_SOFT_output_limiter` 35 | pub soft_output_limiter: Option, 36 | /// `ALC_MAX_AUXILIARY_SENDS` 37 | /// Requires `ALC_EXT_EFX` 38 | pub max_aux_sends: Option, 39 | } 40 | 41 | 42 | /// Attributes that may be supplied during context creation from a loopback device. 43 | /// Requires `ALC_SOFT_loopback` 44 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Default, Debug)] 45 | pub struct LoopbackAttrs { 46 | /// `ALC_MONO_SOURCES` 47 | pub mono_sources: Option, 48 | /// `ALC_STEREO_SOURCES` 49 | pub stereo_sources: Option, 50 | /// `ALC_HRTF_SOFT` 51 | /// Requires `ALC_SOFT_HRTF` 52 | pub soft_hrtf: Option, 53 | /// `ALC_HRTF_ID_SOFT` 54 | /// Requires `ALC_SOFT_HRTF` 55 | pub soft_hrtf_id: Option, 56 | /// `ALC_OUTPUT_LIMITER_SOFT` 57 | /// Requires `ALC_SOFT_output_limiter` 58 | pub soft_output_limiter: Option, 59 | /// `ALC_MAX_AUXILIARY_SENDS` 60 | /// Requires `ALC_EXT_EFX` 61 | pub max_aux_sends: Option, 62 | } 63 | 64 | 65 | /// Channel format for a loopback context. 66 | /// Requires `ALC_SOFT_loopback` 67 | #[derive(Copy, Clone, PartialEq, Eq, Debug)] 68 | pub enum LoopbackFormatChannels { 69 | /// `ALC_MONO_SOFT` 70 | Mono, 71 | /// `ALC_STEREO_SOFT` 72 | Stereo, 73 | /// `ALC_QUAD_SOFT` 74 | Quad, 75 | /// `ALC_5POINT1_SOFT` 76 | Mc51, 77 | /// `ALC_6POINT1_SOFT` 78 | Mc61, 79 | /// `ALC_7POINT1_SOFT` 80 | Mc71, 81 | } 82 | 83 | 84 | /// Sample format for a loopback context. 85 | /// Requires `ALC_SOFT_loopback` 86 | #[derive(Copy, Clone, PartialEq, Eq, Debug)] 87 | pub enum LoopbackFormatType { 88 | /// `ALC_UNSIGNED_BYTE_SOFT` 89 | U8, 90 | /// `ALC_SHORT_SOFT` 91 | I16, 92 | /// `ALC_FLOAT_SOFT` 93 | F32, 94 | } 95 | 96 | 97 | /// The current HRTF mode of a device. 98 | /// Requires `ALC_SOFT_HRTF` 99 | #[derive(Copy, Clone, PartialEq, Eq, Debug)] 100 | pub enum SoftHrtfStatus { 101 | /// `ALC_HRTF_DISABLED_SOFT` 102 | Disabled, 103 | /// `ALC_HRTF_ENABLED_SOFT` 104 | Enabled, 105 | /// `ALC_HRTF_DENIED_SOFT` 106 | Denied, 107 | /// `ALC_HRTF_REQUIRED_SOFT` 108 | Required, 109 | /// `ALC_HRTF_HEADPHONES_DETECTED_SOFT` 110 | HeadphonesDetected, 111 | /// `ALC_HRTF_UNSUPPORTED_FORMAT_SOFT` 112 | UnsupportedFormat, 113 | 114 | Unknown(sys::ALCint), 115 | } 116 | 117 | 118 | pub(crate) struct AltoInner { 119 | pub(crate) api: sys::AlApi, 120 | pub(crate) exts: ::ext::AlcNullCache, 121 | } 122 | 123 | 124 | /// This struct is the entry point of the API. Instantiating it will load an OpenAL implementation. 125 | /// From here, available devices can be queried and opened. 126 | pub struct Alto(pub(crate) Arc); 127 | 128 | 129 | /// Common capabilities expoed by both real and loopback devices. 130 | pub unsafe trait DeviceObject: Any { 131 | /// AltoInner instance from which this device was opened. 132 | fn alto(&self) -> &Alto; 133 | /// Specifier string used to open this device. 134 | fn specifier(&self) -> Option<&CStr>; 135 | /// Raw handle as exposed by OpenAL. 136 | fn as_raw(&self) -> *mut sys::ALCdevice; 137 | /// `alcIsExtensionPresent()` 138 | fn is_extension_present(&self, ext::Alc) -> bool; 139 | /// `alcGetIntegerv(ALC_CONNECTED)` 140 | /// Requires `ALC_EXT_disconnect` 141 | fn connected(&self) -> AltoResult; 142 | /// `alcGetStringiSOFT(ALC_HRTF_SPECIFIER_SOFT)` 143 | /// Requires `ALC_SOFT_HRTF` 144 | fn enumerate_soft_hrtfs(&self) -> Vec; 145 | /// `alcGetIntegerv(ALC_HRTF_STATUS_SOFT)` 146 | /// Requires `ALC_SOFT_HRTF` 147 | fn soft_hrtf_status(&self) -> SoftHrtfStatus; 148 | /// `alcGetIntegerv(ALC_OUTPUT_LIMITER_SOFT)` 149 | /// Requires `ALC_SOFT_output_limiter` 150 | fn soft_output_limiter(&self) -> bool; 151 | /// `alcGetIntegerv(ALC_MAX_AUXILIARY_SENDS)` 152 | /// Requires `ALC_EXT_EFX` 153 | fn max_aux_sends(&self) -> sys::ALCint; 154 | /// Return a new handle to this device. 155 | fn to_device(&self) -> Device; 156 | } 157 | 158 | 159 | pub(crate) struct DeviceInner { 160 | pub(crate) alto: Alto, 161 | spec: Option, 162 | pub(crate) dev: *mut sys::ALCdevice, 163 | pub(crate) exts: ext::AlcCache, 164 | } 165 | 166 | 167 | /// A regular output device. This is typically a device as reported by the operating system. 168 | pub struct OutputDevice(pub(crate) Arc); 169 | 170 | 171 | /// A sample frame that is supported as a loopback device output format. 172 | pub unsafe trait LoopbackFrame: SampleFrame { 173 | fn channels(&ext::ALC_SOFT_loopback) -> AltoResult; 174 | fn sample_ty(&ext::ALC_SOFT_loopback) -> AltoResult; 175 | } 176 | 177 | 178 | /// A loopback device that outputs audio to a memory buffer. 179 | /// Requires `ALC_SOFT_loopback` 180 | pub struct LoopbackDevice(pub(crate) Arc, pub(crate) PhantomData); 181 | 182 | 183 | /// A handle to any kind of output device. 184 | pub struct Device(pub(crate) Arc); 185 | 186 | 187 | /// A capture device from which audio data can be sampled. 188 | /// This is tyically an audio input as reported by the operating system. 189 | pub struct Capture { 190 | alto: Alto, 191 | spec: Option, 192 | dev: *mut sys::ALCdevice, 193 | marker: PhantomData, 194 | } 195 | 196 | 197 | impl Alto { 198 | /// Load the default OpenAL implementation for the platform. 199 | /// This will prefer OpenAL-Soft if it is present, otherwise it will search for a generic implementation. 200 | pub fn load_default() -> AltoResult { 201 | let api = sys::AlApi::load_default()?; 202 | let exts = unsafe { ext::AlcNullCache::new(&api, ptr::null_mut()) }; 203 | Ok(Alto(Arc::new(AltoInner{ 204 | api: api, 205 | exts: exts, 206 | }))).and_then(|a| a.check_version(ptr::null_mut()).map(|_| a)) 207 | } 208 | 209 | 210 | /// Loads a specific OpenAL implementation from a specififed path. 211 | pub fn load>(path: P) -> AltoResult { 212 | let api = sys::AlApi::load(path)?; 213 | let exts = unsafe { ext::AlcNullCache::new(&api, ptr::null_mut()) }; 214 | Ok(Alto(Arc::new(AltoInner{ 215 | api: api, 216 | exts: exts, 217 | }))).and_then(|a| a.check_version(ptr::null_mut()).map(|_| a)) 218 | } 219 | 220 | 221 | fn check_version(&self, dev: *mut sys::ALCdevice) -> AltoResult<()> { 222 | let mut major = 0; 223 | unsafe { self.0.api.alcGetIntegerv(dev, sys::ALC_MAJOR_VERSION, 1, &mut major); } 224 | let mut minor = 0; 225 | unsafe { self.0.api.alcGetIntegerv(dev, sys::ALC_MINOR_VERSION, 1, &mut minor); } 226 | 227 | if (major == 1 && minor >= 1) 228 | || (dev == ptr::null_mut() && major == 0 && minor == 0) // Creative's buggy router DLL won't report a version until you open a device 229 | { 230 | Ok(()) 231 | } else { 232 | Err(AltoError::UnsupportedVersion{major, minor}) 233 | } 234 | } 235 | 236 | 237 | /// Raw entry points of the OpenAL API. 238 | pub fn raw_api(&self) -> &sys::AlApi { &self.0.api } 239 | 240 | 241 | /// `alcGetString(ALC_DEFAULT_DEVICE_SPECIFIER)` 242 | pub fn default_output(&self) -> Option { 243 | let spec = if let Ok(ext::ALC_ENUMERATE_ALL_EXT{ALC_DEFAULT_ALL_DEVICES_SPECIFIER: Ok(dads), ..}) = self.0.exts.ALC_ENUMERATE_ALL_EXT { 244 | unsafe { self.0.api.alcGetString(ptr::null_mut(), dads) } 245 | } else { 246 | unsafe { self.0.api.alcGetString(ptr::null_mut(), sys::ALC_DEFAULT_DEVICE_SPECIFIER) } 247 | }; 248 | 249 | if spec == ptr::null() { 250 | None 251 | } else { 252 | unsafe { Some(CStr::from_ptr(spec).to_owned()) } 253 | } 254 | } 255 | 256 | 257 | /// `alcGetString(ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)` 258 | pub fn default_capture(&self) -> Option { 259 | let spec = unsafe { self.0.api.alcGetString(ptr::null_mut(), sys::ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER) }; 260 | 261 | if spec == ptr::null() { 262 | None 263 | } else { 264 | unsafe { Some(CStr::from_ptr(spec).to_owned()) } 265 | } 266 | } 267 | 268 | 269 | /// `alcGetString(ALC_DEVICE_SPECIFIER)` 270 | pub fn enumerate_outputs(&self) -> Vec { 271 | let spec = if let Ok(ext::ALC_ENUMERATE_ALL_EXT{ALC_ALL_DEVICES_SPECIFIER: Ok(ads), ..}) = self.0.exts.ALC_ENUMERATE_ALL_EXT { 272 | unsafe { self.0.api.alcGetString(ptr::null_mut(), ads) } 273 | } else { 274 | unsafe { self.0.api.alcGetString(ptr::null_mut(), sys::ALC_DEVICE_SPECIFIER) } 275 | }; 276 | Alto::parse_enum_spec(spec as *const u8) 277 | } 278 | 279 | 280 | /// `alcGetString(ALC_CAPTURE_DEVICE_SPECIFIER)` 281 | pub fn enumerate_captures(&self) -> Vec { 282 | let spec = unsafe { self.0.api.alcGetString(ptr::null_mut(), sys::ALC_CAPTURE_DEVICE_SPECIFIER) }; 283 | Alto::parse_enum_spec(spec as *const u8) 284 | } 285 | 286 | 287 | fn parse_enum_spec(spec: *const u8) -> Vec { 288 | let mut specs = Vec::with_capacity(0); 289 | 290 | if spec == ptr::null() { 291 | return specs; 292 | } 293 | 294 | let mut i = 0; 295 | loop { 296 | if unsafe { ptr::read(spec.offset(i)) == 0 && ptr::read(spec.offset(i + 1)) == 0 } { 297 | break; 298 | } 299 | 300 | i += 1; 301 | } 302 | 303 | specs.extend(unsafe { ::std::slice::from_raw_parts(spec as *const u8, i as usize) }.split(|c| *c == 0).map(|d| CString::new(d).unwrap())); 304 | 305 | specs 306 | } 307 | 308 | 309 | /// `alcOpenDevice()` 310 | pub fn open(&self, spec: Option<&CStr>) -> AltoResult { 311 | let spec = spec.map(|s| s.to_owned()).or_else(|| self.default_output()); 312 | let dev = unsafe { self.0.api.alcOpenDevice(spec.as_ref().map(|s| s.as_ptr()).unwrap_or(ptr::null())) }; 313 | 314 | if dev == ptr::null_mut() { 315 | Err(AltoError::InvalidDevice) 316 | } else { 317 | let dev = OutputDevice(Arc::new(DeviceInner{ 318 | alto: Alto(self.0.clone()), 319 | spec: spec, 320 | dev: dev, 321 | exts: unsafe { ext::AlcCache::new(&self.0.api, dev) }, 322 | })); 323 | self.check_version(dev.0.dev).map(|_| dev) 324 | } 325 | } 326 | 327 | 328 | /// `alcLoopbackOpenDeviceSOFT()` 329 | /// Requires `ALC_SOFT_loopback` 330 | pub fn open_loopback(&self, spec: Option<&CStr>) -> AltoResult> { 331 | let asl = self.0.exts.ALC_SOFT_loopback()?; 332 | asl.alcRenderSamplesSOFT?; 333 | 334 | let spec = spec.map(|s| s.to_owned());//.or_else(|| self.default_output()); 335 | let dev = unsafe { asl.alcLoopbackOpenDeviceSOFT?(spec.as_ref().map(|s| s.as_ptr()).unwrap_or(ptr::null())) }; 336 | 337 | if dev == ptr::null_mut() { 338 | Err(AltoError::InvalidDevice) 339 | } else { 340 | let dev = LoopbackDevice( 341 | Arc::new(DeviceInner{ 342 | alto: Alto(self.0.clone()), 343 | spec: spec, 344 | dev: dev, 345 | exts: unsafe { ext::AlcCache::new(&self.0.api, dev) }, 346 | }), 347 | PhantomData, 348 | ); 349 | self.check_version(dev.0.dev).map(|_| dev) 350 | } 351 | } 352 | 353 | 354 | /// `alcCaptureOpenDevice()` 355 | pub fn open_capture(&self, spec: Option<&CStr>, freq: sys::ALCuint, len: sys::ALCsizei) -> AltoResult> { 356 | let spec = spec.map(|s| s.to_owned()).or_else(|| self.default_capture()); 357 | let dev = unsafe { self.0.api.alcCaptureOpenDevice(spec.as_ref().map(|s| s.as_ptr()).unwrap_or(ptr::null()), freq, F::format().into_raw(None)?, len) }; 358 | 359 | if dev == ptr::null_mut() { 360 | Err(AltoError::InvalidDevice) 361 | } else { 362 | let dev = Capture{alto: Alto(self.0.clone()), spec: spec, dev: dev, marker: PhantomData}; 363 | //self.check_version(dev.dev).map(|_| dev) 364 | Ok(dev) 365 | } 366 | } 367 | 368 | 369 | #[doc(hidden)] 370 | pub fn get_error(&self, dev: *mut sys::ALCdevice) -> AltoResult<()> { 371 | match unsafe { self.0.api.alcGetError(dev)} { 372 | sys::ALC_NO_ERROR => Ok(()), 373 | e => Err(AltoError::from_alc(e)), 374 | } 375 | } 376 | } 377 | 378 | 379 | impl Clone for Alto { 380 | fn clone(&self) -> Alto { Alto(self.0.clone()) } 381 | } 382 | 383 | 384 | impl DeviceInner { 385 | #[inline] fn alto(&self) -> &Alto { &self.alto } 386 | #[inline] fn specifier(&self) -> Option<&CStr> { self.spec.as_ref().map(|s| s.as_ref()) } 387 | #[inline] fn as_raw(&self) -> *mut sys::ALCdevice { self.dev } 388 | 389 | 390 | /// `alcIsExtensionPresent()` 391 | pub fn is_extension_present(&self, ext: ext::Alc) -> bool { 392 | match ext { 393 | ext::Alc::Dedicated => self.exts.ALC_EXT_DEDICATED().is_ok(), 394 | ext::Alc::Disconnect => self.exts.ALC_EXT_DISCONNECT().is_ok(), 395 | ext::Alc::Efx => self.exts.ALC_EXT_EFX().is_ok(), 396 | ext::Alc::SoftHrtf => self.exts.ALC_SOFT_HRTF().is_ok(), 397 | ext::Alc::SoftOutputLimiter => self.exts.ALC_SOFT_output_limiter().is_ok(), 398 | ext::Alc::SoftPauseDevice => self.exts.ALC_SOFT_pause_device().is_ok(), 399 | } 400 | } 401 | 402 | 403 | /// `alcGetIntegerv(ALC_CONNECTED)` 404 | /// Requires `ALC_EXT_DISCONNECT` 405 | pub fn connected(&self) -> AltoResult { 406 | let mut value = 0; 407 | unsafe { self.alto.0.api.alcGetIntegerv(self.dev, self.exts.ALC_EXT_DISCONNECT()?.ALC_CONNECTED?, 1, &mut value); } 408 | Ok(value == sys::ALC_TRUE as sys::ALCint) 409 | } 410 | 411 | 412 | /// `alcGetStringiSOFT(ALC_NUM_HRTF_SPECIFIERS_SOFT)` 413 | /// Requires `ALC_SOFT_HRTF` 414 | pub fn enumerate_soft_hrtfs(&self) -> Vec { 415 | let mut spec_vec = Vec::with_capacity(0); 416 | 417 | let _ = (|| -> AltoResult<_> { 418 | let ash = self.exts.ALC_SOFT_HRTF()?; 419 | let mut value = 0; 420 | unsafe { self.alto.0.api.alcGetIntegerv(self.dev, ash.ALC_NUM_HRTF_SPECIFIERS_SOFT?, 1, &mut value); } 421 | 422 | for i in 0 .. value { 423 | unsafe { 424 | let spec = ash.alcGetStringiSOFT?(self.dev, ash.ALC_HRTF_SPECIFIER_SOFT?, i) as *mut _; 425 | spec_vec.push(self.alto.get_error(self.dev).map(|_| CStr::from_ptr(spec).to_owned())?); 426 | } 427 | } 428 | 429 | Ok(()) 430 | })(); 431 | 432 | spec_vec 433 | } 434 | 435 | 436 | /// `alcGetIntegerv(ALC_HRTF_STATUS_SOFT)` 437 | /// Requires `ALC_SOFT_HRTF` 438 | pub fn soft_hrtf_status(&self) -> SoftHrtfStatus { 439 | (|| -> AltoResult<_> { 440 | let ash = self.exts.ALC_SOFT_HRTF()?; 441 | 442 | let mut value = 0; 443 | unsafe { self.alto.0.api.alcGetIntegerv(self.dev, ash.ALC_HRTF_STATUS_SOFT?, 1, &mut value); } 444 | self.alto.get_error(self.dev).and_then(|_| match value { 445 | s if s == ash.ALC_HRTF_DISABLED_SOFT? => Ok(SoftHrtfStatus::Disabled), 446 | s if s == ash.ALC_HRTF_ENABLED_SOFT? => Ok(SoftHrtfStatus::Enabled), 447 | s if s == ash.ALC_HRTF_DENIED_SOFT? => Ok(SoftHrtfStatus::Denied), 448 | s if s == ash.ALC_HRTF_REQUIRED_SOFT? => Ok(SoftHrtfStatus::Required), 449 | s if s == ash.ALC_HRTF_HEADPHONES_DETECTED_SOFT? => Ok(SoftHrtfStatus::HeadphonesDetected), 450 | s if s == ash.ALC_HRTF_UNSUPPORTED_FORMAT_SOFT? => Ok(SoftHrtfStatus::UnsupportedFormat), 451 | s => Ok(SoftHrtfStatus::Unknown(s)), 452 | }) 453 | })().unwrap_or(SoftHrtfStatus::Disabled) 454 | } 455 | 456 | 457 | /// `alcGetIntegerv(ALC_OUTPUT_LIMITER_SOFT)` 458 | /// Requires `ALC_SOFT_output_limiter` 459 | pub fn soft_output_limiter(&self) -> bool { 460 | (|| -> AltoResult<_> { 461 | let asol = self.exts.ALC_SOFT_output_limiter()?; 462 | 463 | let mut value = 0; 464 | unsafe { self.alto.0.api.alcGetIntegerv(self.dev, asol.ALC_OUTPUT_LIMITER_SOFT?, 1, &mut value); } 465 | Ok(value == sys::ALC_TRUE as sys::ALCint) 466 | })().unwrap_or(false) 467 | } 468 | 469 | 470 | /// `alcGetIntegerv(ALC_MAX_AUXILIARY_SENDS)` 471 | /// Requires `ALC_EXT_EFX` 472 | pub fn max_aux_sends(&self) -> sys::ALCint { 473 | let mut value = 0; 474 | let _ = (|| -> AltoResult<_> { 475 | unsafe { self.alto.0.api.alcGetIntegerv(self.dev, self.exts.ALC_EXT_EFX()?.ALC_MAX_AUXILIARY_SENDS?, 1, &mut value); } 476 | Ok(()) 477 | })(); 478 | value 479 | } 480 | } 481 | 482 | 483 | impl Drop for DeviceInner { 484 | fn drop(&mut self) { 485 | unsafe { self.alto.0.api.alcCloseDevice(self.dev); } 486 | } 487 | } 488 | 489 | 490 | impl OutputDevice { 491 | fn make_attrs_vec(&self, attrs: Option) -> AltoResult>> { 492 | let mut attrs_vec = Vec::with_capacity(17); 493 | if let Some(attrs) = attrs { 494 | if let Some(freq) = attrs.frequency { 495 | attrs_vec.extend(&[sys::ALC_FREQUENCY, freq]); 496 | } 497 | if let Some(refresh) = attrs.refresh { 498 | attrs_vec.extend(&[sys::ALC_REFRESH, refresh]); 499 | } 500 | if let Some(mono) = attrs.mono_sources { 501 | attrs_vec.extend(&[sys::ALC_MONO_SOURCES, mono]); 502 | } 503 | if let Some(stereo) = attrs.stereo_sources { 504 | attrs_vec.extend(&[sys::ALC_STEREO_SOURCES, stereo]); 505 | } 506 | 507 | if let Ok(ash) = self.0.exts.ALC_SOFT_HRTF() { 508 | if let Some(hrtf) = attrs.soft_hrtf { 509 | attrs_vec.extend(&[ash.ALC_HRTF_SOFT?, if hrtf { sys::ALC_TRUE } else { sys::ALC_FALSE } as sys::ALCint]); 510 | } 511 | if let Some(hrtf_id) = attrs.soft_hrtf_id { 512 | attrs_vec.extend(&[ash.ALC_HRTF_ID_SOFT?, hrtf_id]); 513 | } 514 | } 515 | 516 | if let Ok(asol) = self.0.exts.ALC_SOFT_output_limiter() { 517 | if let Some(lim) = attrs.soft_output_limiter { 518 | attrs_vec.extend(&[asol.ALC_OUTPUT_LIMITER_SOFT?, if lim { sys::ALC_TRUE } else { sys::ALC_FALSE } as sys::ALCint]); 519 | } 520 | } 521 | 522 | if let Ok(efx) = self.0.exts.ALC_EXT_EFX() { 523 | if let Some(max_sends) = attrs.max_aux_sends { 524 | attrs_vec.extend(&[efx.ALC_MAX_AUXILIARY_SENDS?, max_sends]); 525 | } 526 | } 527 | 528 | attrs_vec.push(0); 529 | Ok(Some(attrs_vec)) 530 | } else { 531 | Ok(None) 532 | } 533 | } 534 | 535 | 536 | /// `alcCreateContext()` 537 | pub fn new_context(&self, attrs: Option) -> AltoResult { 538 | let attrs_vec = self.make_attrs_vec(attrs)?; 539 | let ctx = unsafe { self.0.alto.0.api.alcCreateContext(self.0.dev, attrs_vec.map(|a| a.as_slice().as_ptr()).unwrap_or(ptr::null())) }; 540 | if ctx == ptr::null_mut() { 541 | match self.0.alto.get_error(self.0.dev) { 542 | Ok(..) => Err(AltoError::NullError), 543 | Err(e) => Err(e), 544 | } 545 | } else { 546 | unsafe { Ok(Context::new(self.to_device(), ctx)) } 547 | } 548 | } 549 | 550 | 551 | /// `alcDevicePauseSOFT()` 552 | /// Requires `ALC_SOFT_pause_device` 553 | pub fn soft_pause(&self) -> AltoResult<()> { 554 | let adps = self.0.exts.ALC_SOFT_pause_device()?.alcDevicePauseSOFT?; 555 | 556 | unsafe { adps(self.0.dev) } 557 | if let Err(e) = self.0.alto.get_error(self.0.dev) { 558 | return Err(e); 559 | } 560 | 561 | Ok(()) 562 | } 563 | 564 | 565 | /// `alcDeviceResumeSOFT()` 566 | /// Requires `ALC_SOFT_pause_device` 567 | pub fn soft_resume(&self) { 568 | if let Ok(aspd) = self.0.exts.ALC_SOFT_pause_device() { 569 | if let Ok(adrs) = aspd.alcDeviceResumeSOFT { 570 | unsafe { adrs(self.0.dev); } 571 | } 572 | } 573 | } 574 | 575 | 576 | /// `alcDevicePauseSOFT()` 577 | /// Requires `ALC_SOFT_HRTF` 578 | pub fn soft_reset(&self, attrs: Option) -> AltoResult<()> { 579 | let ards = self.0.exts.ALC_SOFT_HRTF()?.alcResetDeviceSOFT?; 580 | let attrs_vec = self.make_attrs_vec(attrs.into())?; 581 | unsafe { ards(self.0.dev, attrs_vec.map(|a| a.as_slice().as_ptr()).unwrap_or(ptr::null())) }; 582 | self.0.alto.get_error(self.0.dev) 583 | } 584 | } 585 | 586 | 587 | unsafe impl DeviceObject for OutputDevice { 588 | #[inline] fn alto(&self) -> &Alto { self.0.alto() } 589 | #[inline] fn specifier(&self) -> Option<&CStr> { self.0.specifier() } 590 | #[inline] fn as_raw(&self) -> *mut sys::ALCdevice { self.0.as_raw() } 591 | #[inline] fn connected(&self) -> AltoResult { self.0.connected() } 592 | 593 | #[inline] fn is_extension_present(&self, ext: ext::Alc) -> bool { self.0.is_extension_present(ext) } 594 | #[inline] fn enumerate_soft_hrtfs(&self) -> Vec { self.0.enumerate_soft_hrtfs() } 595 | #[inline] fn soft_hrtf_status(&self) -> SoftHrtfStatus { self.0.soft_hrtf_status() } 596 | #[inline] fn soft_output_limiter(&self) -> bool { self.0.soft_output_limiter() } 597 | #[inline] fn max_aux_sends(&self) -> sys::ALCint { self.0.max_aux_sends() } 598 | #[inline] fn to_device(&self) -> Device { Device(self.0.clone()) } 599 | } 600 | 601 | 602 | impl PartialEq for OutputDevice { 603 | fn eq(&self, other: &OutputDevice) -> bool { 604 | self.0.dev == other.0.dev 605 | } 606 | } 607 | impl Eq for OutputDevice { } 608 | 609 | 610 | unsafe impl Send for OutputDevice { } 611 | unsafe impl Sync for OutputDevice { } 612 | 613 | 614 | impl LoopbackDevice { 615 | fn make_attrs_vec(&self, freq: sys::ALCint, attrs: Option) -> AltoResult> { 616 | let asl = self.0.alto.0.exts.ALC_SOFT_loopback()?; 617 | 618 | let mut attrs_vec = Vec::with_capacity(19); 619 | attrs_vec.extend(&[sys::ALC_FREQUENCY, freq]); 620 | attrs_vec.extend(&[asl.ALC_FORMAT_CHANNELS_SOFT?, F::channels(&asl)?]); 621 | attrs_vec.extend(&[asl.ALC_FORMAT_TYPE_SOFT?, F::sample_ty(&asl)?]); 622 | if let Some(attrs) = attrs { 623 | if let Some(mono) = attrs.mono_sources { 624 | attrs_vec.extend(&[sys::ALC_MONO_SOURCES, mono]); 625 | } 626 | if let Some(stereo) = attrs.stereo_sources { 627 | attrs_vec.extend(&[sys::ALC_STEREO_SOURCES, stereo]); 628 | } 629 | 630 | if let Ok(ash) = self.0.exts.ALC_SOFT_HRTF() { 631 | if let Some(hrtf) = attrs.soft_hrtf { 632 | attrs_vec.extend(&[ash.ALC_HRTF_SOFT?, if hrtf { sys::ALC_TRUE } else { sys::ALC_FALSE } as sys::ALCint]); 633 | } 634 | if let Some(hrtf_id) = attrs.soft_hrtf_id { 635 | attrs_vec.extend(&[ash.ALC_HRTF_ID_SOFT?, hrtf_id]); 636 | } 637 | } 638 | 639 | if let Ok(asol) = self.0.exts.ALC_SOFT_output_limiter() { 640 | if let Some(lim) = attrs.soft_output_limiter { 641 | attrs_vec.extend(&[asol.ALC_OUTPUT_LIMITER_SOFT?, if lim { sys::ALC_TRUE } else { sys::ALC_FALSE } as sys::ALCint]); 642 | } 643 | } 644 | 645 | if let Ok(efx) = self.0.exts.ALC_EXT_EFX() { 646 | if let Some(max_sends) = attrs.max_aux_sends { 647 | attrs_vec.extend(&[efx.ALC_MAX_AUXILIARY_SENDS?, max_sends]); 648 | } 649 | } 650 | } 651 | attrs_vec.push(0); 652 | Ok(attrs_vec) 653 | } 654 | 655 | 656 | /// `alcCreateContext()` 657 | pub fn new_context(&self, freq: sys::ALCint, attrs: Option) -> AltoResult { 658 | let attrs_vec = self.make_attrs_vec(freq, attrs.into())?; 659 | let ctx = unsafe { self.0.alto.0.api.alcCreateContext(self.0.dev, attrs_vec.as_slice().as_ptr()) }; 660 | if ctx == ptr::null_mut() { 661 | match self.0.alto.get_error(self.0.dev) { 662 | Ok(..) => Err(AltoError::NullError), 663 | Err(e) => Err(e), 664 | } 665 | } else { 666 | unsafe { Ok(Context::new(self.to_device(), ctx)) } 667 | } 668 | } 669 | 670 | 671 | /// `alcRenderSamplesSOFT()` 672 | /// Returns the number of sample frames rendered to the slice. 673 | pub fn soft_render_samples>(&mut self, mut data: R) -> usize { 674 | let (data, size) = data.as_buffer_data_mut(); 675 | let len = cmp::min(size / mem::size_of::(), sys::ALCsizei::max_value() as usize); 676 | if len == 0 { 677 | return 0; 678 | } 679 | 680 | let asl = self.0.alto.0.exts.ALC_SOFT_loopback().unwrap(); 681 | 682 | unsafe { asl.alcRenderSamplesSOFT.unwrap()(self.0.dev, data, len as sys::ALCsizei); } 683 | 684 | len as usize 685 | } 686 | 687 | 688 | /// `alcDevicePauseSOFT()` 689 | /// Requires `ALC_SOFT_HRTF` 690 | pub fn soft_reset(&self, freq: sys::ALCint, attrs: Option) -> AltoResult<()> { 691 | let ards = self.0.exts.ALC_SOFT_HRTF()?.alcResetDeviceSOFT?; 692 | 693 | let attrs_vec = self.make_attrs_vec(freq, attrs.into()); 694 | unsafe { ards(self.0.dev, attrs_vec.map(|a| a.as_slice().as_ptr()).unwrap_or(ptr::null())) }; 695 | self.0.alto.get_error(self.0.dev) 696 | } 697 | } 698 | 699 | 700 | unsafe impl DeviceObject for LoopbackDevice { 701 | #[inline] fn alto(&self) -> &Alto { self.0.alto() } 702 | #[inline] fn specifier(&self) -> Option<&CStr> { self.0.specifier() } 703 | #[inline] fn as_raw(&self) -> *mut sys::ALCdevice { self.0.as_raw() } 704 | #[inline] fn connected(&self) -> AltoResult { self.0.connected() } 705 | 706 | #[inline] fn is_extension_present(&self, ext: ext::Alc) -> bool { self.0.is_extension_present(ext) } 707 | #[inline] fn enumerate_soft_hrtfs(&self) -> Vec { self.0.enumerate_soft_hrtfs() } 708 | #[inline] fn soft_hrtf_status(&self) -> SoftHrtfStatus { self.0.soft_hrtf_status() } 709 | #[inline] fn soft_output_limiter(&self) -> bool { self.0.soft_output_limiter() } 710 | #[inline] fn max_aux_sends(&self) -> sys::ALCint { self.0.max_aux_sends() } 711 | #[inline] fn to_device(&self) -> Device { Device(self.0.clone()) } 712 | } 713 | 714 | 715 | impl PartialEq for LoopbackDevice { 716 | fn eq(&self, other: &LoopbackDevice) -> bool { 717 | self.0.dev == other.0.dev 718 | } 719 | } 720 | impl Eq for LoopbackDevice { } 721 | 722 | 723 | unsafe impl Send for LoopbackDevice { } 724 | unsafe impl Sync for LoopbackDevice { } 725 | 726 | 727 | unsafe impl DeviceObject for Device { 728 | #[inline] fn alto(&self) -> &Alto { self.0.alto() } 729 | #[inline] fn specifier(&self) -> Option<&CStr> { self.0.specifier() } 730 | #[inline] fn as_raw(&self) -> *mut sys::ALCdevice { self.0.as_raw() } 731 | #[inline] fn connected(&self) -> AltoResult { self.0.connected() } 732 | 733 | #[inline] fn is_extension_present(&self, ext: ext::Alc) -> bool { self.0.is_extension_present(ext) } 734 | #[inline] fn enumerate_soft_hrtfs(&self) -> Vec { self.0.enumerate_soft_hrtfs() } 735 | #[inline] fn soft_hrtf_status(&self) -> SoftHrtfStatus { self.0.soft_hrtf_status() } 736 | #[inline] fn soft_output_limiter(&self) -> bool { self.0.soft_output_limiter() } 737 | #[inline] fn max_aux_sends(&self) -> sys::ALCint { self.0.max_aux_sends() } 738 | #[inline] fn to_device(&self) -> Device { Device(self.0.clone()) } 739 | } 740 | 741 | 742 | impl PartialEq for DeviceObject { 743 | fn eq(&self, other: &DeviceObject) -> bool { 744 | self.as_raw() == other.as_raw() 745 | } 746 | } 747 | impl Eq for DeviceObject { } 748 | 749 | 750 | impl Capture { 751 | /// AltoInner struct from which this device was opened. 752 | #[inline] pub fn alto(&self) -> &Alto { &self.alto } 753 | /// Specifier used to open this device. 754 | #[inline] pub fn specifier(&self) -> Option<&CStr> { self.spec.as_ref().map(|s| s.as_ref()) } 755 | /// Raw device handle as reported by OpenAL. 756 | #[inline] pub fn as_raw(&self) -> *mut sys::ALCdevice { self.dev } 757 | 758 | 759 | /// `alcCaptureStart()` 760 | pub fn start(&mut self) { 761 | unsafe { self.alto.0.api.alcCaptureStart(self.dev); } 762 | } 763 | 764 | 765 | /// `alcCaptureStop()` 766 | pub fn stop(&mut self) { 767 | unsafe { self.alto.0.api.alcCaptureStop(self.dev); } 768 | } 769 | 770 | 771 | /// `alcGetIntegerv(ALC_CAPTURE_SAMPLES)` 772 | pub fn samples_len(&self) -> sys::ALCint { 773 | let mut samples = 0; 774 | unsafe { self.alto.0.api.alcGetIntegerv(self.dev, sys::ALC_CAPTURE_SAMPLES, 1, &mut samples); } 775 | samples 776 | } 777 | 778 | 779 | /// `alcCaptureSamples()` 780 | /// Returns the number of sample-frames captured to the slice. 781 | pub fn capture_samples>(&mut self, mut data: R) -> AltoResult { 782 | let (data, size) = data.as_buffer_data_mut(); 783 | let len = cmp::min(size / mem::size_of::(), self.samples_len() as usize); 784 | if len == 0 { 785 | return Ok(0); 786 | } 787 | 788 | unsafe { self.alto.0.api.alcCaptureSamples(self.dev, data, len as sys::ALCsizei); } 789 | Ok(len as usize) 790 | } 791 | } 792 | 793 | 794 | impl PartialEq for Capture { 795 | fn eq(&self, other: &Capture) -> bool { 796 | self.dev == other.dev 797 | } 798 | } 799 | impl Eq for Capture { } 800 | 801 | impl Drop for Capture { 802 | fn drop(&mut self) { 803 | unsafe { self.alto.0.api.alcCaptureCloseDevice(self.dev); } 804 | } 805 | } 806 | 807 | unsafe impl Send for Capture { } 808 | -------------------------------------------------------------------------------- /src/efx/presets.rs: -------------------------------------------------------------------------------- 1 | /// Represents a preset for the `AL_EFFECT_REVERB` and `AL_EFFECT_EAXREVERB` effects. 2 | pub struct EaxReverbProperties { 3 | pub density: f32, 4 | pub diffusion: f32, 5 | pub gain: f32, 6 | pub gainhf: f32, 7 | pub gainlf: f32, 8 | pub decay_time: f32, 9 | pub decay_hfratio: f32, 10 | pub decay_lfratio: f32, 11 | pub reflections_gain: f32, 12 | pub reflections_delay: f32, 13 | pub reflections_pan: [f32; 3], 14 | pub late_reverb_gain: f32, 15 | pub late_reverb_delay: f32, 16 | pub late_reverb_pan: [f32; 3], 17 | pub echo_time: f32, 18 | pub echo_depth: f32, 19 | pub modulation_time: f32, 20 | pub modulation_depth: f32, 21 | pub air_absorption_gainhf: f32, 22 | pub hfreference: f32, 23 | pub lfreference: f32, 24 | pub room_rolloff_factor: f32, 25 | pub decay_hflimit: bool, 26 | } 27 | 28 | 29 | macro_rules! reverb_preset { 30 | { 31 | $density:expr, 32 | $diffusion:expr, 33 | $gain:expr, 34 | $gainhf:expr, 35 | $gainlf:expr, 36 | $decay_time:expr, 37 | $decay_hfratio:expr, 38 | $decay_lfratio:expr, 39 | $reflections_gain:expr, 40 | $reflections_delay:expr, 41 | $reflections_pan:expr, 42 | $late_reverb_gain:expr, 43 | $late_reverb_delay:expr, 44 | $late_reverb_pan:expr, 45 | $echo_time:expr, 46 | $echo_depth:expr, 47 | $modulation_time:expr, 48 | $modulation_depth:expr, 49 | $air_absorption_gainhf:expr, 50 | $hfreference:expr, 51 | $lfreference:expr, 52 | $room_rolloff_factor:expr, 53 | $decay_hflimit:expr 54 | } => { 55 | EaxReverbProperties{ 56 | density: $density, 57 | diffusion: $diffusion, 58 | gain: $gain, 59 | gainhf: $gainhf, 60 | gainlf: $gainlf, 61 | decay_time: $decay_time, 62 | decay_hfratio: $decay_hfratio, 63 | decay_lfratio: $decay_lfratio, 64 | reflections_gain: $reflections_gain, 65 | reflections_delay: $reflections_delay, 66 | reflections_pan: $reflections_pan, 67 | late_reverb_gain: $late_reverb_gain, 68 | late_reverb_delay: $late_reverb_delay, 69 | late_reverb_pan: $late_reverb_pan, 70 | echo_time: $echo_time, 71 | echo_depth: $echo_depth, 72 | modulation_time: $modulation_time, 73 | modulation_depth: $modulation_depth, 74 | air_absorption_gainhf: $air_absorption_gainhf, 75 | hfreference: $hfreference, 76 | lfreference: $lfreference, 77 | room_rolloff_factor: $room_rolloff_factor, 78 | decay_hflimit: $decay_hflimit, 79 | } 80 | }; 81 | } 82 | 83 | 84 | pub static REVERB_PRESET_GENERIC: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.8913, 1.0000, 1.4900, 0.8300, 1.0000, 0.0500, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0110, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 85 | pub static REVERB_PRESET_PADDEDCELL: EaxReverbProperties = reverb_preset! { 0.1715, 1.0000, 0.3162, 0.0010, 1.0000, 0.1700, 0.1000, 1.0000, 0.2500, 0.0010, [ 0.0000, 0.0000, 0.0000 ], 1.2691, 0.0020, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 86 | pub static REVERB_PRESET_ROOM: EaxReverbProperties = reverb_preset! { 0.4287, 1.0000, 0.3162, 0.5929, 1.0000, 0.4000, 0.8300, 1.0000, 0.1503, 0.0020, [ 0.0000, 0.0000, 0.0000 ], 1.0629, 0.0030, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 87 | pub static REVERB_PRESET_BATHROOM: EaxReverbProperties = reverb_preset! { 0.1715, 1.0000, 0.3162, 0.2512, 1.0000, 1.4900, 0.5400, 1.0000, 0.6531, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 3.2734, 0.0110, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 88 | pub static REVERB_PRESET_LIVINGROOM: EaxReverbProperties = reverb_preset! { 0.9766, 1.0000, 0.3162, 0.0010, 1.0000, 0.5000, 0.1000, 1.0000, 0.2051, 0.0030, [ 0.0000, 0.0000, 0.0000 ], 0.2805, 0.0040, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 89 | pub static REVERB_PRESET_STONEROOM: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.7079, 1.0000, 2.3100, 0.6400, 1.0000, 0.4411, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 1.1003, 0.0170, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 90 | pub static REVERB_PRESET_AUDITORIUM: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.5781, 1.0000, 4.3200, 0.5900, 1.0000, 0.4032, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 0.7170, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 91 | pub static REVERB_PRESET_CONCERTHALL: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.5623, 1.0000, 3.9200, 0.7000, 1.0000, 0.2427, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 0.9977, 0.0290, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 92 | pub static REVERB_PRESET_CAVE: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 1.0000, 1.0000, 2.9100, 1.3000, 1.0000, 0.5000, 0.0150, [ 0.0000, 0.0000, 0.0000 ], 0.7063, 0.0220, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 93 | pub static REVERB_PRESET_ARENA: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.4477, 1.0000, 7.2400, 0.3300, 1.0000, 0.2612, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 1.0186, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 94 | pub static REVERB_PRESET_HANGAR: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.3162, 1.0000, 10.0500, 0.2300, 1.0000, 0.5000, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 1.2560, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 95 | pub static REVERB_PRESET_CARPETEDHALLWAY: EaxReverbProperties = reverb_preset! { 0.4287, 1.0000, 0.3162, 0.0100, 1.0000, 0.3000, 0.1000, 1.0000, 0.1215, 0.0020, [ 0.0000, 0.0000, 0.0000 ], 0.1531, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 96 | pub static REVERB_PRESET_HALLWAY: EaxReverbProperties = reverb_preset! { 0.3645, 1.0000, 0.3162, 0.7079, 1.0000, 1.4900, 0.5900, 1.0000, 0.2458, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 1.6615, 0.0110, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 97 | pub static REVERB_PRESET_STONECORRIDOR: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.7612, 1.0000, 2.7000, 0.7900, 1.0000, 0.2472, 0.0130, [ 0.0000, 0.0000, 0.0000 ], 1.5758, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 98 | pub static REVERB_PRESET_ALLEY: EaxReverbProperties = reverb_preset! { 1.0000, 0.3000, 0.3162, 0.7328, 1.0000, 1.4900, 0.8600, 1.0000, 0.2500, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 0.9954, 0.0110, [ 0.0000, 0.0000, 0.0000 ], 0.1250, 0.9500, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 99 | pub static REVERB_PRESET_FOREST: EaxReverbProperties = reverb_preset! { 1.0000, 0.3000, 0.3162, 0.0224, 1.0000, 1.4900, 0.5400, 1.0000, 0.0525, 0.1620, [ 0.0000, 0.0000, 0.0000 ], 0.7682, 0.0880, [ 0.0000, 0.0000, 0.0000 ], 0.1250, 1.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 100 | pub static REVERB_PRESET_CITY: EaxReverbProperties = reverb_preset! { 1.0000, 0.5000, 0.3162, 0.3981, 1.0000, 1.4900, 0.6700, 1.0000, 0.0730, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 0.1427, 0.0110, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 101 | pub static REVERB_PRESET_MOUNTAINS: EaxReverbProperties = reverb_preset! { 1.0000, 0.2700, 0.3162, 0.0562, 1.0000, 1.4900, 0.2100, 1.0000, 0.0407, 0.3000, [ 0.0000, 0.0000, 0.0000 ], 0.1919, 0.1000, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 1.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 102 | pub static REVERB_PRESET_QUARRY: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.3162, 1.0000, 1.4900, 0.8300, 1.0000, 0.0000, 0.0610, [ 0.0000, 0.0000, 0.0000 ], 1.7783, 0.0250, [ 0.0000, 0.0000, 0.0000 ], 0.1250, 0.7000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 103 | pub static REVERB_PRESET_PLAIN: EaxReverbProperties = reverb_preset! { 1.0000, 0.2100, 0.3162, 0.1000, 1.0000, 1.4900, 0.5000, 1.0000, 0.0585, 0.1790, [ 0.0000, 0.0000, 0.0000 ], 0.1089, 0.1000, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 1.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 104 | pub static REVERB_PRESET_PARKINGLOT: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 1.0000, 1.0000, 1.6500, 1.5000, 1.0000, 0.2082, 0.0080, [ 0.0000, 0.0000, 0.0000 ], 0.2652, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 105 | pub static REVERB_PRESET_SEWERPIPE: EaxReverbProperties = reverb_preset! { 0.3071, 0.8000, 0.3162, 0.3162, 1.0000, 2.8100, 0.1400, 1.0000, 1.6387, 0.0140, [ 0.0000, 0.0000, 0.0000 ], 3.2471, 0.0210, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 106 | pub static REVERB_PRESET_UNDERWATER: EaxReverbProperties = reverb_preset! { 0.3645, 1.0000, 0.3162, 0.0100, 1.0000, 1.4900, 0.1000, 1.0000, 0.5963, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 7.0795, 0.0110, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 1.1800, 0.3480, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 107 | pub static REVERB_PRESET_DRUGGED: EaxReverbProperties = reverb_preset! { 0.4287, 0.5000, 0.3162, 1.0000, 1.0000, 8.3900, 1.3900, 1.0000, 0.8760, 0.0020, [ 0.0000, 0.0000, 0.0000 ], 3.1081, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 1.0000, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 108 | pub static REVERB_PRESET_DIZZY: EaxReverbProperties = reverb_preset! { 0.3645, 0.6000, 0.3162, 0.6310, 1.0000, 17.2300, 0.5600, 1.0000, 0.1392, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 0.4937, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 1.0000, 0.8100, 0.3100, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 109 | pub static REVERB_PRESET_PSYCHOTIC: EaxReverbProperties = reverb_preset! { 0.0625, 0.5000, 0.3162, 0.8404, 1.0000, 7.5600, 0.9100, 1.0000, 0.4864, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 2.4378, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 4.0000, 1.0000, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 110 | 111 | pub static REVERB_PRESET_CASTLE_SMALLROOM: EaxReverbProperties = reverb_preset! { 1.0000, 0.8900, 0.3162, 0.3981, 0.1000, 1.2200, 0.8300, 0.3100, 0.8913, 0.0220, [ 0.0000, 0.0000, 0.0000 ], 1.9953, 0.0110, [ 0.0000, 0.0000, 0.0000 ], 0.1380, 0.0800, 0.2500, 0.0000, 0.9943, 5168.6001, 139.5000, 0.0000, true }; 112 | pub static REVERB_PRESET_CASTLE_SHORTPASSAGE: EaxReverbProperties = reverb_preset! { 1.0000, 0.8900, 0.3162, 0.3162, 0.1000, 2.3200, 0.8300, 0.3100, 0.8913, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0230, [ 0.0000, 0.0000, 0.0000 ], 0.1380, 0.0800, 0.2500, 0.0000, 0.9943, 5168.6001, 139.5000, 0.0000, true }; 113 | pub static REVERB_PRESET_CASTLE_MEDIUMROOM: EaxReverbProperties = reverb_preset! { 1.0000, 0.9300, 0.3162, 0.2818, 0.1000, 2.0400, 0.8300, 0.4600, 0.6310, 0.0220, [ 0.0000, 0.0000, 0.0000 ], 1.5849, 0.0110, [ 0.0000, 0.0000, 0.0000 ], 0.1550, 0.0300, 0.2500, 0.0000, 0.9943, 5168.6001, 139.5000, 0.0000, true }; 114 | pub static REVERB_PRESET_CASTLE_LARGEROOM: EaxReverbProperties = reverb_preset! { 1.0000, 0.8200, 0.3162, 0.2818, 0.1259, 2.5300, 0.8300, 0.5000, 0.4467, 0.0340, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0160, [ 0.0000, 0.0000, 0.0000 ], 0.1850, 0.0700, 0.2500, 0.0000, 0.9943, 5168.6001, 139.5000, 0.0000, true }; 115 | pub static REVERB_PRESET_CASTLE_LONGPASSAGE: EaxReverbProperties = reverb_preset! { 1.0000, 0.8900, 0.3162, 0.3981, 0.1000, 3.4200, 0.8300, 0.3100, 0.8913, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 1.4125, 0.0230, [ 0.0000, 0.0000, 0.0000 ], 0.1380, 0.0800, 0.2500, 0.0000, 0.9943, 5168.6001, 139.5000, 0.0000, true }; 116 | pub static REVERB_PRESET_CASTLE_HALL: EaxReverbProperties = reverb_preset! { 1.0000, 0.8100, 0.3162, 0.2818, 0.1778, 3.1400, 0.7900, 0.6200, 0.1778, 0.0560, [ 0.0000, 0.0000, 0.0000 ], 1.1220, 0.0240, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5168.6001, 139.5000, 0.0000, true }; 117 | pub static REVERB_PRESET_CASTLE_CUPBOARD: EaxReverbProperties = reverb_preset! { 1.0000, 0.8900, 0.3162, 0.2818, 0.1000, 0.6700, 0.8700, 0.3100, 1.4125, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 3.5481, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 0.1380, 0.0800, 0.2500, 0.0000, 0.9943, 5168.6001, 139.5000, 0.0000, true }; 118 | pub static REVERB_PRESET_CASTLE_COURTYARD: EaxReverbProperties = reverb_preset! { 1.0000, 0.4200, 0.3162, 0.4467, 0.1995, 2.1300, 0.6100, 0.2300, 0.2239, 0.1600, [ 0.0000, 0.0000, 0.0000 ], 0.7079, 0.0360, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.3700, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 119 | pub static REVERB_PRESET_CASTLE_ALCOVE: EaxReverbProperties = reverb_preset! { 1.0000, 0.8900, 0.3162, 0.5012, 0.1000, 1.6400, 0.8700, 0.3100, 1.0000, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 1.4125, 0.0340, [ 0.0000, 0.0000, 0.0000 ], 0.1380, 0.0800, 0.2500, 0.0000, 0.9943, 5168.6001, 139.5000, 0.0000, true }; 120 | 121 | pub static REVERB_PRESET_FACTORY_SMALLROOM: EaxReverbProperties = reverb_preset! { 0.3645, 0.8200, 0.3162, 0.7943, 0.5012, 1.7200, 0.6500, 1.3100, 0.7079, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 1.7783, 0.0240, [ 0.0000, 0.0000, 0.0000 ], 0.1190, 0.0700, 0.2500, 0.0000, 0.9943, 3762.6001, 362.5000, 0.0000, true }; 122 | pub static REVERB_PRESET_FACTORY_SHORTPASSAGE: EaxReverbProperties = reverb_preset! { 0.3645, 0.6400, 0.2512, 0.7943, 0.5012, 2.5300, 0.6500, 1.3100, 1.0000, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0380, [ 0.0000, 0.0000, 0.0000 ], 0.1350, 0.2300, 0.2500, 0.0000, 0.9943, 3762.6001, 362.5000, 0.0000, true }; 123 | pub static REVERB_PRESET_FACTORY_MEDIUMROOM: EaxReverbProperties = reverb_preset! { 0.4287, 0.8200, 0.2512, 0.7943, 0.5012, 2.7600, 0.6500, 1.3100, 0.2818, 0.0220, [ 0.0000, 0.0000, 0.0000 ], 1.4125, 0.0230, [ 0.0000, 0.0000, 0.0000 ], 0.1740, 0.0700, 0.2500, 0.0000, 0.9943, 3762.6001, 362.5000, 0.0000, true }; 124 | pub static REVERB_PRESET_FACTORY_LARGEROOM: EaxReverbProperties = reverb_preset! { 0.4287, 0.7500, 0.2512, 0.7079, 0.6310, 4.2400, 0.5100, 1.3100, 0.1778, 0.0390, [ 0.0000, 0.0000, 0.0000 ], 1.1220, 0.0230, [ 0.0000, 0.0000, 0.0000 ], 0.2310, 0.0700, 0.2500, 0.0000, 0.9943, 3762.6001, 362.5000, 0.0000, true }; 125 | pub static REVERB_PRESET_FACTORY_LONGPASSAGE: EaxReverbProperties = reverb_preset! { 0.3645, 0.6400, 0.2512, 0.7943, 0.5012, 4.0600, 0.6500, 1.3100, 1.0000, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0370, [ 0.0000, 0.0000, 0.0000 ], 0.1350, 0.2300, 0.2500, 0.0000, 0.9943, 3762.6001, 362.5000, 0.0000, true }; 126 | pub static REVERB_PRESET_FACTORY_HALL: EaxReverbProperties = reverb_preset! { 0.4287, 0.7500, 0.3162, 0.7079, 0.6310, 7.4300, 0.5100, 1.3100, 0.0631, 0.0730, [ 0.0000, 0.0000, 0.0000 ], 0.8913, 0.0270, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0700, 0.2500, 0.0000, 0.9943, 3762.6001, 362.5000, 0.0000, true }; 127 | pub static REVERB_PRESET_FACTORY_CUPBOARD: EaxReverbProperties = reverb_preset! { 0.3071, 0.6300, 0.2512, 0.7943, 0.5012, 0.4900, 0.6500, 1.3100, 1.2589, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 1.9953, 0.0320, [ 0.0000, 0.0000, 0.0000 ], 0.1070, 0.0700, 0.2500, 0.0000, 0.9943, 3762.6001, 362.5000, 0.0000, true }; 128 | pub static REVERB_PRESET_FACTORY_COURTYARD: EaxReverbProperties = reverb_preset! { 0.3071, 0.5700, 0.3162, 0.3162, 0.6310, 2.3200, 0.2900, 0.5600, 0.2239, 0.1400, [ 0.0000, 0.0000, 0.0000 ], 0.3981, 0.0390, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.2900, 0.2500, 0.0000, 0.9943, 3762.6001, 362.5000, 0.0000, true }; 129 | pub static REVERB_PRESET_FACTORY_ALCOVE: EaxReverbProperties = reverb_preset! { 0.3645, 0.5900, 0.2512, 0.7943, 0.5012, 3.1400, 0.6500, 1.3100, 1.4125, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 1.0000, 0.0380, [ 0.0000, 0.0000, 0.0000 ], 0.1140, 0.1000, 0.2500, 0.0000, 0.9943, 3762.6001, 362.5000, 0.0000, true }; 130 | 131 | pub static REVERB_PRESET_ICEPALACE_SMALLROOM: EaxReverbProperties = reverb_preset! { 1.0000, 0.8400, 0.3162, 0.5623, 0.2818, 1.5100, 1.5300, 0.2700, 0.8913, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 1.4125, 0.0110, [ 0.0000, 0.0000, 0.0000 ], 0.1640, 0.1400, 0.2500, 0.0000, 0.9943, 12428.5000, 99.6000, 0.0000, true }; 132 | pub static REVERB_PRESET_ICEPALACE_SHORTPASSAGE: EaxReverbProperties = reverb_preset! { 1.0000, 0.7500, 0.3162, 0.5623, 0.2818, 1.7900, 1.4600, 0.2800, 0.5012, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 1.1220, 0.0190, [ 0.0000, 0.0000, 0.0000 ], 0.1770, 0.0900, 0.2500, 0.0000, 0.9943, 12428.5000, 99.6000, 0.0000, true }; 133 | pub static REVERB_PRESET_ICEPALACE_MEDIUMROOM: EaxReverbProperties = reverb_preset! { 1.0000, 0.8700, 0.3162, 0.5623, 0.4467, 2.2200, 1.5300, 0.3200, 0.3981, 0.0390, [ 0.0000, 0.0000, 0.0000 ], 1.1220, 0.0270, [ 0.0000, 0.0000, 0.0000 ], 0.1860, 0.1200, 0.2500, 0.0000, 0.9943, 12428.5000, 99.6000, 0.0000, true }; 134 | pub static REVERB_PRESET_ICEPALACE_LARGEROOM: EaxReverbProperties = reverb_preset! { 1.0000, 0.8100, 0.3162, 0.5623, 0.4467, 3.1400, 1.5300, 0.3200, 0.2512, 0.0390, [ 0.0000, 0.0000, 0.0000 ], 1.0000, 0.0270, [ 0.0000, 0.0000, 0.0000 ], 0.2140, 0.1100, 0.2500, 0.0000, 0.9943, 12428.5000, 99.6000, 0.0000, true }; 135 | pub static REVERB_PRESET_ICEPALACE_LONGPASSAGE: EaxReverbProperties = reverb_preset! { 1.0000, 0.7700, 0.3162, 0.5623, 0.3981, 3.0100, 1.4600, 0.2800, 0.7943, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0250, [ 0.0000, 0.0000, 0.0000 ], 0.1860, 0.0400, 0.2500, 0.0000, 0.9943, 12428.5000, 99.6000, 0.0000, true }; 136 | pub static REVERB_PRESET_ICEPALACE_HALL: EaxReverbProperties = reverb_preset! { 1.0000, 0.7600, 0.3162, 0.4467, 0.5623, 5.4900, 1.5300, 0.3800, 0.1122, 0.0540, [ 0.0000, 0.0000, 0.0000 ], 0.6310, 0.0520, [ 0.0000, 0.0000, 0.0000 ], 0.2260, 0.1100, 0.2500, 0.0000, 0.9943, 12428.5000, 99.6000, 0.0000, true }; 137 | pub static REVERB_PRESET_ICEPALACE_CUPBOARD: EaxReverbProperties = reverb_preset! { 1.0000, 0.8300, 0.3162, 0.5012, 0.2239, 0.7600, 1.5300, 0.2600, 1.1220, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 1.9953, 0.0160, [ 0.0000, 0.0000, 0.0000 ], 0.1430, 0.0800, 0.2500, 0.0000, 0.9943, 12428.5000, 99.6000, 0.0000, true }; 138 | pub static REVERB_PRESET_ICEPALACE_COURTYARD: EaxReverbProperties = reverb_preset! { 1.0000, 0.5900, 0.3162, 0.2818, 0.3162, 2.0400, 1.2000, 0.3800, 0.3162, 0.1730, [ 0.0000, 0.0000, 0.0000 ], 0.3162, 0.0430, [ 0.0000, 0.0000, 0.0000 ], 0.2350, 0.4800, 0.2500, 0.0000, 0.9943, 12428.5000, 99.6000, 0.0000, true }; 139 | pub static REVERB_PRESET_ICEPALACE_ALCOVE: EaxReverbProperties = reverb_preset! { 1.0000, 0.8400, 0.3162, 0.5623, 0.2818, 2.7600, 1.4600, 0.2800, 1.1220, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 0.8913, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 0.1610, 0.0900, 0.2500, 0.0000, 0.9943, 12428.5000, 99.6000, 0.0000, true }; 140 | 141 | pub static REVERB_PRESET_SPACESTATION_SMALLROOM: EaxReverbProperties = reverb_preset! { 0.2109, 0.7000, 0.3162, 0.7079, 0.8913, 1.7200, 0.8200, 0.5500, 0.7943, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 1.4125, 0.0130, [ 0.0000, 0.0000, 0.0000 ], 0.1880, 0.2600, 0.2500, 0.0000, 0.9943, 3316.1001, 458.2000, 0.0000, true }; 142 | pub static REVERB_PRESET_SPACESTATION_SHORTPASSAGE: EaxReverbProperties = reverb_preset! { 0.2109, 0.8700, 0.3162, 0.6310, 0.8913, 3.5700, 0.5000, 0.5500, 1.0000, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 1.1220, 0.0160, [ 0.0000, 0.0000, 0.0000 ], 0.1720, 0.2000, 0.2500, 0.0000, 0.9943, 3316.1001, 458.2000, 0.0000, true }; 143 | pub static REVERB_PRESET_SPACESTATION_MEDIUMROOM: EaxReverbProperties = reverb_preset! { 0.2109, 0.7500, 0.3162, 0.6310, 0.8913, 3.0100, 0.5000, 0.5500, 0.3981, 0.0340, [ 0.0000, 0.0000, 0.0000 ], 1.1220, 0.0350, [ 0.0000, 0.0000, 0.0000 ], 0.2090, 0.3100, 0.2500, 0.0000, 0.9943, 3316.1001, 458.2000, 0.0000, true }; 144 | pub static REVERB_PRESET_SPACESTATION_LARGEROOM: EaxReverbProperties = reverb_preset! { 0.3645, 0.8100, 0.3162, 0.6310, 0.8913, 3.8900, 0.3800, 0.6100, 0.3162, 0.0560, [ 0.0000, 0.0000, 0.0000 ], 0.8913, 0.0350, [ 0.0000, 0.0000, 0.0000 ], 0.2330, 0.2800, 0.2500, 0.0000, 0.9943, 3316.1001, 458.2000, 0.0000, true }; 145 | pub static REVERB_PRESET_SPACESTATION_LONGPASSAGE: EaxReverbProperties = reverb_preset! { 0.4287, 0.8200, 0.3162, 0.6310, 0.8913, 4.6200, 0.6200, 0.5500, 1.0000, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0310, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.2300, 0.2500, 0.0000, 0.9943, 3316.1001, 458.2000, 0.0000, true }; 146 | pub static REVERB_PRESET_SPACESTATION_HALL: EaxReverbProperties = reverb_preset! { 0.4287, 0.8700, 0.3162, 0.6310, 0.8913, 7.1100, 0.3800, 0.6100, 0.1778, 0.1000, [ 0.0000, 0.0000, 0.0000 ], 0.6310, 0.0470, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.2500, 0.2500, 0.0000, 0.9943, 3316.1001, 458.2000, 0.0000, true }; 147 | pub static REVERB_PRESET_SPACESTATION_CUPBOARD: EaxReverbProperties = reverb_preset! { 0.1715, 0.5600, 0.3162, 0.7079, 0.8913, 0.7900, 0.8100, 0.5500, 1.4125, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 1.7783, 0.0180, [ 0.0000, 0.0000, 0.0000 ], 0.1810, 0.3100, 0.2500, 0.0000, 0.9943, 3316.1001, 458.2000, 0.0000, true }; 148 | pub static REVERB_PRESET_SPACESTATION_ALCOVE: EaxReverbProperties = reverb_preset! { 0.2109, 0.7800, 0.3162, 0.7079, 0.8913, 1.1600, 0.8100, 0.5500, 1.4125, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 1.0000, 0.0180, [ 0.0000, 0.0000, 0.0000 ], 0.1920, 0.2100, 0.2500, 0.0000, 0.9943, 3316.1001, 458.2000, 0.0000, true }; 149 | 150 | pub static REVERB_PRESET_WOODEN_SMALLROOM: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.1122, 0.3162, 0.7900, 0.3200, 0.8700, 1.0000, 0.0320, [ 0.0000, 0.0000, 0.0000 ], 0.8913, 0.0290, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 4705.0000, 99.6000, 0.0000, true }; 151 | pub static REVERB_PRESET_WOODEN_SHORTPASSAGE: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.1259, 0.3162, 1.7500, 0.5000, 0.8700, 0.8913, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 0.6310, 0.0240, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 4705.0000, 99.6000, 0.0000, true }; 152 | pub static REVERB_PRESET_WOODEN_MEDIUMROOM: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.1000, 0.2818, 1.4700, 0.4200, 0.8200, 0.8913, 0.0490, [ 0.0000, 0.0000, 0.0000 ], 0.8913, 0.0290, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 4705.0000, 99.6000, 0.0000, true }; 153 | pub static REVERB_PRESET_WOODEN_LARGEROOM: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.0891, 0.2818, 2.6500, 0.3300, 0.8200, 0.8913, 0.0660, [ 0.0000, 0.0000, 0.0000 ], 0.7943, 0.0490, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 4705.0000, 99.6000, 0.0000, true }; 154 | pub static REVERB_PRESET_WOODEN_LONGPASSAGE: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.1000, 0.3162, 1.9900, 0.4000, 0.7900, 1.0000, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 0.4467, 0.0360, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 4705.0000, 99.6000, 0.0000, true }; 155 | pub static REVERB_PRESET_WOODEN_HALL: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.0794, 0.2818, 3.4500, 0.3000, 0.8200, 0.8913, 0.0880, [ 0.0000, 0.0000, 0.0000 ], 0.7943, 0.0630, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 4705.0000, 99.6000, 0.0000, true }; 156 | pub static REVERB_PRESET_WOODEN_CUPBOARD: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.1413, 0.3162, 0.5600, 0.4600, 0.9100, 1.1220, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 1.1220, 0.0280, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 4705.0000, 99.6000, 0.0000, true }; 157 | pub static REVERB_PRESET_WOODEN_COURTYARD: EaxReverbProperties = reverb_preset! { 1.0000, 0.6500, 0.3162, 0.0794, 0.3162, 1.7900, 0.3500, 0.7900, 0.5623, 0.1230, [ 0.0000, 0.0000, 0.0000 ], 0.1000, 0.0320, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 4705.0000, 99.6000, 0.0000, true }; 158 | pub static REVERB_PRESET_WOODEN_ALCOVE: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.1259, 0.3162, 1.2200, 0.6200, 0.9100, 1.1220, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 0.7079, 0.0240, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 4705.0000, 99.6000, 0.0000, true }; 159 | 160 | pub static REVERB_PRESET_SPORT_EMPTYSTADIUM: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.4467, 0.7943, 6.2600, 0.5100, 1.1000, 0.0631, 0.1830, [ 0.0000, 0.0000, 0.0000 ], 0.3981, 0.0380, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 161 | pub static REVERB_PRESET_SPORT_SQUASHCOURT: EaxReverbProperties = reverb_preset! { 1.0000, 0.7500, 0.3162, 0.3162, 0.7943, 2.2200, 0.9100, 1.1600, 0.4467, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 0.7943, 0.0110, [ 0.0000, 0.0000, 0.0000 ], 0.1260, 0.1900, 0.2500, 0.0000, 0.9943, 7176.8999, 211.2000, 0.0000, true }; 162 | pub static REVERB_PRESET_SPORT_SMALLSWIMMINGPOOL: EaxReverbProperties = reverb_preset! { 1.0000, 0.7000, 0.3162, 0.7943, 0.8913, 2.7600, 1.2500, 1.1400, 0.6310, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 0.7943, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 0.1790, 0.1500, 0.8950, 0.1900, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 163 | pub static REVERB_PRESET_SPORT_LARGESWIMMINGPOOL: EaxReverbProperties = reverb_preset! { 1.0000, 0.8200, 0.3162, 0.7943, 1.0000, 5.4900, 1.3100, 1.1400, 0.4467, 0.0390, [ 0.0000, 0.0000, 0.0000 ], 0.5012, 0.0490, [ 0.0000, 0.0000, 0.0000 ], 0.2220, 0.5500, 1.1590, 0.2100, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 164 | pub static REVERB_PRESET_SPORT_GYMNASIUM: EaxReverbProperties = reverb_preset! { 1.0000, 0.8100, 0.3162, 0.4467, 0.8913, 3.1400, 1.0600, 1.3500, 0.3981, 0.0290, [ 0.0000, 0.0000, 0.0000 ], 0.5623, 0.0450, [ 0.0000, 0.0000, 0.0000 ], 0.1460, 0.1400, 0.2500, 0.0000, 0.9943, 7176.8999, 211.2000, 0.0000, true }; 165 | pub static REVERB_PRESET_SPORT_FULLSTADIUM: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.0708, 0.7943, 5.2500, 0.1700, 0.8000, 0.1000, 0.1880, [ 0.0000, 0.0000, 0.0000 ], 0.2818, 0.0380, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 166 | pub static REVERB_PRESET_SPORT_STADIUMTANNOY: EaxReverbProperties = reverb_preset! { 1.0000, 0.7800, 0.3162, 0.5623, 0.5012, 2.5300, 0.8800, 0.6800, 0.2818, 0.2300, [ 0.0000, 0.0000, 0.0000 ], 0.5012, 0.0630, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.2000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 167 | 168 | pub static REVERB_PRESET_PREFAB_WORKSHOP: EaxReverbProperties = reverb_preset! { 0.4287, 1.0000, 0.3162, 0.1413, 0.3981, 0.7600, 1.0000, 1.0000, 1.0000, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 1.1220, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 169 | pub static REVERB_PRESET_PREFAB_SCHOOLROOM: EaxReverbProperties = reverb_preset! { 0.4022, 0.6900, 0.3162, 0.6310, 0.5012, 0.9800, 0.4500, 0.1800, 1.4125, 0.0170, [ 0.0000, 0.0000, 0.0000 ], 1.4125, 0.0150, [ 0.0000, 0.0000, 0.0000 ], 0.0950, 0.1400, 0.2500, 0.0000, 0.9943, 7176.8999, 211.2000, 0.0000, true }; 170 | pub static REVERB_PRESET_PREFAB_PRACTISEROOM: EaxReverbProperties = reverb_preset! { 0.4022, 0.8700, 0.3162, 0.3981, 0.5012, 1.1200, 0.5600, 0.1800, 1.2589, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 1.4125, 0.0110, [ 0.0000, 0.0000, 0.0000 ], 0.0950, 0.1400, 0.2500, 0.0000, 0.9943, 7176.8999, 211.2000, 0.0000, true }; 171 | pub static REVERB_PRESET_PREFAB_OUTHOUSE: EaxReverbProperties = reverb_preset! { 1.0000, 0.8200, 0.3162, 0.1122, 0.1585, 1.3800, 0.3800, 0.3500, 0.8913, 0.0240, [ 0.0000, 0.0000, -0.0000 ], 0.6310, 0.0440, [ 0.0000, 0.0000, 0.0000 ], 0.1210, 0.1700, 0.2500, 0.0000, 0.9943, 2854.3999, 107.5000, 0.0000, false }; 172 | pub static REVERB_PRESET_PREFAB_CARAVAN: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.0891, 0.1259, 0.4300, 1.5000, 1.0000, 1.0000, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 1.9953, 0.0120, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 173 | 174 | pub static REVERB_PRESET_DOME_TOMB: EaxReverbProperties = reverb_preset! { 1.0000, 0.7900, 0.3162, 0.3548, 0.2239, 4.1800, 0.2100, 0.1000, 0.3868, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 1.6788, 0.0220, [ 0.0000, 0.0000, 0.0000 ], 0.1770, 0.1900, 0.2500, 0.0000, 0.9943, 2854.3999, 20.0000, 0.0000, false }; 175 | pub static REVERB_PRESET_PIPE_SMALL: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.3548, 0.2239, 5.0400, 0.1000, 0.1000, 0.5012, 0.0320, [ 0.0000, 0.0000, 0.0000 ], 2.5119, 0.0150, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 2854.3999, 20.0000, 0.0000, true }; 176 | pub static REVERB_PRESET_DOME_SAINTPAULS: EaxReverbProperties = reverb_preset! { 1.0000, 0.8700, 0.3162, 0.3548, 0.2239, 10.4800, 0.1900, 0.1000, 0.1778, 0.0900, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0420, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.1200, 0.2500, 0.0000, 0.9943, 2854.3999, 20.0000, 0.0000, true }; 177 | pub static REVERB_PRESET_PIPE_LONGTHIN: EaxReverbProperties = reverb_preset! { 0.2560, 0.9100, 0.3162, 0.4467, 0.2818, 9.2100, 0.1800, 0.1000, 0.7079, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 0.7079, 0.0220, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 2854.3999, 20.0000, 0.0000, false }; 178 | pub static REVERB_PRESET_PIPE_LARGE: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.3548, 0.2239, 8.4500, 0.1000, 0.1000, 0.3981, 0.0460, [ 0.0000, 0.0000, 0.0000 ], 1.5849, 0.0320, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 2854.3999, 20.0000, 0.0000, true }; 179 | pub static REVERB_PRESET_PIPE_RESONANT: EaxReverbProperties = reverb_preset! { 0.1373, 0.9100, 0.3162, 0.4467, 0.2818, 6.8100, 0.1800, 0.1000, 0.7079, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 1.0000, 0.0220, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 2854.3999, 20.0000, 0.0000, false }; 180 | 181 | pub static REVERB_PRESET_OUTDOORS_BACKYARD: EaxReverbProperties = reverb_preset! { 1.0000, 0.4500, 0.3162, 0.2512, 0.5012, 1.1200, 0.3400, 0.4600, 0.4467, 0.0690, [ 0.0000, 0.0000, -0.0000 ], 0.7079, 0.0230, [ 0.0000, 0.0000, 0.0000 ], 0.2180, 0.3400, 0.2500, 0.0000, 0.9943, 4399.1001, 242.9000, 0.0000, false }; 182 | pub static REVERB_PRESET_OUTDOORS_ROLLINGPLAINS: EaxReverbProperties = reverb_preset! { 1.0000, 0.0000, 0.3162, 0.0112, 0.6310, 2.1300, 0.2100, 0.4600, 0.1778, 0.3000, [ 0.0000, 0.0000, -0.0000 ], 0.4467, 0.0190, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 1.0000, 0.2500, 0.0000, 0.9943, 4399.1001, 242.9000, 0.0000, false }; 183 | pub static REVERB_PRESET_OUTDOORS_DEEPCANYON: EaxReverbProperties = reverb_preset! { 1.0000, 0.7400, 0.3162, 0.1778, 0.6310, 3.8900, 0.2100, 0.4600, 0.3162, 0.2230, [ 0.0000, 0.0000, -0.0000 ], 0.3548, 0.0190, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 1.0000, 0.2500, 0.0000, 0.9943, 4399.1001, 242.9000, 0.0000, false }; 184 | pub static REVERB_PRESET_OUTDOORS_CREEK: EaxReverbProperties = reverb_preset! { 1.0000, 0.3500, 0.3162, 0.1778, 0.5012, 2.1300, 0.2100, 0.4600, 0.3981, 0.1150, [ 0.0000, 0.0000, -0.0000 ], 0.1995, 0.0310, [ 0.0000, 0.0000, 0.0000 ], 0.2180, 0.3400, 0.2500, 0.0000, 0.9943, 4399.1001, 242.9000, 0.0000, false }; 185 | pub static REVERB_PRESET_OUTDOORS_VALLEY: EaxReverbProperties = reverb_preset! { 1.0000, 0.2800, 0.3162, 0.0282, 0.1585, 2.8800, 0.2600, 0.3500, 0.1413, 0.2630, [ 0.0000, 0.0000, -0.0000 ], 0.3981, 0.1000, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.3400, 0.2500, 0.0000, 0.9943, 2854.3999, 107.5000, 0.0000, false }; 186 | 187 | pub static REVERB_PRESET_MOOD_HEAVEN: EaxReverbProperties = reverb_preset! { 1.0000, 0.9400, 0.3162, 0.7943, 0.4467, 5.0400, 1.1200, 0.5600, 0.2427, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0290, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0800, 2.7420, 0.0500, 0.9977, 5000.0000, 250.0000, 0.0000, true }; 188 | pub static REVERB_PRESET_MOOD_HELL: EaxReverbProperties = reverb_preset! { 1.0000, 0.5700, 0.3162, 0.3548, 0.4467, 3.5700, 0.4900, 2.0000, 0.0000, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 1.4125, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 0.1100, 0.0400, 2.1090, 0.5200, 0.9943, 5000.0000, 139.5000, 0.0000, false }; 189 | pub static REVERB_PRESET_MOOD_MEMORY: EaxReverbProperties = reverb_preset! { 1.0000, 0.8500, 0.3162, 0.6310, 0.3548, 4.0600, 0.8200, 0.5600, 0.0398, 0.0000, [ 0.0000, 0.0000, 0.0000 ], 1.1220, 0.0000, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.4740, 0.4500, 0.9886, 5000.0000, 250.0000, 0.0000, false }; 190 | 191 | pub static REVERB_PRESET_DRIVING_COMMENTATOR: EaxReverbProperties = reverb_preset! { 1.0000, 0.0000, 0.3162, 0.5623, 0.5012, 2.4200, 0.8800, 0.6800, 0.1995, 0.0930, [ 0.0000, 0.0000, 0.0000 ], 0.2512, 0.0170, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 1.0000, 0.2500, 0.0000, 0.9886, 5000.0000, 250.0000, 0.0000, true }; 192 | pub static REVERB_PRESET_DRIVING_PITGARAGE: EaxReverbProperties = reverb_preset! { 0.4287, 0.5900, 0.3162, 0.7079, 0.5623, 1.7200, 0.9300, 0.8700, 0.5623, 0.0000, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0160, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.1100, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, false }; 193 | pub static REVERB_PRESET_DRIVING_INCAR_RACER: EaxReverbProperties = reverb_preset! { 0.0832, 0.8000, 0.3162, 1.0000, 0.7943, 0.1700, 2.0000, 0.4100, 1.7783, 0.0070, [ 0.0000, 0.0000, 0.0000 ], 0.7079, 0.0150, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 10268.2002, 251.0000, 0.0000, true }; 194 | pub static REVERB_PRESET_DRIVING_INCAR_SPORTS: EaxReverbProperties = reverb_preset! { 0.0832, 0.8000, 0.3162, 0.6310, 1.0000, 0.1700, 0.7500, 0.4100, 1.0000, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 0.5623, 0.0000, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 10268.2002, 251.0000, 0.0000, true }; 195 | pub static REVERB_PRESET_DRIVING_INCAR_LUXURY: EaxReverbProperties = reverb_preset! { 0.2560, 1.0000, 0.3162, 0.1000, 0.5012, 0.1300, 0.4100, 0.4600, 0.7943, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 1.5849, 0.0100, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 10268.2002, 251.0000, 0.0000, true }; 196 | pub static REVERB_PRESET_DRIVING_FULLGRANDSTAND: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 0.2818, 0.6310, 3.0100, 1.3700, 1.2800, 0.3548, 0.0900, [ 0.0000, 0.0000, 0.0000 ], 0.1778, 0.0490, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 10420.2002, 250.0000, 0.0000, false }; 197 | pub static REVERB_PRESET_DRIVING_EMPTYGRANDSTAND: EaxReverbProperties = reverb_preset! { 1.0000, 1.0000, 0.3162, 1.0000, 0.7943, 4.6200, 1.7500, 1.4000, 0.2082, 0.0900, [ 0.0000, 0.0000, 0.0000 ], 0.2512, 0.0490, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.0000, 0.9943, 10420.2002, 250.0000, 0.0000, false }; 198 | pub static REVERB_PRESET_DRIVING_TUNNEL: EaxReverbProperties = reverb_preset! { 1.0000, 0.8100, 0.3162, 0.3981, 0.8913, 3.4200, 0.9400, 1.3100, 0.7079, 0.0510, [ 0.0000, 0.0000, 0.0000 ], 0.7079, 0.0470, [ 0.0000, 0.0000, 0.0000 ], 0.2140, 0.0500, 0.2500, 0.0000, 0.9943, 5000.0000, 155.3000, 0.0000, true }; 199 | 200 | pub static REVERB_PRESET_CITY_STREETS: EaxReverbProperties = reverb_preset! { 1.0000, 0.7800, 0.3162, 0.7079, 0.8913, 1.7900, 1.1200, 0.9100, 0.2818, 0.0460, [ 0.0000, 0.0000, 0.0000 ], 0.1995, 0.0280, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.2000, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 201 | pub static REVERB_PRESET_CITY_SUBWAY: EaxReverbProperties = reverb_preset! { 1.0000, 0.7400, 0.3162, 0.7079, 0.8913, 3.0100, 1.2300, 0.9100, 0.7079, 0.0460, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0280, [ 0.0000, 0.0000, 0.0000 ], 0.1250, 0.2100, 0.2500, 0.0000, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 202 | pub static REVERB_PRESET_CITY_MUSEUM: EaxReverbProperties = reverb_preset! { 1.0000, 0.8200, 0.3162, 0.1778, 0.1778, 3.2800, 1.4000, 0.5700, 0.2512, 0.0390, [ 0.0000, 0.0000, -0.0000 ], 0.8913, 0.0340, [ 0.0000, 0.0000, 0.0000 ], 0.1300, 0.1700, 0.2500, 0.0000, 0.9943, 2854.3999, 107.5000, 0.0000, false }; 203 | pub static REVERB_PRESET_CITY_LIBRARY: EaxReverbProperties = reverb_preset! { 1.0000, 0.8200, 0.3162, 0.2818, 0.0891, 2.7600, 0.8900, 0.4100, 0.3548, 0.0290, [ 0.0000, 0.0000, -0.0000 ], 0.8913, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 0.1300, 0.1700, 0.2500, 0.0000, 0.9943, 2854.3999, 107.5000, 0.0000, false }; 204 | pub static REVERB_PRESET_CITY_UNDERPASS: EaxReverbProperties = reverb_preset! { 1.0000, 0.8200, 0.3162, 0.4467, 0.8913, 3.5700, 1.1200, 0.9100, 0.3981, 0.0590, [ 0.0000, 0.0000, 0.0000 ], 0.8913, 0.0370, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.1400, 0.2500, 0.0000, 0.9920, 5000.0000, 250.0000, 0.0000, true }; 205 | pub static REVERB_PRESET_CITY_ABANDONED: EaxReverbProperties = reverb_preset! { 1.0000, 0.6900, 0.3162, 0.7943, 0.8913, 3.2800, 1.1700, 0.9100, 0.4467, 0.0440, [ 0.0000, 0.0000, 0.0000 ], 0.2818, 0.0240, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.2000, 0.2500, 0.0000, 0.9966, 5000.0000, 250.0000, 0.0000, true }; 206 | 207 | pub static REVERB_PRESET_DUSTYROOM: EaxReverbProperties = reverb_preset! { 0.3645, 0.5600, 0.3162, 0.7943, 0.7079, 1.7900, 0.3800, 0.2100, 0.5012, 0.0020, [ 0.0000, 0.0000, 0.0000 ], 1.2589, 0.0060, [ 0.0000, 0.0000, 0.0000 ], 0.2020, 0.0500, 0.2500, 0.0000, 0.9886, 13046.0000, 163.3000, 0.0000, true }; 208 | pub static REVERB_PRESET_CHAPEL: EaxReverbProperties = reverb_preset! { 1.0000, 0.8400, 0.3162, 0.5623, 1.0000, 4.6200, 0.6400, 1.2300, 0.4467, 0.0320, [ 0.0000, 0.0000, 0.0000 ], 0.7943, 0.0490, [ 0.0000, 0.0000, 0.0000 ], 0.2500, 0.0000, 0.2500, 0.1100, 0.9943, 5000.0000, 250.0000, 0.0000, true }; 209 | pub static REVERB_PRESET_SMALLWATERROOM: EaxReverbProperties = reverb_preset! { 1.0000, 0.7000, 0.3162, 0.4477, 1.0000, 1.5100, 1.2500, 1.1400, 0.8913, 0.0200, [ 0.0000, 0.0000, 0.0000 ], 1.4125, 0.0300, [ 0.0000, 0.0000, 0.0000 ], 0.1790, 0.1500, 0.8950, 0.1900, 0.9920, 5000.0000, 250.0000, 0.0000, false }; 210 | -------------------------------------------------------------------------------- /src/ext.rs: -------------------------------------------------------------------------------- 1 | use std::mem; 2 | use std::ptr; 3 | 4 | use sys::*; 5 | 6 | 7 | macro_rules! alc_ext { 8 | { 9 | pub(crate) cache $cache:ident; 10 | 11 | 12 | $(pub ext $ext:ident { 13 | $(pub const $const_:ident,)* 14 | $(pub fn $fn_:ident: $fn_ty:ty,)* 15 | })* 16 | } => { 17 | #[allow(non_snake_case)] 18 | pub(crate) struct $cache { 19 | pub $($ext: ExtResult<$ext>,)* 20 | } 21 | 22 | 23 | #[allow(non_snake_case, dead_code)] 24 | impl $cache { 25 | pub unsafe fn new(api: &AlApi, dev: *mut ALCdevice) -> $cache { 26 | $cache{ 27 | $($ext: $ext::load(api, dev),)* 28 | } 29 | } 30 | 31 | 32 | $(pub fn $ext(&self) -> ExtResult<&$ext> { 33 | self.$ext.as_ref().map_err(|e| *e) 34 | })* 35 | } 36 | 37 | 38 | unsafe impl Send for $cache { } 39 | unsafe impl Sync for $cache { } 40 | 41 | 42 | $(#[allow(non_camel_case_types, non_snake_case)] 43 | #[derive(Debug)] 44 | pub struct $ext { 45 | $(pub $const_: ExtResult,)* 46 | $(pub $fn_: ExtResult<$fn_ty>,)* 47 | } 48 | 49 | 50 | impl $ext { 51 | pub fn load(api: &AlApi, dev: *mut ALCdevice) -> ExtResult<$ext> { 52 | unsafe { api.alcGetError(dev); } 53 | if unsafe { api.alcIsExtensionPresent(dev, concat!(stringify!($ext), "\0").as_bytes().as_ptr() as *const ALCchar) } == ALC_TRUE { 54 | Ok($ext{ 55 | $($const_: { 56 | let e = unsafe { api.alcGetEnumValue(dev, concat!(stringify!($const_), "\0").as_bytes().as_ptr() as *const ALCchar) }; 57 | if e != 0 && unsafe { api.alcGetError(dev) } == ALC_NO_ERROR { 58 | Ok(e) 59 | } else { 60 | // Workaround for missing symbols in OpenAL-Soft 61 | match stringify!($const_) { 62 | "AL_EFFECTSLOT_EFFECT" => Ok(1), 63 | "AL_EFFECTSLOT_GAIN" => Ok(2), 64 | "AL_EFFECTSLOT_AUXILIARY_SEND_AUTO" => Ok(3), 65 | _ => Err(ExtensionError), 66 | } 67 | } 68 | },)* 69 | $($fn_: { 70 | let p = unsafe { api.alcGetProcAddress(dev, concat!(stringify!($fn_), "\0").as_bytes().as_ptr() as *const ALCchar) }; 71 | if p != ptr::null_mut() && unsafe { api.alcGetError(dev) } == ALC_NO_ERROR { 72 | Ok(unsafe { mem::transmute(p) }) 73 | } else { 74 | Err(ExtensionError) 75 | } 76 | },)* 77 | }) 78 | } else { 79 | Err(ExtensionError) 80 | } 81 | } 82 | })* 83 | }; 84 | } 85 | 86 | 87 | macro_rules! al_ext { 88 | { 89 | pub(crate) cache $cache:ident; 90 | 91 | 92 | $(pub ext $ext:ident { 93 | $(pub const $const_:ident,)* 94 | $(pub fn $fn_:ident: $fn_ty:ty,)* 95 | })* 96 | } => { 97 | #[allow(non_snake_case)] 98 | pub(crate) struct $cache { 99 | pub $($ext: ExtResult<$ext>,)* 100 | } 101 | 102 | 103 | #[allow(non_snake_case, dead_code)] 104 | impl $cache { 105 | pub unsafe fn new(api: &AlApi) -> $cache { 106 | $cache{ 107 | $($ext: $ext::load(api),)* 108 | } 109 | } 110 | 111 | 112 | $(pub fn $ext(&self) -> ExtResult<&$ext> { 113 | self.$ext.as_ref().map_err(|e| *e) 114 | })* 115 | } 116 | 117 | 118 | unsafe impl Send for $cache { } 119 | 120 | 121 | $(#[allow(non_camel_case_types, non_snake_case)] 122 | #[derive(Debug)] 123 | pub struct $ext { 124 | $(pub $const_: ExtResult,)* 125 | $(pub $fn_: ExtResult<$fn_ty>,)* 126 | } 127 | 128 | 129 | impl $ext { 130 | pub fn load(api: &AlApi) -> ExtResult<$ext> { 131 | unsafe { api.alGetError(); } 132 | if unsafe { api.alIsExtensionPresent(concat!(stringify!($ext), "\0").as_bytes().as_ptr() as *const ALchar) } == AL_TRUE { 133 | Ok($ext{ 134 | $($const_: { 135 | let e = unsafe { api.alGetEnumValue(concat!(stringify!($const_), "\0").as_bytes().as_ptr() as *const ALchar) }; 136 | if e != 0 && unsafe { api.alGetError() } == AL_NO_ERROR { 137 | Ok(e) 138 | } else { 139 | Err(ExtensionError) 140 | } 141 | },)* 142 | $($fn_: { 143 | let p = unsafe { api.alGetProcAddress(concat!(stringify!($fn_), "\0").as_bytes().as_ptr() as *const ALchar) }; 144 | if p != ptr::null_mut() && unsafe { api.alGetError() } == AL_NO_ERROR { 145 | Ok(unsafe { mem::transmute(p) }) 146 | } else { 147 | Err(ExtensionError) 148 | } 149 | },)* 150 | }) 151 | } else { 152 | Err(ExtensionError) 153 | } 154 | } 155 | })* 156 | }; 157 | } 158 | 159 | 160 | #[doc(hidden)] 161 | #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] 162 | pub struct ExtensionError; 163 | 164 | 165 | #[doc(hidden)] 166 | pub type ExtResult = ::std::result::Result; 167 | 168 | 169 | #[derive(Copy, Clone, PartialEq, Hash, Eq, Debug)] 170 | pub enum AlcNull { 171 | /// `ALC_ENUMERATE_ALL_EXT` 172 | EnumerateAll, 173 | /// `ALC_SOFT_loopback` 174 | SoftLoopback, 175 | /// `ALC_EXT_thread_local_context` 176 | ThreadLocalContext, 177 | } 178 | 179 | 180 | #[derive(Copy, Clone, PartialEq, Hash, Eq, Debug)] 181 | pub enum Alc { 182 | /// `ALC_EXT_DEDICATED` 183 | Dedicated, 184 | /// `ALC_EXT_disconnect` 185 | Disconnect, 186 | /// `ALC_EXT_EFX` 187 | Efx, 188 | /// `ALC_SOFT_HRTF` 189 | SoftHrtf, 190 | /// `ALC_SOFT_pause_device` 191 | SoftPauseDevice, 192 | /// `ALC_SOFT_output_limiter` 193 | SoftOutputLimiter, 194 | } 195 | 196 | 197 | #[derive(Copy, Clone, PartialEq, Hash, Eq, Debug)] 198 | pub enum Al { 199 | /// `AL_EXT_ALAW` 200 | ALaw, 201 | /// `AL_EXT_BFORMAT` 202 | BFormat, 203 | /// `AL_EXT_double` 204 | Double, 205 | /// `AL_EXT_float32` 206 | Float32, 207 | /// `AL_EXT_IMA4` 208 | Ima4, 209 | /// `AL_EXT_MCFORMATS` 210 | McFormats, 211 | /// `AL_EXT_MULAW` 212 | MuLaw, 213 | /// `AL_EXT_MULAW_BFORMAT` 214 | MuLawBFormat, 215 | /// `AL_EXT_MULAW_MCFORMATS` 216 | MuLawMcFormats, 217 | /// `AL_SOFT_block_alignment` 218 | SoftBlockAlignment, 219 | // SoftBufferSamples, 220 | // SoftBufferSubData, 221 | /// `AL_SOFT_deferred_updates` 222 | SoftDeferredUpdates, 223 | /// `AL_SOFT_direct_channels` 224 | SoftDirectChannels, 225 | /// `AL_SOFT_loop_points` 226 | SoftLoopPoints, 227 | /// `AL_SOFT_MSADPCM` 228 | SoftMsadpcm, 229 | /// `AL_SOFT_source_latency` 230 | SoftSourceLatency, 231 | /// `AL_SOFT_source_length` 232 | SoftSourceLength, 233 | /// `AL_EXT_source_distance_model` 234 | SourceDistanceModel, 235 | /// `AL_SOFT_source_spatialize` 236 | SoftSourceSpatialize, 237 | /// `AL_SOFT_source_resampler` 238 | SoftSourceResampler, 239 | /// `AL_SOFT_gain_clamp_ex` 240 | SoftGainClampEx, 241 | /// `AL_EXT_STEREO_ANGLES` 242 | StereoAngles, 243 | /// `AL_EXT_SOURCE_RADIUS` 244 | SourceRadius, 245 | } 246 | 247 | 248 | alc_ext! { 249 | pub(crate) cache AlcNullCache; 250 | 251 | 252 | pub ext ALC_ENUMERATE_ALL_EXT { 253 | pub const ALC_ALL_DEVICES_SPECIFIER, 254 | pub const ALC_DEFAULT_ALL_DEVICES_SPECIFIER, 255 | } 256 | 257 | 258 | pub ext ALC_SOFT_loopback { 259 | pub const ALC_BYTE_SOFT, 260 | pub const ALC_UNSIGNED_BYTE_SOFT, 261 | pub const ALC_SHORT_SOFT, 262 | pub const ALC_UNSIGNED_SHORT_SOFT, 263 | pub const ALC_INT_SOFT, 264 | pub const ALC_UNSIGNED_INT_SOFT, 265 | pub const ALC_FLOAT_SOFT, 266 | pub const ALC_MONO_SOFT, 267 | pub const ALC_STEREO_SOFT, 268 | pub const ALC_QUAD_SOFT, 269 | pub const ALC_5POINT1_SOFT, 270 | pub const ALC_6POINT1_SOFT, 271 | pub const ALC_7POINT1_SOFT, 272 | pub const ALC_FORMAT_CHANNELS_SOFT, 273 | pub const ALC_FORMAT_TYPE_SOFT, 274 | 275 | pub fn alcLoopbackOpenDeviceSOFT: unsafe extern "C" fn(deviceName: *const ALCchar) -> *mut ALCdevice, 276 | pub fn alcIsRenderFormatSupportedSOFT: unsafe extern "C" fn(device: *mut ALCdevice, frequency: ALCsizei, channels: ALCenum, type_: ALCenum) -> ALCboolean, 277 | pub fn alcRenderSamplesSOFT: unsafe extern "C" fn(device: *mut ALCdevice, buffer: *mut ALvoid, samples: ALCsizei), 278 | } 279 | 280 | 281 | pub ext ALC_EXT_thread_local_context { 282 | pub fn alcSetThreadContext: unsafe extern "C" fn(ctx: *mut ALCcontext) -> ALCboolean, 283 | pub fn alcGetThreadContext: unsafe extern "C" fn() -> *mut ALCcontext, 284 | } 285 | } 286 | 287 | 288 | alc_ext! { 289 | pub(crate) cache AlcCache; 290 | 291 | 292 | pub ext ALC_EXT_DEDICATED { 293 | pub const AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT, 294 | pub const AL_EFFECT_DEDICATED_DIALOGUE, 295 | pub const AL_EFFECT_DEDICATED_GAIN, 296 | } 297 | 298 | 299 | pub ext ALC_EXT_DISCONNECT { 300 | pub const ALC_CONNECTED, 301 | } 302 | 303 | 304 | pub ext ALC_EXT_EFX { 305 | pub const AL_EFFECTSLOT_EFFECT, 306 | pub const AL_EFFECTSLOT_GAIN, 307 | pub const AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, 308 | 309 | pub const AL_EFFECT_TYPE, 310 | pub const AL_EFFECT_EAXREVERB, 311 | pub const AL_EAXREVERB_DENSITY, 312 | pub const AL_EAXREVERB_DIFFUSION, 313 | pub const AL_EAXREVERB_GAIN, 314 | pub const AL_EAXREVERB_GAINHF, 315 | pub const AL_EAXREVERB_GAINLF, 316 | pub const AL_EAXREVERB_DECAY_TIME, 317 | pub const AL_EAXREVERB_DECAY_HFRATIO, 318 | pub const AL_EAXREVERB_DECAY_LFRATIO, 319 | pub const AL_EAXREVERB_REFLECTIONS_GAIN, 320 | pub const AL_EAXREVERB_REFLECTIONS_DELAY, 321 | pub const AL_EAXREVERB_REFLECTIONS_PAN, 322 | pub const AL_EAXREVERB_LATE_REVERB_GAIN, 323 | pub const AL_EAXREVERB_LATE_REVERB_DELAY, 324 | pub const AL_EAXREVERB_LATE_REVERB_PAN, 325 | pub const AL_EAXREVERB_ECHO_TIME, 326 | pub const AL_EAXREVERB_ECHO_DEPTH, 327 | pub const AL_EAXREVERB_MODULATION_TIME, 328 | pub const AL_EAXREVERB_MODULATION_DEPTH, 329 | pub const AL_EAXREVERB_AIR_ABSORPTION_GAINHF, 330 | pub const AL_EAXREVERB_HFREFERENCE, 331 | pub const AL_EAXREVERB_LFREFERENCE, 332 | pub const AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, 333 | pub const AL_EAXREVERB_DECAY_HFLIMIT, 334 | pub const AL_EFFECT_REVERB, 335 | pub const AL_REVERB_DENSITY, 336 | pub const AL_REVERB_DIFFUSION, 337 | pub const AL_REVERB_GAIN, 338 | pub const AL_REVERB_GAINHF, 339 | pub const AL_REVERB_DECAY_TIME, 340 | pub const AL_REVERB_DECAY_HFRATIO, 341 | pub const AL_REVERB_REFLECTIONS_GAIN, 342 | pub const AL_REVERB_REFLECTIONS_DELAY, 343 | pub const AL_REVERB_LATE_REVERB_GAIN, 344 | pub const AL_REVERB_LATE_REVERB_DELAY, 345 | pub const AL_REVERB_AIR_ABSORPTION_GAINHF, 346 | pub const AL_REVERB_ROOM_ROLLOFF_FACTOR, 347 | pub const AL_REVERB_DECAY_HFLIMIT, 348 | pub const AL_EFFECT_CHORUS, 349 | pub const AL_CHORUS_WAVEFORM, 350 | pub const AL_CHORUS_PHASE, 351 | pub const AL_CHORUS_RATE, 352 | pub const AL_CHORUS_DEPTH, 353 | pub const AL_CHORUS_FEEDBACK, 354 | pub const AL_CHORUS_DELAY, 355 | pub const AL_EFFECT_DISTORTION, 356 | pub const AL_DISTORTION_EDGE, 357 | pub const AL_DISTORTION_GAIN, 358 | pub const AL_DISTORTION_LOWPASS_CUTOFF, 359 | pub const AL_DISTORTION_EQCENTER, 360 | pub const AL_DISTORTION_EQBANDWIDTH, 361 | pub const AL_EFFECT_ECHO, 362 | pub const AL_ECHO_DELAY, 363 | pub const AL_ECHO_LRDELAY, 364 | pub const AL_ECHO_DAMPING, 365 | pub const AL_ECHO_FEEDBACK, 366 | pub const AL_ECHO_SPREAD, 367 | pub const AL_EFFECT_FLANGER, 368 | pub const AL_FLANGER_WAVEFORM, 369 | pub const AL_FLANGER_PHASE, 370 | pub const AL_FLANGER_RATE, 371 | pub const AL_FLANGER_DEPTH, 372 | pub const AL_FLANGER_FEEDBACK, 373 | pub const AL_FLANGER_DELAY, 374 | pub const AL_EFFECT_FREQUENCY_SHIFTER, 375 | pub const AL_FREQUENCY_SHIFTER_FREQUENCY, 376 | pub const AL_FREQUENCY_SHIFTER_LEFT_DIRECTION, 377 | pub const AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION, 378 | pub const AL_EFFECT_VOCAL_MORPHER, 379 | pub const AL_VOCAL_MORPHER_PHONEMEA, 380 | pub const AL_VOCAL_MORPHER_PHONEMEB, 381 | pub const AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING, 382 | pub const AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING, 383 | pub const AL_VOCAL_MORPHER_WAVEFORM, 384 | pub const AL_VOCAL_MORPHER_RATE, 385 | pub const AL_EFFECT_PITCH_SHIFTER, 386 | pub const AL_PITCH_SHIFTER_COARSE_TUNE, 387 | pub const AL_PITCH_SHIFTER_FINE_TUNE, 388 | pub const AL_EFFECT_RING_MODULATOR, 389 | pub const AL_RING_MODULATOR_FREQUENCY, 390 | pub const AL_RING_MODULATOR_HIGHPASS_CUTOFF, 391 | pub const AL_RING_MODULATOR_WAVEFORM, 392 | pub const AL_EFFECT_AUTOWAH, 393 | pub const AL_AUTOWAH_ATTACK_TIME, 394 | pub const AL_AUTOWAH_RELEASE_TIME, 395 | pub const AL_AUTOWAH_RESONANCE, 396 | pub const AL_AUTOWAH_PEAK_GAIN, 397 | pub const AL_EFFECT_COMPRESSOR, 398 | pub const AL_COMPRESSOR_ONOFF, 399 | pub const AL_EFFECT_EQUALIZER, 400 | pub const AL_EQUALIZER_LOW_GAIN, 401 | pub const AL_EQUALIZER_LOW_CUTOFF, 402 | pub const AL_EQUALIZER_MID1_GAIN, 403 | pub const AL_EQUALIZER_MID1_CENTER, 404 | pub const AL_EQUALIZER_MID1_WIDTH, 405 | pub const AL_EQUALIZER_MID2_GAIN, 406 | pub const AL_EQUALIZER_MID2_CENTER, 407 | pub const AL_EQUALIZER_MID2_WIDTH, 408 | pub const AL_EQUALIZER_HIGH_GAIN, 409 | pub const AL_EQUALIZER_HIGH_CUTOFF, 410 | 411 | pub const AL_FILTER_TYPE, 412 | pub const AL_FILTER_LOWPASS, 413 | pub const AL_LOWPASS_GAIN, 414 | pub const AL_LOWPASS_GAINHF, 415 | pub const AL_FILTER_HIGHPASS, 416 | pub const AL_HIGHPASS_GAIN, 417 | pub const AL_HIGHPASS_GAINLF, 418 | pub const AL_FILTER_BANDPASS, 419 | pub const AL_BANDPASS_GAIN, 420 | pub const AL_BANDPASS_GAINLF, 421 | pub const AL_BANDPASS_GAINHF, 422 | 423 | pub const AL_DIRECT_FILTER, 424 | pub const AL_AUXILIARY_SEND_FILTER, 425 | pub const AL_AIR_ABSORPTION_FACTOR, 426 | pub const AL_ROOM_ROLLOFF_FACTOR, 427 | pub const AL_CONE_OUTER_GAINHF, 428 | pub const AL_DIRECT_FILTER_GAINHF_AUTO, 429 | pub const AL_AUXILIARY_SEND_FILTER_GAIN_AUTO, 430 | pub const AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO, 431 | 432 | pub const AL_METERS_PER_UNIT, 433 | 434 | pub const ALC_EFX_MAJOR_VERSION, 435 | pub const ALC_EFX_MINOR_VERSION, 436 | pub const ALC_MAX_AUXILIARY_SENDS, 437 | 438 | 439 | pub fn alGenAuxiliaryEffectSlots: unsafe extern "C" fn(n: ALsizei, auxiliaryeffectslots: *mut ALuint), 440 | pub fn alDeleteAuxiliaryEffectSlots: unsafe extern "C" fn(n: ALsizei, auxiliaryeffectslots: *mut ALuint), 441 | pub fn alIsAuxiliaryEffectSlot: unsafe extern "C" fn(auxiliaryeffectslot: ALuint), 442 | pub fn alAuxiliaryEffectSloti: unsafe extern "C" fn(auxiliaryeffectslot: ALuint, param: ALenum, iValue: ALint), 443 | pub fn alAuxiliaryEffectSlotiv: unsafe extern "C" fn(auxiliaryeffectslot: ALuint, param: ALenum, piValues: *mut ALint), 444 | pub fn alAuxiliaryEffectSlotf: unsafe extern "C" fn(auxiliaryeffectslot: ALuint, param: ALenum, flValue: ALfloat), 445 | pub fn alAuxiliaryEffectSlotfv: unsafe extern "C" fn(auxiliaryeffectslot: ALuint, param: ALenum, pflValues: *mut ALfloat), 446 | pub fn alGetAuxiliaryEffectSloti: unsafe extern "C" fn(auxiliaryeffectslot: ALuint, param: ALenum, piValue: *mut ALint), 447 | pub fn alGetAuxiliaryEffectSlotiv: unsafe extern "C" fn(auxiliaryeffectslot: ALuint, param: ALenum, piValues: *mut ALint), 448 | pub fn alGetAuxiliaryEffectSlotf: unsafe extern "C" fn(auxiliaryeffectslot: ALuint, param: ALenum, pflValue: *mut ALfloat), 449 | pub fn alGetAuxiliaryEffectSlotfv: unsafe extern "C" fn(auxiliaryeffectslot: ALuint, param: ALenum, pflValues: *mut ALfloat), 450 | 451 | pub fn alGenEffects: unsafe extern "C" fn(n: ALsizei, effects: *mut ALuint), 452 | pub fn alDeleteEffects: unsafe extern "C" fn(n: ALsizei, effects: *mut ALuint), 453 | pub fn alIsEffect: unsafe extern "C" fn(effect: ALuint), 454 | pub fn alEffecti: unsafe extern "C" fn(effect: ALuint, param: ALenum, iValue: ALint), 455 | pub fn alEffectiv: unsafe extern "C" fn(effect: ALuint, param: ALenum, piValues: *mut ALint), 456 | pub fn alEffectf: unsafe extern "C" fn(effect: ALuint, param: ALenum, flValue: ALfloat), 457 | pub fn alEffectfv: unsafe extern "C" fn(effect: ALuint, param: ALenum, pflValues: *mut ALfloat), 458 | pub fn alGetEffecti: unsafe extern "C" fn(effect: ALuint, param: ALenum, piValue: *mut ALint), 459 | pub fn alGetEffectiv: unsafe extern "C" fn(effect: ALuint, param: ALenum, piValues: *mut ALint), 460 | pub fn alGetEffectf: unsafe extern "C" fn(effect: ALuint, param: ALenum, pflValue: *mut ALfloat), 461 | pub fn alGetEffectfv: unsafe extern "C" fn(effect: ALuint, param: ALenum, pflValues: *mut ALfloat), 462 | 463 | pub fn alGenFilters: unsafe extern "C" fn(n: ALsizei, filters: *mut ALuint), 464 | pub fn alDeleteFilters: unsafe extern "C" fn(n: ALsizei, filters: *mut ALuint), 465 | pub fn alIsFilter: unsafe extern "C" fn(filter: ALuint), 466 | pub fn alFilteri: unsafe extern "C" fn(filter: ALuint, param: ALenum, iValue: ALint), 467 | pub fn alFilteriv: unsafe extern "C" fn(filter: ALuint, param: ALenum, piValues: *mut ALint), 468 | pub fn alFilterf: unsafe extern "C" fn(filter: ALuint, param: ALenum, flValue: ALfloat), 469 | pub fn alFilterfv: unsafe extern "C" fn(filter: ALuint, param: ALenum, pflValues: *mut ALfloat), 470 | pub fn alGetFilteri: unsafe extern "C" fn(filter: ALuint, param: ALenum, piValue: *mut ALint), 471 | pub fn alGetFilteriv: unsafe extern "C" fn(filter: ALuint, param: ALenum, piValues: *mut ALint), 472 | pub fn alGetFilterf: unsafe extern "C" fn(filter: ALuint, param: ALenum, pflValue: *mut ALfloat), 473 | pub fn alGetFilterfv: unsafe extern "C" fn(filter: ALuint, param: ALenum, pflValues: *mut ALfloat), 474 | } 475 | 476 | 477 | pub ext ALC_SOFT_HRTF { 478 | pub const ALC_HRTF_SOFT, 479 | pub const ALC_HRTF_ID_SOFT, 480 | pub const ALC_DONT_CARE_SOFT, 481 | pub const ALC_HRTF_STATUS_SOFT, 482 | pub const ALC_NUM_HRTF_SPECIFIERS_SOFT, 483 | pub const ALC_HRTF_SPECIFIER_SOFT, 484 | pub const ALC_HRTF_DISABLED_SOFT, 485 | pub const ALC_HRTF_ENABLED_SOFT, 486 | pub const ALC_HRTF_DENIED_SOFT, 487 | pub const ALC_HRTF_REQUIRED_SOFT, 488 | pub const ALC_HRTF_HEADPHONES_DETECTED_SOFT, 489 | pub const ALC_HRTF_UNSUPPORTED_FORMAT_SOFT, 490 | 491 | pub fn alcGetStringiSOFT: unsafe extern "C" fn(dev: *mut ALCdevice, paramName: ALCenum, index: ALCsizei) -> *const ALCchar, 492 | pub fn alcResetDeviceSOFT: unsafe extern "C" fn(dev: *mut ALCdevice, attrList: *const ALCint) -> ALCboolean, 493 | } 494 | 495 | 496 | pub ext ALC_SOFT_pause_device { 497 | pub fn alcDevicePauseSOFT: unsafe extern "C" fn(dev: *mut ALCdevice), 498 | pub fn alcDeviceResumeSOFT: unsafe extern "C" fn(dev: *mut ALCdevice), 499 | } 500 | 501 | 502 | pub ext ALC_SOFT_output_limiter { 503 | pub const ALC_OUTPUT_LIMITER_SOFT, 504 | pub const ALC_DONT_CARE_SOFT, 505 | 506 | pub fn alcResetDeviceSOFT: unsafe extern "C" fn(dev: *mut ALCdevice, attrList: *const ALCint) -> ALCboolean, 507 | } 508 | } 509 | 510 | 511 | pub type ALint64SOFT = i64; 512 | pub type ALuint64SOFT = u64; 513 | 514 | 515 | al_ext! { 516 | pub(crate) cache AlCache; 517 | 518 | 519 | pub ext AL_EXT_ALAW { 520 | pub const AL_FORMAT_MONO_ALAW_EXT, 521 | pub const AL_FORMAT_STEREO_ALAW_EXT, 522 | } 523 | 524 | 525 | pub ext AL_EXT_BFORMAT { 526 | pub const AL_FORMAT_BFORMAT2D_8, 527 | pub const AL_FORMAT_BFORMAT2D_16, 528 | pub const AL_FORMAT_BFORMAT2D_FLOAT32, 529 | pub const AL_FORMAT_BFORMAT3D_8, 530 | pub const AL_FORMAT_BFORMAT3D_16, 531 | pub const AL_FORMAT_BFORMAT3D_FLOAT32, 532 | } 533 | 534 | 535 | pub ext AL_EXT_double { 536 | pub const AL_FORMAT_MONO_DOUBLE_EXT, 537 | pub const AL_FORMAT_STEREO_DOUBLE_EXT, 538 | } 539 | 540 | 541 | pub ext AL_EXT_float32 { 542 | pub const AL_FORMAT_MONO_FLOAT32, 543 | pub const AL_FORMAT_STEREO_FLOAT32, 544 | } 545 | 546 | 547 | pub ext AL_EXT_IMA4 { 548 | pub const AL_FORMAT_MONO_IMA4, 549 | pub const AL_FORMAT_STEREO_IMA4, 550 | } 551 | 552 | 553 | pub ext AL_EXT_MCFORMATS { 554 | pub const AL_FORMAT_QUAD8, 555 | pub const AL_FORMAT_QUAD16, 556 | pub const AL_FORMAT_QUAD32, 557 | pub const AL_FORMAT_REAR8, 558 | pub const AL_FORMAT_REAR16, 559 | pub const AL_FORMAT_REAR32, 560 | pub const AL_FORMAT_51CHN8, 561 | pub const AL_FORMAT_51CHN16, 562 | pub const AL_FORMAT_51CHN32, 563 | pub const AL_FORMAT_61CHN8, 564 | pub const AL_FORMAT_61CHN16, 565 | pub const AL_FORMAT_61CHN32, 566 | pub const AL_FORMAT_71CHN8, 567 | pub const AL_FORMAT_71CHN16, 568 | pub const AL_FORMAT_71CHN32, 569 | } 570 | 571 | 572 | pub ext AL_EXT_MULAW { 573 | pub const AL_FORMAT_MONO_MULAW_EXT, 574 | pub const AL_FORMAT_STEREO_MULAW_EXT, 575 | } 576 | 577 | 578 | pub ext AL_EXT_MULAW_BFORMAT { 579 | pub const AL_FORMAT_BFORMAT2D_MULAW, 580 | pub const AL_FORMAT_BFORMAT3D_MULAW, 581 | } 582 | 583 | 584 | pub ext AL_EXT_MULAW_MCFORMATS { 585 | pub const AL_FORMAT_MONO_MULAW, 586 | pub const AL_FORMAT_STEREO_MULAW, 587 | pub const AL_FORMAT_QUAD_MULAW, 588 | pub const AL_FORMAT_REAR_MULAW, 589 | pub const AL_FORMAT_51CHN_MULAW, 590 | pub const AL_FORMAT_61CHN_MULAW, 591 | pub const AL_FORMAT_71CHN_MULAW, 592 | } 593 | 594 | 595 | pub ext AL_SOFT_block_alignment { 596 | pub const AL_UNPACK_BLOCK_ALIGNMENT_SOFT, 597 | pub const AL_PACK_BLOCK_ALIGNMENT_SOFT, 598 | } 599 | 600 | 601 | // pub ext AL_SOFT_buffer_samples { 602 | // pub const AL_MONO_SOFT, 603 | // pub const AL_STEREO_SOFT, 604 | // pub const AL_REAR_SOFT, 605 | // pub const AL_QUAD_SOFT, 606 | // pub const AL_5POINT1_SOFT, 607 | // pub const AL_6POINT1_SOFT, 608 | // pub const AL_7POINT1_SOFT, 609 | // 610 | // pub const AL_BYTE_SOFT, 611 | // pub const AL_UNSIGNED_BYTE_SOFT, 612 | // pub const AL_SHORT_SOFT, 613 | // pub const AL_UNSIGNED_SHORT_SOFT, 614 | // pub const AL_INT_SOFT, 615 | // pub const AL_UNSIGNED_INT_SOFT, 616 | // pub const AL_FLOAT_SOFT, 617 | // pub const AL_DOUBLE_SOFT, 618 | // pub const AL_BYTE3_SOFT, 619 | // pub const AL_UNSIGNED_BYTE3_SOFT, 620 | // 621 | // pub const AL_MONO8_SOFT, 622 | // pub const AL_MONO16_SOFT, 623 | // pub const AL_MONO32F_SOFT, 624 | // pub const AL_STEREO8_SOFT, 625 | // pub const AL_STEREO16_SOFT, 626 | // pub const AL_STEREO32F_SOFT, 627 | // pub const AL_QUAD8_SOFT, 628 | // pub const AL_QUAD16_SOFT, 629 | // pub const AL_QUAD32F_SOFT, 630 | // pub const AL_REAR8_SOFT, 631 | // pub const AL_REAR16_SOFT, 632 | // pub const AL_REAR32F_SOFT, 633 | // pub const AL_5POINT1_8_SOFT, 634 | // pub const AL_5POINT1_16_SOFT, 635 | // pub const AL_5POINT1_32F_SOFT, 636 | // pub const AL_6POINT1_8_SOFT, 637 | // pub const AL_6POINT1_16_SOFT, 638 | // pub const AL_6POINT1_32F_SOFT, 639 | // pub const AL_7POINT1_8_SOFT, 640 | // pub const AL_7POINT1_16_SOFT, 641 | // pub const AL_7POINT1_32F_SOFT, 642 | // 643 | // pub const AL_INTERNAL_FORMAT_SOFT, 644 | // pub const AL_BYTE_LENGTH_SOFT, 645 | // pub const AL_SAMPLE_LENGTH_SOFT, 646 | // pub const AL_SEC_LENGTH_SOFT, 647 | // 648 | // pub fn alBufferSamplesSOFT: unsafe extern "C" fn(buffer: ALuint, samplerate: ALuint, internalformat: ALenum, samples: ALsizei, channels: ALenum, type_: ALenum, data: *const ALvoid), 649 | // pub fn alBufferSubSamplesSOFT: unsafe extern "C" fn(buffer: ALuint, offset: ALsizei, samples: ALsizei, channels: ALenum, type_: ALenum, data: *const ALvoid), 650 | // pub fn alGetBufferSamplesSOFT: unsafe extern "C" fn(buffer: ALuint, offset: ALsizei, samples: ALsizei, channels: ALenum, type_: ALenum, data: *mut ALvoid), 651 | // pub fn alIsBufferFormatSupportedSOFT: unsafe extern "C" fn(format: ALenum) -> ALboolean, 652 | // } 653 | // 654 | // 655 | // pub ext AL_SOFT_buffer_sub_data { 656 | // pub const AL_BYTE_RW_OFFSETS_SOFT, 657 | // pub const AL_SAMPLE_RW_OFFSETS_SOFT, 658 | // 659 | // pub fn alBufferSubDataSOFT: unsafe extern "C" fn(buffer: ALuint, format: ALenum, data: *const ALvoid, offset: ALsizei, length: ALsizei), 660 | // } 661 | 662 | 663 | pub ext AL_SOFT_deferred_updates { 664 | pub const AL_DEFERRED_UPDATES_SOFT, 665 | 666 | pub fn alDeferUpdatesSOFT: unsafe extern "C" fn(), 667 | pub fn alProcessUpdatesSOFT: unsafe extern "C" fn(), 668 | } 669 | 670 | 671 | pub ext AL_SOFT_direct_channels { 672 | pub const AL_DIRECT_CHANNELS_SOFT, 673 | } 674 | 675 | 676 | pub ext AL_SOFT_loop_points { 677 | pub const AL_LOOP_POINTS_SOFT, 678 | } 679 | 680 | 681 | pub ext AL_SOFT_MSADPCM { 682 | pub const AL_FORMAT_MONO_MSADPCM_SOFT, 683 | pub const AL_FORMAT_STEREO_MSADPCM_SOFT, 684 | } 685 | 686 | 687 | pub ext AL_SOFT_source_latency { 688 | pub const AL_SAMPLE_OFFSET_LATENCY_SOFT, 689 | pub const AL_SEC_OFFSET_LATENCY_SOFT, 690 | 691 | pub fn alSourcedSOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, value: ALdouble), 692 | pub fn alSource3dSOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, value1: ALdouble, value2: ALdouble, value3: ALdouble), 693 | pub fn alSourcedvSOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, values: *const ALdouble), 694 | pub fn alGetSourcedSOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, value: *mut ALdouble), 695 | pub fn alGetSource3dSOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, value1: *mut ALdouble, value2: *mut ALdouble, value3: *mut ALdouble), 696 | pub fn alGetSourcedvSOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, values: *mut ALdouble), 697 | pub fn alSourcei64SOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, value: ALint64SOFT), 698 | pub fn alSource3i64SOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, value1: ALint64SOFT, value2: ALint64SOFT, value3: ALint64SOFT), 699 | pub fn alSourcei64vSOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, values: *const ALint64SOFT), 700 | pub fn alGetSourcei64SOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, value: *mut ALint64SOFT), 701 | pub fn alGetSource3i64SOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, value1: *mut ALint64SOFT, value2: *mut ALint64SOFT, value3: *mut ALint64SOFT), 702 | pub fn alGetSourcei64vSOFT: unsafe extern "C" fn(source: ALuint, param: ALenum, values: *mut ALint64SOFT), 703 | } 704 | 705 | 706 | pub ext AL_SOFT_source_length { 707 | pub const AL_BYTE_LENGTH_SOFT, 708 | pub const AL_SAMPLE_LENGTH_SOFT, 709 | pub const AL_SEC_LENGTH_SOFT, 710 | } 711 | 712 | 713 | pub ext AL_EXT_source_distance_model { 714 | pub const AL_SOURCE_DISTANCE_MODEL, 715 | } 716 | 717 | 718 | pub ext AL_EXT_STEREO_ANGLES { 719 | pub const AL_STEREO_ANGLES, 720 | } 721 | 722 | 723 | pub ext AL_EXT_SOURCE_RADIUS { 724 | pub const AL_SOURCE_RADIUS, 725 | } 726 | 727 | 728 | pub ext AL_SOFT_gain_clamp_ex { 729 | pub const AL_GAIN_LIMIT_SOFT, 730 | } 731 | 732 | 733 | pub ext AL_SOFT_source_resampler { 734 | pub const AL_NUM_RESAMPLERS_SOFT, 735 | pub const AL_DEFAULT_RESAMPLER_SOFT, 736 | pub const AL_SOURCE_RESAMPLER_SOFT, 737 | pub const AL_RESAMPLER_NAME_SOFT, 738 | 739 | pub fn alGetStringiSOFT: unsafe extern "C" fn(paramName: ALenum, index: ALsizei) -> *const ALchar, 740 | } 741 | 742 | 743 | pub ext AL_SOFT_source_spatialize { 744 | pub const AL_SOURCE_SPATIALIZE_SOFT, 745 | pub const AL_AUTO_SOFT, 746 | } 747 | } 748 | 749 | 750 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # Overview 2 | //! Alto is an idiomatic wrapper for the OpenAL 3D audio API and associated extensions (including EFX). 3 | //! This documentation does not describe how to use the OpenAL API itself, but rather explains how 4 | //! it has been adapted for rust and provides the native symbols associated with each function 5 | //! so they can be cross-referenced with the official OpenAL documentation for full details. 6 | //! 7 | //! The core of the API is the [`Alto`](struct.Alto.html) struct. It has no analog in raw OpenAL and 8 | //! represents an implementation of the API itself. From there, instances of familiar OpenAL objects 9 | //! can be instantiated. 10 | //! 11 | //! # WARNING 12 | //! Because Alto interacts with global C state via dynamic linking, having multiple versions of Alto in one project could lead to unsafety. 13 | //! Please make sure only one version of Alto is in your dependency tree at any given time. 14 | 15 | 16 | #[macro_use] 17 | extern crate lazy_static; 18 | extern crate parking_lot; 19 | extern crate al_sys; 20 | 21 | use std::error::Error as StdError; 22 | use std::fmt; 23 | use std::io; 24 | 25 | 26 | mod alc; 27 | pub use alc::*; 28 | 29 | 30 | mod al; 31 | pub use al::*; 32 | 33 | 34 | pub mod ext; 35 | 36 | 37 | pub mod efx; 38 | 39 | 40 | pub mod sys { 41 | pub use al_sys::*; 42 | } 43 | 44 | 45 | /// An error as reported by `alcGetError` or `alGetError`, plus some Alto specific variants. 46 | #[derive(Debug)] 47 | pub enum AltoError { 48 | /// `ALC_INVALID_DEVICE` 49 | InvalidDevice, 50 | /// `ALC_INVALID_CONTEXT` 51 | InvalidContext, 52 | /// `AL_INVALID_NAME` 53 | InvalidName, 54 | /// `ALC/AL_INVALID_ENUM` 55 | InvalidEnum, 56 | /// `ALC/AL_INVALID_VALUE` 57 | InvalidValue, 58 | /// `AL_INVALID_OPERATION` 59 | InvalidOperation, 60 | /// `ALC/AL_OUT_OF_MEMORY` 61 | OutOfMemory, 62 | UnknownAlcError(sys::ALCint), 63 | UnknownAlError(sys::ALint), 64 | 65 | /// The underlying implementation is not compatible with the 1.1 spec. Alto specific. 66 | UnsupportedVersion{major: sys::ALCint, minor: sys::ALCint}, 67 | /// The requested action can't be performed because the required extension is unavaiable. Alto specific. 68 | ExtensionNotPresent, 69 | /// Resource creation failed without setting an error code. 70 | NullError, 71 | /// A resource belongs to another device and is not eligible. 72 | WrongDevice, 73 | /// A resource belongs to another context and is not eligible. 74 | WrongContext, 75 | /// There was an underlying IO error, usually from a failure when loading the OpenAL dylib. Alto specific. 76 | Io(io::Error), 77 | } 78 | 79 | 80 | pub type AltoResult = ::std::result::Result; 81 | 82 | 83 | impl AltoError { 84 | fn from_alc(alc: sys::ALCenum) -> AltoError { 85 | match alc { 86 | sys::ALC_INVALID_DEVICE => AltoError::InvalidDevice, 87 | sys::ALC_INVALID_CONTEXT => AltoError::InvalidContext, 88 | sys::ALC_INVALID_ENUM => AltoError::InvalidEnum, 89 | sys::ALC_INVALID_VALUE => AltoError::InvalidValue, 90 | sys::ALC_OUT_OF_MEMORY => AltoError::OutOfMemory, 91 | e => AltoError::UnknownAlcError(e), 92 | } 93 | } 94 | 95 | 96 | fn from_al(al: sys::ALenum) -> AltoError { 97 | match al { 98 | sys::AL_INVALID_NAME => AltoError::InvalidName, 99 | sys::AL_INVALID_ENUM => AltoError::InvalidEnum, 100 | sys::AL_INVALID_VALUE => AltoError::InvalidValue, 101 | sys::AL_INVALID_OPERATION => AltoError::InvalidOperation, 102 | sys::AL_OUT_OF_MEMORY => AltoError::OutOfMemory, 103 | e => AltoError::UnknownAlError(e), 104 | } 105 | } 106 | } 107 | 108 | 109 | impl fmt::Display for AltoError { 110 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 111 | write!(f, "{}", self.description()) 112 | } 113 | } 114 | 115 | 116 | impl StdError for AltoError { 117 | fn description(&self) -> &str { 118 | match *self { 119 | AltoError::InvalidDevice => "ALTO ERROR: ALC Invalid Device", 120 | AltoError::InvalidContext => "ALTO ERROR: ALC Invalid Context", 121 | AltoError::InvalidName => "ALTO ERROR: AL Invalid Name", 122 | AltoError::InvalidEnum => "ALTO ERROR: ALC Invalid Enum", 123 | AltoError::InvalidValue => "ALTO ERROR: ALC Invalid Value", 124 | AltoError::InvalidOperation => "ALTO ERROR: AL Invalid Operation", 125 | AltoError::OutOfMemory => "ALTO ERROR: ALC Out of Memory", 126 | AltoError::UnknownAlcError(..) => "ALTO ERROR: Unknown ALC error", 127 | AltoError::UnknownAlError(..) => "ALTO ERROR: Unknown AL error", 128 | 129 | AltoError::UnsupportedVersion{..} => "ALTO ERROR: Unsupported Version", 130 | AltoError::ExtensionNotPresent => "ALTO ERROR: Extension Not Present", 131 | AltoError::NullError => "ALTO ERROR: Return value is NULL with no error code", 132 | AltoError::WrongDevice => "ALTO ERROR: Resource used on wrong device", 133 | AltoError::WrongContext => "ALTO ERROR: Resource used on wrong device", 134 | AltoError::Io(ref io) => io.description(), 135 | } 136 | } 137 | } 138 | 139 | 140 | impl From for AltoError { 141 | fn from(io: io::Error) -> AltoError { 142 | AltoError::Io(io) 143 | } 144 | } 145 | 146 | 147 | impl From for AltoError { 148 | fn from(_: ext::ExtensionError) -> AltoError { 149 | AltoError::ExtensionNotPresent 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /tests/alto.rs: -------------------------------------------------------------------------------- 1 | extern crate alto; 2 | 3 | use std::ffi::CStr; 4 | 5 | use alto::{Alto, Capture, DeviceObject, Stereo}; 6 | 7 | type MyCapture = Capture>; 8 | 9 | fn load_alto() -> Alto { 10 | Alto::load_default().unwrap() 11 | } 12 | 13 | fn open_cap(a: &Alto, spec: Option<&CStr>) -> MyCapture { 14 | a.open_capture(spec, 4096, 1024).unwrap() 15 | } 16 | 17 | #[test] 18 | fn load_default() { 19 | load_alto(); 20 | } 21 | 22 | #[test] 23 | fn default_output() { 24 | let a = load_alto(); 25 | 26 | let def = a.default_output().unwrap(); 27 | 28 | println!("{:?}", def.to_str().unwrap()); 29 | 30 | let d_def = a.open(Some(&def)).unwrap(); 31 | let d_none = a.open(None).unwrap(); 32 | 33 | assert_eq!(d_def.specifier(), d_none.specifier()); 34 | } 35 | 36 | #[test] 37 | fn specified_output() { 38 | let a = load_alto(); 39 | let devices = a.enumerate_outputs(); 40 | 41 | for device in devices { 42 | let dev = a.open(Some(&device)).unwrap(); 43 | assert_eq!(dev.specifier().unwrap(), device.as_ref()); 44 | } 45 | } 46 | 47 | #[test] 48 | fn default_input() { 49 | let a = load_alto(); 50 | 51 | let def = a.default_capture().unwrap(); 52 | let d_def = open_cap(&a, Some(&def)); 53 | let d_none = open_cap(&a, Some(&def)); 54 | 55 | assert_eq!(d_def.specifier(), d_none.specifier()); 56 | } 57 | 58 | #[test] 59 | fn specified_input() { 60 | let a = load_alto(); 61 | let devices = a.enumerate_captures(); 62 | 63 | for device in devices { 64 | let dev = open_cap(&a, Some(&device)); 65 | assert_eq!(dev.specifier().unwrap(), device.as_ref()); 66 | } 67 | } 68 | --------------------------------------------------------------------------------