pub struct Audio {
_stream: Stream,
mixer: Arc<Mutex<Mixer>>,
cache: HashMap<i32, Option<Arc<Sound>>>,
map_name: String,
rng: u32,
music: (u32, String),
timbres: Option<Vec<Timbre>>,
}Fields§
§_stream: Stream§mixer: Arc<Mutex<Mixer>>§cache: HashMap<i32, Option<Arc<Sound>>>§map_name: String§rng: u32§music: (u32, String)CD track and song of the music playing (to keep it going across reloads).
timbres: Option<Vec<Timbre>>AdLib timbre bank for MIDI music (GMTIMBRE.TMB), if present.
Implementations§
Source§impl Audio
impl Audio
pub fn new(res: &Resources) -> Result<Audio, String>
fn rand(&mut self) -> u32
Sourcefn preload_all(&mut self, res: &Resources)
fn preload_all(&mut self, res: &Resources)
Decodes every sound effect once, up front (about the size of SOUNDS.RFF in memory), so starting a level or firing a weapon never waits for a sound to load.
pub fn load(&mut self, res: &Resources, id: i32) -> Option<Arc<Sound>>
Sourcepub fn play(
&mut self,
res: &Resources,
id: i32,
at: Option<(f64, f64, f64)>,
looping: bool,
radius: (f64, f64),
owner: i64,
)
pub fn play( &mut self, res: &Resources, id: i32, at: Option<(f64, f64, f64)>, looping: bool, radius: (f64, f64), owner: i64, )
Plays sound id, optionally at a world position.
Sourcepub fn play_movie_sound(&mut self, samples: Vec<u8>, rate: u32)
pub fn play_movie_sound(&mut self, samples: Vec<u8>, rate: u32)
Plays a cutscene soundtrack (unsigned 8-bit mono PCM) and turns the music off until
Audio::stop_movie.
Sourcepub fn stop_movie(&mut self)
pub fn stop_movie(&mut self)
Stops the cutscene soundtrack and brings the music back.
fn start_level(&mut self, res: &Resources, game: &Game)
pub fn on_event(&mut self, res: &Resources, game: &Game, e: &GameEvent)
Sourcepub fn update_listener(&mut self, game: &Game)
pub fn update_listener(&mut self, game: &Game)
Updates positional volumes and panning; restarts ambience on level change.
pub fn level_changed(&mut self, res: &Resources, game: &Game)
pub fn set_volumes(&mut self, sfx: f32, music: f32)
Sourcepub fn play_music(&mut self, res: &Resources, n: u32, song: &str)
pub fn play_music(&mut self, res: &Resources, n: u32, song: &str)
Plays CD track n from music/TRACKnn.WAV (ripped from the user’s own disc). When
that file is missing, plays the MIDI song from SOUNDS.RFF with the FM synthesizer.
Auto Trait Implementations§
impl !RefUnwindSafe for Audio
impl !Send for Audio
impl !Sync for Audio
impl !UnwindSafe for Audio
impl Freeze for Audio
impl Unpin for Audio
impl UnsafeUnpin for Audio
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more