System

Struct System 

Source
pub struct System { /* private fields */ }
Expand description

Fmod system object.

This is a single reference counted pointer, so it can be freely cloned.

§Channels

There are three types of channel considered by the FMOD system:

  1. hardware output channels or “speakermode channels” – the number of speakermode channels is returned in the DriverInfo structure by the system.get_driver_info() method
  2. software channels – “mixable voices”; unless specified, the FMOD default number of software channels is 64
  3. virtual channels – these are virtual voices that can be dynamically mapped to an available software channel depending on how audible it is

When playing a Sound with sound.play(), that sound is assigned to the returned virtual channel. If there are more playing virtual channels than the number of software channels, some channels will be dynamically virtualized and excluded from mixing, although other aspects such as playback position will continue to be updated.

If, at the time of the call to sound.play(), all virtual channels are in use, the virtual channel with the lowest priority will be ‘stolen’ from the currently playing sound, i.e. the sound currently playing on that channel is stopped and any subsequent function calls on the stolen sound’s previously returned Channel will return Error::ChannelStolen.

The default priority for playback is 128. In practice if a number of default priority play() calls exceeding the virtual channel count are made all at once, the last played channel is re-stolen on each subsequent call to play.

§Reverb

TODO

Implementations§

Source§

impl System

Source

pub fn default() -> Result<Self, Error>

Create and initialize with 256 max virtual channels, the default number of software channels (64), and Initflags::NORMAL.

Examples found in repository?
examples/example.rs (line 15)
12fn main() {
13  println!("fmod example main...");
14
15  let mut system     = System::default().unwrap();
16  hex!(fmod::FMOD_VERSION);
17  hex!(system.get_version().unwrap());
18
19  let sound_filename = "bite.wav";
20  println!("  opening {sound_filename:?}");
21  let mut sound      = system.create_sound_from_file_default (sound_filename)
22    .unwrap();
23  println!("  playing {sound_filename:?}");
24  let channel        = sound.play (None, false).unwrap();
25  while channel.is_playing().unwrap() {
26    std::thread::sleep (std::time::Duration::from_millis (100));
27  }
28  println!("...fmod example main");
29}
Source

pub fn new( num_software_channels: Option<u16>, num_virtual_channels: u16, initflags: Initflags, ) -> Result<Self, Error>

Create with the given number of software channels, max number of virtual channels, and initflags.

If the number of software channels is not provided, by default FMOD will create a system with 64 software channels.

Source

pub fn update(&mut self) -> Result<(), Error>

Source

pub fn get_3d_listener_attributes( &self, listener: i32, ) -> Result<ListenerAttributes, Error>

Source

pub fn get_3d_num_listeners(&self) -> Result<i32, Error>

Source

pub fn get_3d_settings(&self) -> Result<(f32, f32, f32), Error>

Retrieves the global doppler scale, distance factor and rolloff scale for all 3D sound in FMOD

Source

pub fn get_channels_playing(&self) -> Result<(i32, i32), Error>

Source

pub fn get_cpu_usage(&self) -> Result<CpuUsage, Error>

Source

pub fn get_driver(&self) -> Result<i32, Error>

Returns the currently selected driver number

Source

pub fn get_driver_info(&self, id: i32) -> Result<DriverInfo, Error>

Source

pub fn get_dsp_buffer_size(&self) -> Result<(u32, i32), Error>

Retrieves the buffer size settings for the FMOD software mixing engine.

Returns (bufferlength, numbuffers):

  • buffelength – Address of a variable that receives the mixer engine block size in samples. Default = 1024. (milliseconds = 1024 at 48khz = 1024 / 48000 * 1000 = 10.66ms). This means the mixer updates every 21.3ms.
  • numbuffers – Address of a variable that receives the mixer engine number of buffers used. Default = 4. To get the total buffersize multiply the bufferlength by the numbuffers value. By default this would be 4*1024.
Source

pub fn get_geometry_occlusion( &self, listener: [f32; 3], source: [f32; 3], ) -> Result<(f32, f32), Error>

Calculates geometry occlusion between a listener and a sound source.

Returns (direct, reverb).

Source

pub fn get_geometry_settings(&self) -> Result<f32, Error>

Retrieves the maximum world size for the geometry engine

Source

pub fn get_master_channel_group(&self) -> Result<ChannelGroupRef, Error>

Source

pub fn get_num_drivers(&self) -> Result<i32, Error>

Source

pub fn get_num_plugins(&self, plugintype: Plugintype) -> Result<i32, Error>

Source

pub fn get_output(&self) -> Result<Outputtype, Error>

Source

pub fn get_output_by_plugin(&self) -> Result<PluginHandle, Error>

Returns the currently selected output as an id in the list of output plugins

Source

pub fn get_record_driver_info( &self, id: i32, ) -> Result<(DriverInfo, DriverState), Error>

Source

pub fn get_record_num_drivers(&self) -> Result<(i32, i32), Error>

Returns the number of recording drivers available for this output mode and the number of recording drivers currently plugged in

Source

pub fn get_reverb_properties(&self, instance: i32) -> Result<Properties, Error>

Source

pub fn get_software_channels(&self) -> Result<i32, Error>

Source

