#[repr(C)]
pub struct ChannelVolumes { /* private fields */ }
Expand description

A structure encapsulating a per-channel volume

Implementations§

source§

impl ChannelVolumes

source

pub const CHANNELS_MAX: u8 = 32u8

Maximum number of allowed channels.

source

pub fn init(&mut self) -> &Self

Initializes the specified volume and return a pointer to it.

The sample spec will have a defined state but is_valid() will fail for it.

source

pub fn is_valid(&self) -> bool

Checks if the ChannelVolumes structure is valid.

source

pub fn len(&self) -> u8

Gets the number of active channels.

source

pub fn set_len(&mut self, channels: u8)

Sets the number of active channels.

Volumes for up to Self::CHANNELS_MAX channels can be held. This sets the portion of the internal array considered “active” and thus available for reading/writing (i.e. when borrowing self as a slice).

Panics if the number of channels specified is greater than Self::CHANNELS_MAX.

source

pub fn get(&self) -> &[Volume]

Gets an immutable slice of the set of “active” channels.

source

pub fn get_mut(&mut self) -> &mut [Volume]

Gets a mutable slice of the set of “active” channels.

source

pub fn set(&mut self, channels: u8, v: Volume) -> &Self

Sets the volume of the specified number of channels to the supplied volume.

source

pub fn reset(&mut self, channels: u8) -> &Self

Sets the volume of the first n channels to Volume::NORMAL.

source

pub fn mute(&mut self, channels: u8) -> &Self

Sets the volume of the first n channels to Volume::MUTED.

source

pub fn is_muted(&self) -> bool

Checks if all channels are muted.

source

pub fn is_norm(&self) -> bool

Checks if all channels are at normal volume level.

source

pub fn avg(&self) -> Volume

Gets the average volume of all channels.

source

pub fn avg_mask(&self, cm: &Map, mask: Option<PositionMask>) -> Volume

Returns the average volume of all channels that are included in the specified channel map with the specified channel position mask.

If no channel is selected the returned value will be Volume::MUTED. If mask is None, has the same effect as passing POSITION_MASK_ALL.

source

pub fn max(&self) -> Volume

Gets the maximum volume of all channels.

source

pub fn max_mask(&self, cm: &Map, mask: Option<PositionMask>) -> Volume

Gets the maximum volume of all channels that are included in the specified channel map with the specified channel position mask.

If no channel is selected the returned value will be Volume::MUTED. If mask is None, has the same effect as passing POSITION_MASK_ALL.

source

pub fn min(&self) -> Volume

Gets the minimum volume of all channels.

source

pub fn min_mask(&self, cm: &Map, mask: Option<PositionMask>) -> Volume

Gets the minimum volume of all channels that are included in the specified channel map with the specified channel position mask.

If no channel is selected the returned value will be Volume::MUTED. If mask is None, has the same effect as passing POSITION_MASK_ALL.

source

pub fn sw_multiply(&mut self, with: Option<&Self>) -> &mut Self

Multiplies two per-channel volumes.

If with is None, multiplies with itself. This is only valid for software volumes! Returns pointer to self.

source

pub fn sw_multiply_scalar(&mut self, with: Volume) -> &mut Self

Multiplies a per-channel volume with a scalar volume.

This is only valid for software volumes! Returns pointer to self.

source

pub fn sw_divide(&mut self, with: Option<&Self>) -> &mut Self

Divides two per-channel volumes.

If with is None, divides with itself. This is only valid for software volumes! Returns pointer to self.

source

pub fn sw_divide_scalar(&mut self, with: Volume) -> &mut Self

Divides a per-channel volume by a scalar volume.

This is only valid for software volumes! Returns pointer to self.

source

pub fn remap(&mut self, from: &Map, to: &Map) -> &mut Self

Remaps a volume from one channel mapping to a different channel mapping.

Returns pointer to self.

source

pub fn is_compatible_with_ss(&self, ss: &Spec) -> bool

Checks if the specified volume is compatible with the specified sample spec.

source

pub fn is_compatible_with_cm(&self, cm: &Map) -> bool

Checks if the specified volume is compatible with the specified channel map.

source

pub fn get_balance(&self, map: &Map) -> f32

Calculates a ‘balance’ value for the specified volume with the specified channel map.

The return value will range from -1.0 (left) to +1.0 (right). If no balance value is applicable to this channel map the return value will always be 0.0. See Map::can_balance().

source

pub fn set_balance(&mut self, map: &Map, new_balance: f32) -> Option<&mut Self>

Adjusts the ‘balance’ value for the specified volume with the specified channel map.

The balance is a value between -1.0 and +1.0. This operation might not be reversible! Also, after this call get_balance() is not guaranteed to actually return the requested balance value (e.g. when the input volume was zero anyway for all channels). If no balance value is applicable to this channel map the volume will not be modified. See Map::can_balance().

Returns pointer to self, or None on error.

source

pub fn get_fade(&self, map: &Map) -> f32

Calculates a ‘fade’ value (i.e. ‘balance’ between front and rear) for the specified volume with the specified channel map.

The return value will range from -1.0f (rear) to +1.0f (left). If no fade value is applicable to this channel map the return value will always be 0.0. See Map::can_fade().

source

pub fn set_fade(&mut self, map: &Map, new_fade: f32) -> Option<&mut Self>

Adjusts the ‘fade’ value (i.e. ‘balance’ between front and rear) for the specified volume with the specified channel map.

