⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

AudioMixer

Struct AudioMixer 

Source
pub struct AudioMixer { /* private fields */ }
Expand description

Multi-channel audio mixer with fixed-point arithmetic

Implementations§

Source§

impl AudioMixer

Source

pub fn new(sample_rate: u32, channels: u8) -> Self

Create a new audio mixer

§Arguments
  • sample_rate - Output sample rate in Hz (e.g., 48000)
  • channels - Number of output channels (1=mono, 2=stereo)
Source

pub fn add_channel(&mut self, name: &str) -> u16

Add a new mixer channel and return its ID

Source

pub fn remove_channel(&mut self, id: u16)

Remove a mixer channel by ID

Source

pub fn set_volume(&self, channel_id: u16, volume: u16)

Set volume for a specific channel (0..65535)

Source

pub fn set_master_volume(&self, volume: u16)

Set the master volume (0..65535)

Source

pub fn get_master_volume(&self) -> u16

Get the master volume (0..65535)

Source

pub fn mix_to_output(&mut self, output: &mut [i16])

Mix all active channels into the provided output buffer

For each sample position, reads from all channels, applies per-channel volume and mute, sums with saturation, then applies master volume. The result is written directly to output.

Source

pub fn channel_count(&self) -> usize

Return the number of active channels

Source

pub fn get_channel_mut(&mut self, id: u16) -> Option<&mut MixerChannel>

Get a mutable reference to a channel by ID

Source

pub fn write_channel_samples(&mut self, channel_id: u16, samples: &[i16])

Write samples to a specific channel

Auto Trait Implementations§

§

impl !Freeze for AudioMixer

§

impl RefUnwindSafe for AudioMixer

§

impl Send for AudioMixer

§

impl Sync for AudioMixer

§

impl Unpin for AudioMixer

§

impl UnwindSafe for AudioMixer

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.