pub struct VolumeControl { /* private fields */ }Expand description
Handle to the DAC’s hardware volume control.
Cheap to clone. Calls serialize with each other and with the library’s own volume I/O. Writes are verified by reading the level back; a failed multi-channel write restores the channels already written.
Implementations§
Source§impl VolumeControl
impl VolumeControl
Sourcepub fn range(&self) -> Result<VolumeRange>
pub fn range(&self) -> Result<VolumeRange>
The writable range, or Error::Control if the control disappeared
(for example the active stream moved to another terminal).
Sourcepub fn get(&self) -> Result<VolumeState>
pub fn get(&self) -> Result<VolumeState>
Reads the live level from the device.
Sourcepub fn set_db(&self, db: f64) -> Result<VolumeState>
pub fn set_db(&self, db: f64) -> Result<VolumeState>
Sets the level in dB. The value is clamped to the range and snapped to the nearest step the DAC supports (a tie goes to the quieter one). Returns the level read back.
Sourcepub fn set_fraction(&self, fraction: f64) -> Result<VolumeState>
pub fn set_fraction(&self, fraction: f64) -> Result<VolumeState>
Sets the level on the 0..1 curve (see VolumeState::fraction). The
exact inverse of the read-back mapping: feeding a read-back fraction
back in reproduces the same step.
Sourcepub fn step(&self, direction: i8, steps: u8) -> Result<VolumeState>
pub fn step(&self, direction: i8, steps: u8) -> Result<VolumeState>
Moves the level up (direction > 0) or down (direction < 0) by
1/steps of the 0..1 curve, always by at least one DAC step.
steps == 0 selects DEFAULT_VOLUME_STEPS. A direction of 0 only
reads the level.
Sourcepub fn set_mute(&self, muted: bool) -> Result<VolumeState>
pub fn set_mute(&self, muted: bool) -> Result<VolumeState>
Sets the master mute. Error::Control if the DAC has no writable
mute or the readback disagrees.
Sourcepub fn startup(&self) -> StartupVolumeReport
pub fn startup(&self) -> StartupVolumeReport
What the library did with the DAC’s level when it was opened, before any
stream could start: the level each channel had, the level it has now and
the limit a host should not restore above. See StartupVolumeReport.
On connect a host reads this, then restores the level it remembers for
this DAC capped by limit_db, or leaves the attenuated level.
Sourcepub fn original_db(&self) -> Option<f64>
pub fn original_db(&self) -> Option<f64>
The level the DAC had before the library first wrote to it, in dB, if it was recorded (all channels agreed).