The balance is a value between -1.0 and +1.0. This operation might not be reversible! Also, after this call get_fade() is not guaranteed to actually return the requested fade value (e.g. when the input volume was zero anyway for all channels). If no fade value is applicable to this channel map the volume will not be modified. See Map::can_fade().

Returns pointer to self, or None on error.

source

pub fn get_lfe_balance(&self, map: &Map) -> f32

Available on crate feature pa_v8 only.

Calculates a ‘lfe balance’ value for the specified volume with the specified channel map.

The return value will range from -1.0 (no lfe) to +1.0 (only lfe), where 0.0 is balanced. If no value is applicable to this channel map the return value will always be 0.0. See Map::can_lfe_balance().

source

pub fn set_lfe_balance( &mut self, map: &Map, new_balance: f32 ) -> Option<&mut Self>

Available on crate feature pa_v8 only.

Adjusts the ‘LFE balance’ value for the specified volume with the specified channel map.

The balance is a value between -1.0 (no lfe) and +1.0 (only lfe). This operation might not be reversible! Also, after this call get_lfe_balance() is not guaranteed to actually return the requested value (e.g. when the input volume was zero anyway for all channels). If no lfe balance value is applicable to this channel map the volume will not be modified. See Map::can_lfe_balance().

Returns pointer to self, or None on error.

source

pub fn scale(&mut self, max: Volume) -> Option<&mut Self>

Scales so that the maximum volume of all channels equals max.

The proportions between the channel volumes are kept.

Returns pointer to self, or None on error.

source

pub fn scale_mask( &mut self, max: Volume, cm: &mut Map, mask: Option<PositionMask> ) -> Option<&mut Self>

Scales so that the maximum volume of all channels selected via cm/mask equals max.

This also modifies the volume of those channels that are unmasked. The proportions between the channel volumes are kept.

If mask is None, has the same effect as passing POSITION_MASK_ALL.

Returns pointer to self, or None on error.

source

pub fn set_position( &mut self, map: &Map, p: Position, v: Volume ) -> Option<&mut Self>

Sets the passed volume to all channels at the specified channel position.

Returns None if either invalid data was provided, or if there is no channel at the position specified. You can check if a channel map includes a specific position by calling Map::has_position(). On success, returns pointer to self.

source

pub fn get_position(&self, map: &Map, p: Position) -> Volume

Gets the maximum volume of all channels at the specified channel position.

Will return 0 if there is no channel at the position specified. You can check if a channel map includes a specific position by calling Map::has_position().

source

pub fn merge(&mut self, with: &Self) -> Option<&mut Self>

Merges one set of channel volumes with another.

The channel count is set to the minimum between that of self and that of with. Only this number of channels are processed. For each channel processed, volume is set to the greatest of the values from self and from with. I.e if one set has three channels and the other has two, the number of channels will be set to two, and only the first two channels will be compared, with the greatest values of these two channels being stored. The third channel in the one set will be ignored.

Returns pointer to self, or None on error.

source

pub fn inc_clamp(&mut self, inc: Volume, limit: Volume) -> Option<&mut Self>

Increases the volume passed in by inc, but not exceeding limit.

The proportions between the channels are kept.

Returns pointer to self, or None on error.

source

pub fn increase(&mut self, inc: Volume) -> Option<&mut Self>

Increases the volume passed in by inc.

The proportions between the channels are kept.

Returns pointer to self, or None on error.

source

pub fn decrease(&mut self, dec: Volume) -> Option<&mut Self>

Decreases the volume passed in by dec.

The proportions between the channels are kept.

Returns pointer to self, or None on error.

source

pub fn print(&self) -> String

Pretty prints a volume structure.

source

pub fn print_db(&self) -> String

Pretty prints a volume structure but show dB values.

source

pub fn print_verbose(&self, map: Option<&Map>, print_db: bool) -> String

Pretty prints a volume structure in a verbose way.

The volume for each channel is printed in several formats: the raw volume value, percentage, and if print_db is non-zero, also the dB value. If map is provided, the channel names will be printed.

Trait Implementations§

source§

impl AsMut<pa_cvolume> for ChannelVolumes

source§

fn as_mut(&mut self) -> &mut pa_cvolume

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<pa_cvolume> for ChannelVolumes

source§

fn as_ref(&self) -> &pa_cvolume

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<[Volume]> for ChannelVolumes

source§

fn borrow(&self) -> &[Volume]

Immutably borrows from an owned value. Read more
source§

impl BorrowMut<[Volume]> for ChannelVolumes

source§

fn borrow_mut(&mut self) -> &mut [Volume]

Mutably borrows from an owned value. Read more
source§

impl Clone for ChannelVolumes

source§

fn clone(&self) -> ChannelVolumes

Returns a copy 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 ChannelVolumes

source§

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

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

impl Default for ChannelVolumes

source§

fn default() -> ChannelVolumes

Returns the “default value” for a type. Read more
source§

impl Display for ChannelVolumes

source§

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

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

impl From<pa_cvolume> for ChannelVolumes

source§

fn from(cv: pa_cvolume) -> Self

Converts to this type from the input type.
source§

impl PartialEq<ChannelVolumes> for ChannelVolumes

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<Volume> for ChannelVolumes

source§

fn eq(&self, v: &Volume) -> bool

Returns true if the volume of all channels are equal to the specified value.

1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for ChannelVolumes

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.