fyrox_sound/lib.rs
1// Copyright (c) 2019-present Dmitry Stepanov and Fyrox Engine contributors.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in all
11// copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19// SOFTWARE.
20
21//! Sound library for games and interactive applications.
22//!
23//! ## Features
24//!
25//! - Generic and spatial sounds.
26//! - WAV and OGG/Vorbis formats support.
27//! - Streaming.
28//! - Head-related transfer function support ([HRTF](https://en.wikipedia.org/wiki/Head-related_transfer_function)).
29//! - Reverb effect.
30//!
31//! ## Examples
32//!
33//! Here is an example of how to play a sound using fyrox-sound:
34//!
35//! ```no_run
36//! use std::{
37//! thread,
38//! time::Duration
39//! };
40//! use fyrox_sound::{
41//! source::{
42//! SoundSourceBuilder,
43//! SoundSource,
44//! Status
45//! },
46//! context::SoundContext,
47//! buffer::{
48//! DataSource,
49//! SoundBufferResource
50//! },
51//! };
52//! use fyrox_sound::buffer::SoundBufferResourceExtension;
53//! use fyrox_resource::io::FsResourceIo;
54//!
55//! let context = SoundContext::new();
56//!
57//! let sound_buffer = SoundBufferResource::new_generic(fyrox_sound::futures::executor::block_on(DataSource::from_file("sound.wav", &FsResourceIo)).unwrap()).unwrap();
58//!
59//! let source = SoundSourceBuilder::new()
60//! .with_buffer(sound_buffer)
61//! .with_status(Status::Playing)
62//! .build()
63//! .unwrap();
64//!
65//! context.state()
66//! .add_source(source);
67//!
68//! thread::sleep(Duration::from_secs(3));
69//!
70//! ```
71//!
72//! Other examples can be found in `./examples` folder. Make sure you run them with `--release` flag.
73//!
74//! ## Supported OS
75//!
76//! - Windows (DirectSound)
77//! - Linux (alsa)
78//! - macOS (CoreAudio)
79//! - WebAssembly (WebAudio)
80//! - Android (AAudio, API Level 26+)
81//!
82//! ## HRTF
83//!
84//! Library uses special HRIR Spheres which were composed from IRCAM HRIR database. Since
85//! HRTF is very specific to each person, you should try some of them to find best for you.
86//! They can be found [here](https://github.com/mrDIMAS/hrir_sphere_builder/tree/master/hrtf_base/IRCAM).
87
88#![warn(missing_docs)]
89
90pub mod buffer;
91pub mod context;
92
93pub mod bus;
94pub mod dsp;
95pub mod effects;
96pub mod engine;
97pub mod error;
98pub mod listener;
99pub mod renderer;
100pub mod source;
101
102// Reexport some modules because there some types of them in public API.
103pub use fyrox_core::algebra;
104pub use fyrox_core::futures;
105pub use fyrox_core::math;
106pub use fyrox_core::pool;
107pub use hrtf;
108
109mod decoder;