pub struct AudioUnit { /* private fields */ }Expand description
A rust representation of the objc2_audio_toolbox::AudioUnit, including
a pointer to the current rendering callback.
Find the original Audio Unit Programming Guide here.
Implementations§
Source§impl AudioUnit
impl AudioUnit
Sourcepub fn set_render_callback<F, D>(&mut self, f: F) -> Result<(), Error>
pub fn set_render_callback<F, D>(&mut self, f: F) -> Result<(), Error>
Pass a render callback (aka “Input Procedure”) to the AudioUnit.
Sourcepub fn set_input_callback<F, D>(&mut self, f: F) -> Result<(), Error>
pub fn set_input_callback<F, D>(&mut self, f: F) -> Result<(), Error>
Pass an input callback (aka “Input Procedure”) to the AudioUnit.
Sourcepub fn free_render_callback(&mut self) -> Option<Box<InputProcFnWrapper>>
pub fn free_render_callback(&mut self) -> Option<Box<InputProcFnWrapper>>
Retrieves ownership over the render callback and returns it where it can be re-used or safely dropped.
Sourcepub fn free_input_callback(&mut self) -> Option<Box<InputProcFnWrapper>>
pub fn free_input_callback(&mut self) -> Option<Box<InputProcFnWrapper>>
Retrieves ownership over the input callback and returns it where it can be re-used or safely dropped.
Source§impl AudioUnit
impl AudioUnit
Sourcepub fn new<T>(ty: T) -> Result<AudioUnit, Error>
pub fn new<T>(ty: T) -> Result<AudioUnit, Error>
Construct a new AudioUnit with any type that may be automatically converted into Type.
Here is a list of compatible types:
To construct the AudioUnit with some component flags, see AudioUnit::new_with_flags.
Note: the AudioUnit is constructed with the kAudioUnitManufacturer_Apple Manufacturer
Identifier, as this is the only Audio Unit Manufacturer Identifier documented by Apple in
the AudioUnit reference (see here).
Sourcepub fn new_with_flags<T>(
ty: T,
flags: u32,
mask: u32,
) -> Result<AudioUnit, Error>
pub fn new_with_flags<T>( ty: T, flags: u32, mask: u32, ) -> Result<AudioUnit, Error>
The same as AudioUnit::new but with the given component flags and mask.
Sourcepub fn initialize(&mut self) -> Result<(), Error>
pub fn initialize(&mut self) -> Result<(), Error>
On successful initialization, the audio formats for input and output are valid and the audio unit is ready to render. During initialization, an audio unit allocates memory according to the maximum number of audio frames it can produce in response to a single render call.
Usually, the state of an audio unit (such as its I/O formats and memory allocations) cannot be changed while an audio unit is initialized.
Sourcepub fn uninitialize(&mut self) -> Result<(), Error>
pub fn uninitialize(&mut self) -> Result<(), Error>
Before you change an initialize audio unit’s processing characteristics, such as its input or output audio data format or its sample rate, you must first uninitialize it. Calling this function deallocates the audio unit’s resources.
After calling this function, you can reconfigure the audio unit and then call AudioUnitInitialize to reinitialize it.
Sourcepub fn set_property<T>(
&mut self,
id: u32,
scope: Scope,
elem: Element,
maybe_data: Option<&T>,
) -> Result<(), Error>
pub fn set_property<T>( &mut self, id: u32, scope: Scope, elem: Element, maybe_data: Option<&T>, ) -> Result<(), Error>
Sets the value for some property of the AudioUnit.
To clear an audio unit property value, set the data parameter with None::<()>.
Clearing properties only works for those properties that do not have a default value.
For more on “properties” see the reference.
Available in iOS 2.0 and later.
§Parameters
- id: The identifier of the property.
- scope: The audio unit scope for the property.
- elem: The audio unit element for the property.
- maybe_data: The value that you want to apply to the property.
Sourcepub fn get_property<T>(
&self,
id: u32,
scope: Scope,
elem: Element,
) -> Result<T, Error>
pub fn get_property<T>( &self, id: u32, scope: Scope, elem: Element, ) -> Result<T, Error>
Gets the value of an AudioUnit property.
Available in iOS 2.0 and later.
§Parameters
- id: The identifier of the property.
- scope: The audio unit scope for the property.
- elem: The audio unit element for the property.
Sourcepub fn start(&mut self) -> Result<(), Error>
pub fn start(&mut self) -> Result<(), Error>
Starts an I/O AudioUnit, which in turn starts the audio unit processing graph that it is connected to.
Available in OS X v10.0 and later.
Sourcepub fn stop(&mut self) -> Result<(), Error>
pub fn stop(&mut self) -> Result<(), Error>
Stops an I/O AudioUnit, which in turn stops the audio unit processing graph that it is connected to.
Available in OS X v10.0 and later.
Sourcepub fn set_sample_rate(&mut self, sample_rate: f64) -> Result<(), Error>
pub fn set_sample_rate(&mut self, sample_rate: f64) -> Result<(), Error>
Set the AudioUnit’s sample rate.
Available in iOS 2.0 and later.
Sourcepub fn sample_rate(&self) -> Result<f64, Error>
pub fn sample_rate(&self) -> Result<f64, Error>
Get the AudioUnit’s sample rate.
Sourcepub fn set_stream_format(
&mut self,
stream_format: StreamFormat,
scope: Scope,
element: Element,
) -> Result<(), Error>
pub fn set_stream_format( &mut self, stream_format: StreamFormat, scope: Scope, element: Element, ) -> Result<(), Error>
Sets the current StreamFormat for the AudioUnit.
Core Audio uses slightly different defaults depending on the platform.
From the Core Audio Overview:
The canonical formats in Core Audio are as follows:
- iOS input and output: Linear PCM with 16-bit integer samples.
- iOS audio units and other audio processing: Noninterleaved linear PCM with 8.24-bit fixed-point samples
- Mac input and output: Linear PCM with 32-bit floating point samples.
- Mac audio units and other audio processing: Noninterleaved linear PCM with 32-bit floating-point
Sourcepub fn stream_format(
&self,
scope: Scope,
element: Element,
) -> Result<StreamFormat, Error>
pub fn stream_format( &self, scope: Scope, element: Element, ) -> Result<StreamFormat, Error>
Return the current Stream Format for the AudioUnit.
Sourcepub fn output_stream_format(&self) -> Result<StreamFormat, Error>
pub fn output_stream_format(&self) -> Result<StreamFormat, Error>
Return the current output Stream Format for the AudioUnit.
Sourcepub fn input_stream_format(&self) -> Result<StreamFormat, Error>
pub fn input_stream_format(&self) -> Result<StreamFormat, Error>
Return the current input Stream Format for the AudioUnit.