pub fn get_software_format(&self) -> Result<(i32, Speakermode, i32), Error>

Retrieves the output format for the software mixer:

(samplerate, speakermode, numrawspeakers)

Source

pub fn get_sound_ram(&self) -> Result<SoundRam, Error>

Source

pub fn get_speaker_mode_channels(&self, mode: Speakermode) -> Result<i32, Error>

Source

pub fn get_speaker_position( &self, speaker: Speaker, ) -> Result<(f32, f32, bool), Error>

Retrieves the current speaker position information for the selected speaker.

Returns (x, y, active).

Source

pub fn get_stream_buffer_size(&self) -> Result<(u32, Timeunit), Error>

Returns the current internal buffersize settings for streamable sounds

Source

pub fn get_version(&self) -> Result<u32, Error>

Version of linked FMOD shared library.

The version is a 32 bit hexadecimal value formated as 16:8:8, with the upper 16 bits being the product version, the middle 8 bits being the major version and the bottom 8 bits being the minor version.

Examples found in repository?
examples/example.rs (line 17)
12fn main() {
13  println!("fmod example main...");
14
15  let mut system     = System::default().unwrap();
16  hex!(fmod::FMOD_VERSION);
17  hex!(system.get_version().unwrap());
18
19  let sound_filename = "bite.wav";
20  println!("  opening {sound_filename:?}");
21  let mut sound      = system.create_sound_from_file_default (sound_filename)
22    .unwrap();
23  println!("  playing {sound_filename:?}");
24  let channel        = sound.play (None, false).unwrap();
25  while channel.is_playing().unwrap() {
26    std::thread::sleep (std::time::Duration::from_millis (100));
27  }
28  println!("...fmod example main");
29}
Source

pub fn get_version_string(&self) -> Result<String, Error>

Version of linked FMOD shared library

Source

pub fn create_channel_group( &mut self, name: Option<&str>, ) -> Result<ChannelGroup, Error>

Source

pub fn create_dsp( &mut self, description: &'static Description, ) -> Result<Dsp, Error>

Source

pub fn create_dsp_by_type(&mut self, type_: Type) -> Result<Dsp, Error>

Source

pub fn create_dsp_sfxreverb( &mut self, properties: &Properties, dry_level: f32, ) -> Result<Dsp, Error>

A convenience method that creates a dsp::Sfxreverb from a given reverb3d::Properties and dry level.

Source

pub fn create_reverb3d(&mut self) -> Result<Reverb3d, Error>

Source

pub fn create_sound_from_file( &mut self, filename: &str, mode: Mode, exinfo: Option<&mut Createsoundexinfo>, ) -> Result<Sound, Error>

Source

pub fn create_sound_from_memory( &mut self, data: &[u8], mode: Mode, exinfo: Option<&mut Createsoundexinfo>, ) -> Result<Sound, Error>

Source

pub fn create_sound_from_pcm( &mut self, pcm: &[i16], mode: Mode, exinfo: Option<&mut Createsoundexinfo>, ) -> Result<Sound, Error>

§Panics

Panics on write failures.

Source

pub fn create_sound_from_file_default( &mut self, filename: &str, ) -> Result<Sound, Error>

Open a sound in DEFAULT mode with no exinfo argument

Examples found in repository?
examples/example.rs (line 21)
12fn main() {
13  println!("fmod example main...");
14
15  let mut system     = System::default().unwrap();
16  hex!(fmod::FMOD_VERSION);
17  hex!(system.get_version().unwrap());
18
19  let sound_filename = "bite.wav";
20  println!("  opening {sound_filename:?}");
21  let mut sound      = system.create_sound_from_file_default (sound_filename)
22    .unwrap();
23  println!("  playing {sound_filename:?}");
24  let channel        = sound.play (None, false).unwrap();
25  while channel.is_playing().unwrap() {
26    std::thread::sleep (std::time::Duration::from_millis (100));
27  }
28  println!("...fmod example main");
29}
Source

pub fn create_sound_from_memory_default( &mut self, data: &[u8], ) -> Result<Sound, Error>

Source

pub fn create_sound_from_pcm_default( &mut self, pcm: &[i16], ) -> Result<Sound, Error>

Source

pub fn set_3d_listener_attributes( &mut self, listener: i32, attributes: &ListenerAttributes, ) -> Result<(), Error>

Source

pub fn set_output(&mut self, output: Outputtype) -> Result<(), Error>

Source

pub fn set_reverb_properties( &mut self, instance: i32, properties: &Properties, ) -> Result<(), Error>

Sets parameters for the global reverb environment.

instance – Index of the particular reverb instance to target, from 0 to fmod::dsp::REVERB_MAXINSTANCES.

When using each instance for the first time, FMOD will create a physical SFX reverb DSP unit that takes up several hundred kilobytes of memory and some CPU.

Trait Implementations§

Source§

impl Clone for System

Source§

fn clone(&self) -> System

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for System

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for System

Source§

fn eq(&self, other: &System) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for System

Auto Trait Implementations§

§

impl Freeze for System

§

impl RefUnwindSafe for System

§

impl !Send for System

§

impl !Sync for System

§

impl Unpin for System

§

impl UnwindSafe for System

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.