Struct SoundBuilder

Source
pub struct SoundBuilder<'a> { /* private fields */ }
Expand description

A builder for creating a Sound.

Implementations§

Source§

impl<'a> SoundBuilder<'a>

Source

pub const fn open(filename: &'a Utf8CStr) -> Self

Open a file or url.

Source

pub const fn open_user( length: c_uint, channel_count: c_int, default_frequency: c_int, format: SoundFormat, ) -> Self

Open a user-created static sample or stream.

Source

pub const unsafe fn open_memory(data: &'a [u8]) -> Self

Open the sound using a byte slice.

§Safety

The slice must remain valid until the sound has been loaded. See the Mode docs for more information.

Source

pub const unsafe fn open_memory_point(data: &'a [u8]) -> Self

Open the sound using a byte slice.

§Safety

The slice must remain valid until the sound has been released. Unlike Self::open_memory this function does not copy the data, so it is even more unsafe!

Source

pub const fn with_filesystem<F: FileSystemSync + FileSystemAsync>( self, userdata: *mut c_void, ) -> Self

Specify a custom filesystem to open the Sound.

Source

pub const fn with_filesystem_sync<F: FileSystemSync>( self, userdata: *mut c_void, ) -> Self

Specify a custom sync filesystem to open the Sound.

Source

pub const fn with_filesystem_async<F: FileSystemAsync>( self, userdata: *mut c_void, ) -> Self

Specify a custom async filesystem to open the Sound.

Source

pub const unsafe fn with_raw_ex_info( self, ex_info: FMOD_CREATESOUNDEXINFO, ) -> Self

§Safety

The FMOD_CREATESOUNDEXINFO must be valid.

Source

pub const fn with_file_offset(self, file_offset: c_uint) -> Self

File offset to start reading from.

Source

pub const fn with_open_raw( self, channel_count: c_int, default_frequency: c_int, format: SoundFormat, ) -> Self

Ignore the file format and treat as raw PCM.

Source

pub const fn with_mode(self, mode: Mode) -> Self

Set the Mode flags for this builder.

Mode::OPEN_MEMORY, Mode::OPEN_MEMORY_POINT, Mode::OPEN_USER, and Mode::OPEN_RAW cannot be set using this function.

Please use constructors on this type to use those modes.

Source

pub const fn with_decode_buffer_size(self, size: c_uint) -> Self

Size of the decoded buffer for Mode::CREATE_STREAM, or the block size used with pcmreadcallback for SoundBuilder::open_user.

Source

pub const fn with_initial_subsound(self, initial_subsound: c_int) -> Self

Initial subsound to seek to for Mode::CREATE_STREAM.

Source

pub const fn with_subsound_count(self, count: c_int) -> Self

Number of subsounds available for SoundBuilder::open_user, or maximum subsounds to load from file.

Source

pub const fn with_inclusion_list(self, list: &'a [c_int]) -> Self

List of subsound indices to load from file.

Source

pub const fn with_dls_name(self, dls_name: &'a Utf8CStr) -> Self

File path for a SoundType::DLS sample set to use when loading a SoundType::MIDI file, see below for defaults.

Source

pub const fn with_encryption_key(self, key: &'a Utf8CStr) -> Self

Key for encrypted SoundType::FSB file, cannot be used in conjunction with Self::open_memory_point.

Source

pub fn with_max_polyphony(self, max_polyphony: c_int) -> Self

Maximum voice count for SoundType::MIDI / SoundType::IT.

Source

pub const fn with_suggested_sound_type(self, sound_type: SoundType) -> Self

Attempt to load using the specified type first instead of loading in codec priority order.

Source

pub const fn with_file_buffer_size(self, size: c_int) -> Self

Buffer size for reading the file, -1 to disable buffering.

Source

pub const fn with_channel_order(self, order: ChannelOrder) -> Self

Custom ordering of speakers for this sound data.

Source

pub fn with_initial_sound_group(self, group: SoundGroup) -> Self

SoundGroup to place the created Sound in once created.

Source

pub const fn with_initial_seek_position( self, position: c_uint, unit: TimeUnit, ) -> Self

Initial position to seek to for Mode::CREATE_STREAM.

Source

pub const fn with_ignore_set_filesystem(self, ignore: bool) -> Self

Ignore System::set_filesystem_sync and this SoundBuilder’s file callbacks.

Source

pub const fn with_audioqueue_policy(self, policy: c_uint) -> Self

Hardware / software decoding policy for SoundType::AudioQueue.

Source

pub const fn with_min_midi_granularity(self, granularity: c_uint) -> Self

Mixer granularity for SoundType::MIDI sounds, smaller numbers give a more accurate reproduction at the cost of higher CPU usage.

Source

pub const fn with_non_block_thread_id(self, id: c_int) -> Self

Thread index to execute Mode::NONBLOCKING loads on for parallel Sound loading.

Source

pub const fn with_fsb_guid(self, guid: &'a Guid) -> Self

On input, GUID of already loaded SoundType::FSB file to reduce disk access, on output, GUID of loaded FSB.

Source

pub const fn with_pcm_callback<C: PcmCallback>(self) -> Self

Specify a PCM callback.

Source

pub const fn with_nonblock_callback<C: NonBlockCallback>(self) -> Self

Callback to notify completion for Mode::NONBLOCKING, occurs during creation and seeking / restarting streams.

Source

pub fn build(&self, system: System) -> Result<Sound>

Helper method that forwards to System::create_sound.

Source

pub fn build_stream(&self, system: System) -> Result<Sound>

Helper method that forwards to System::create_stream.

Source§

impl<'a> SoundBuilder<'a>

Source

pub const fn mode(&self) -> Mode

Get the mode of this SoundBuilder.

Source

pub const fn raw_ex_info(&self) -> FMOD_CREATESOUNDEXINFO

Get the raw ex info of this SoundBuilder.

Source

pub const fn raw_name_or_data(&self) -> *const c_char

Get the raw name/data/url of this SoundBuilder.

Source

pub fn name_or_url(&self) -> Option<&Utf8CStr>

Get the name or url of this SoundBuilder.

Returns None if Mode::OPEN_MEMORY or Mode::OPEN_MEMORY_POINT or Mode::OPEN_USER are set.

Source

pub fn data(&self) -> Option<&[u8]>

Get the data of this SoundBuilder.

Returns Some if Mode::OPEN_MEMORY or Mode::OPEN_MEMORY_POINT are set.

Source

pub const fn length(&self) -> c_uint

Get the length of data of this SoundBuilder.

Source

pub const fn file_offset(&self) -> c_uint

Get the file offset of this SoundBuilder.

Source

pub const fn channel_count(&self) -> c_int

Get the channel count of this SoundBuilder.

Source

pub const fn default_frequency(&self) -> c_int

Get the default frequency of this SoundBuilder.

Source

pub fn format(&self) -> SoundFormat

Get the sound format of this SoundBuilder.

Source

pub const fn decode_buffer_size(&self) -> c_uint

Get the decode buffer size of this SoundBuilder.

Source

pub const fn initial_subsound(&self) -> c_int

Get the initial subsound of this SoundBuilder.

Source

pub const fn subsound_count(&self) -> c_int

Get the subsound count of this SoundBuilder.

Source

pub fn inclusion_list(&self) -> Option<&'a [c_int]>

Get the inclusion list of this SoundBuilder.

Source

pub fn dls_name(&self) -> Option<&Utf8CStr>

Get the DLS name of this SoundBuilder.

Source

pub fn encryption_key(&self) -> Option<&Utf8CStr>

Get the encryption key of this SoundBuilder.

Source

pub const fn max_polyphony(&self) -> c_int

Get the max polyphony of this SoundBuilder.

Source

pub fn suggested_sound_type(&self) -> SoundType

Get the suggested sound type of this SoundBuilder.

Source

pub const fn file_buffer_size(&self) -> c_int

Get the file buffer size of this SoundBuilder.

Source

pub fn channel_order(&self) -> ChannelOrder

Get the channel order of this SoundBuilder.

Source

pub fn initial_sound_group(&self) -> Option<SoundGroup>

Get the initial sound group of this SoundBuilder.

Source

pub fn initial_seek_position(&self) -> (c_uint, TimeUnit)

Get the initial seek position of this SoundBuilder.

Source

pub const fn ignore_set_filesystem(&self) -> bool

Get the ignore set filesystem flag of this SoundBuilder.

Source

pub const fn min_midi_granularity(&self) -> c_uint

Get the min midi granularity of this SoundBuilder.

Source

pub const fn non_block_thread_id(&self) -> c_int

Get the nonblock thread id of this SoundBuilder.

Source

pub const fn fsb_guid(&self) -> Option<Guid>

Get the FSB guid of this SoundBuilder.

Source§

impl SoundBuilder<'_>

Source

pub unsafe fn from_ffi( name_or_data: *const c_char, mode: FMOD_MODE, create_sound_ex_info: FMOD_CREATESOUNDEXINFO, ) -> Self

§Safety

The mode must match the required fields of the FMOD_CREATESOUNDEXINFO struct. The FMOD_CREATESOUNDEXINFO struct’s cbsize field must be set to the size of the struct.

If the mode is not Mode::OPEN_MEMORY or Mode::OPEN_MEMORY_POINT name_or_data pointer must be valid for reads of bytes up to and including the nul terminator.

If the mode is Mode::OPEN_MEMORY or Mode::OPEN_MEMORY_POINT the data pointer must be valid for reads of bytes up to FMOD_CREATESOUNDEXINFO::length.

The lifetime of the builder is unbounded and MUST be constrained!

Trait Implementations§

Source§

impl<'a> Debug for SoundBuilder<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for SoundBuilder<'a>

§

impl<'a> RefUnwindSafe for SoundBuilder<'a>

§

impl<'a> !Send for SoundBuilder<'a>

§

impl<'a> !Sync for SoundBuilder<'a>

§

impl<'a> Unpin for SoundBuilder<'a>

§

impl<'a> UnwindSafe for SoundBuilder<'a>

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> 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, 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.