[][src]Struct miniaudio::ChannelConverter

#[repr(transparent)]pub struct ChannelConverter(_);

channel conversion is used for channel rearrangement and conversion from one channel count to another. The ChannelConverter API is used for channel conversion.

In addition to converting from one channel count to another the channel converter can also be used to rearrange channels. When initializing the channel converter, you can optionally pass in channel maps for both the input and output frames. If the channel counts are the same, each channel map contains teh same channel positions with the exception that they're in a different order, a simple shuffling of the channels will be performed. If, however, there is not a 1:1 mapping of channel positions, or the channel counts differ, the input channels will be mixed based on a mixing mode which is specified when initializing the ChannelConverterConfig object.

When converting from mono to multi-channel, the mono channel is simply copied to each output channel. When going the other way around, the audio of each output channel is simply averaged and copied to the mono channel.

In more complicated cases blending is used. ChannelMixMode::Simple mode will drop excess channels and silence extra channels. For example, convertion from 4 to 2 channels, the 3rd and 4th channels will be dropped, whereas converting from 2 to 4 channels will put silence into the 3rd and 4th channels.

ChannelModeMode::Rectangle mode uses spacial locality based on a rectangle to compute a simple distribution between input and output. Imaging sitting in the middle of a root, with speakers on the walls representing channel positions. Channel::FrontLeft position can be thought of as being in the corder of the front and left walls.

Finally, ChannelMixMode::CustomWeights mode can be used to use custom user-defined weights.

Implementations

impl ChannelConverter[src]

pub fn new(config: &ChannelConverterConfig) -> Result<ChannelConverter, Error>[src]

pub fn format(&self) -> Format[src]

pub fn channels_in(&self) -> u32[src]

pub fn channels_out(&self) -> u32[src]

pub fn channel_map_in(&self) -> &[Channel][src]

pub fn channel_map_out(&self) -> &[Channel][src]

pub fn mixing_mode(&self) -> ChannelMixMode[src]

pub fn is_passthrough(&self) -> bool[src]

pub fn is_simple_shuffle(&self) -> bool[src]

pub fn is_simple_mono_expansion(&self) -> bool[src]

pub fn is_stereo_to_mono(&self) -> bool[src]

pub fn shuffle_table(&self) -> &[u8; 32][src]

pub fn process_pcm_frames(
    &mut self,
    output: &mut FramesMut,
    input: &Frames
) -> Result<(), Error>
[src]

Trait Implementations

impl Clone for ChannelConverter[src]

impl Drop for ChannelConverter[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.