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:
- hardware output channels or “speakermode channels” – the number of
speakermode channels is returned in the
DriverInfo
structure by thesystem.get_driver_info()
method - software channels – “mixable voices”; unless specified, the FMOD default number of software channels is 64
- 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
impl System
Sourcepub fn default() -> Result<Self, Error>
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?
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}
Sourcepub fn new(
num_software_channels: Option<u16>,
num_virtual_channels: u16,
initflags: Initflags,
) -> Result<Self, Error>
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.
pub fn update(&mut self) -> Result<(), Error>
pub fn get_3d_listener_attributes( &self, listener: i32, ) -> Result<ListenerAttributes, Error>
pub fn get_3d_num_listeners(&self) -> Result<i32, Error>
Sourcepub fn get_3d_settings(&self) -> Result<(f32, f32, f32), Error>
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
pub fn get_channels_playing(&self) -> Result<(i32, i32), Error>
pub fn get_cpu_usage(&self) -> Result<CpuUsage, Error>
Sourcepub fn get_driver(&self) -> Result<i32, Error>
pub fn get_driver(&self) -> Result<i32, Error>
Returns the currently selected driver number
pub fn get_driver_info(&self, id: i32) -> Result<DriverInfo, Error>
Sourcepub fn get_dsp_buffer_size(&self) -> Result<(u32, i32), Error>
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.
Sourcepub fn get_geometry_occlusion(
&self,
listener: [f32; 3],
source: [f32; 3],
) -> Result<(f32, f32), Error>
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)
.
Sourcepub fn get_geometry_settings(&self) -> Result<f32, Error>
pub fn get_geometry_settings(&self) -> Result<f32, Error>
Retrieves the maximum world size for the geometry engine
pub fn get_master_channel_group(&self) -> Result<ChannelGroupRef, Error>
pub fn get_num_drivers(&self) -> Result<i32, Error>
pub fn get_num_plugins(&self, plugintype: Plugintype) -> Result<i32, Error>
pub fn get_output(&self) -> Result<Outputtype, Error>
Sourcepub fn get_output_by_plugin(&self) -> Result<PluginHandle, Error>
pub fn get_output_by_plugin(&self) -> Result<PluginHandle, Error>
Returns the currently selected output as an id in the list of output plugins
pub fn get_record_driver_info( &self, id: i32, ) -> Result<(DriverInfo, DriverState), Error>
Sourcepub fn get_record_num_drivers(&self) -> Result<(i32, i32), Error>
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
pub fn get_reverb_properties(&self, instance: i32) -> Result<Properties, Error>
pub fn get_software_channels(&self) -> Result<i32, Error>
Sourcepub fn get_software_format(&self) -> Result<(i32, Speakermode, i32), Error>
pub fn get_software_format(&self) -> Result<(i32, Speakermode, i32), Error>
Retrieves the output format for the software mixer:
(samplerate, speakermode, numrawspeakers)
pub fn get_sound_ram(&self) -> Result<SoundRam, Error>
pub fn get_speaker_mode_channels(&self, mode: Speakermode) -> Result<i32, Error>
Sourcepub fn get_speaker_position(
&self,
speaker: Speaker,
) -> Result<(f32, f32, bool), Error>
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)
.
Sourcepub fn get_stream_buffer_size(&self) -> Result<(u32, Timeunit), Error>
pub fn get_stream_buffer_size(&self) -> Result<(u32, Timeunit), Error>
Returns the current internal buffersize settings for streamable sounds
Sourcepub fn get_version(&self) -> Result<u32, Error>
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?
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}
Sourcepub fn get_version_string(&self) -> Result<String, Error>
pub fn get_version_string(&self) -> Result<String, Error>
Version of linked FMOD shared library
pub fn create_channel_group( &mut self, name: Option<&str>, ) -> Result<ChannelGroup, Error>
pub fn create_dsp( &mut self, description: &'static Description, ) -> Result<Dsp, Error>
pub fn create_dsp_by_type(&mut self, type_: Type) -> Result<Dsp, Error>
Sourcepub fn create_dsp_sfxreverb(
&mut self,
properties: &Properties,
dry_level: f32,
) -> Result<Dsp, Error>
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.
pub fn create_reverb3d(&mut self) -> Result<Reverb3d, Error>
pub fn create_sound_from_file( &mut self, filename: &str, mode: Mode, exinfo: Option<&mut Createsoundexinfo>, ) -> Result<Sound, Error>
pub fn create_sound_from_memory( &mut self, data: &[u8], mode: Mode, exinfo: Option<&mut Createsoundexinfo>, ) -> Result<Sound, Error>
Sourcepub fn create_sound_from_pcm(
&mut self,
pcm: &[i16],
mode: Mode,
exinfo: Option<&mut Createsoundexinfo>,
) -> Result<Sound, Error>
pub fn create_sound_from_pcm( &mut self, pcm: &[i16], mode: Mode, exinfo: Option<&mut Createsoundexinfo>, ) -> Result<Sound, Error>
§Panics
Panics on write failures.
Sourcepub fn create_sound_from_file_default(
&mut self,
filename: &str,
) -> Result<Sound, Error>
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?
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}
pub fn create_sound_from_memory_default( &mut self, data: &[u8], ) -> Result<Sound, Error>
pub fn create_sound_from_pcm_default( &mut self, pcm: &[i16], ) -> Result<Sound, Error>
pub fn set_3d_listener_attributes( &mut self, listener: i32, attributes: &ListenerAttributes, ) -> Result<(), Error>
pub fn set_output(&mut self, output: Outputtype) -> Result<(), Error>
Sourcepub fn set_reverb_properties(
&mut self,
instance: i32,
properties: &Properties,
) -> Result<(), Error>
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.