pub struct AudioContext {
    id: usize,
    client_context_id: ClientContextId,
    backend_chan: Arc<Mutex<Sender<BackendMsg>>>,
    sender: Sender<AudioRenderThreadMsg>,
    state: Cell<ProcessingState>,
    sample_rate: f32,
    dest_node: NodeId,
    listener: NodeId,
    make_decoder: Arc<dyn Fn() -> Box<dyn AudioDecoder> + Sync + Send>,
}
Expand description

Representation of an audio context on the control thread.

Fields§

§id: usize

Media instance ID.

§client_context_id: ClientContextId

Client context ID.

§backend_chan: Arc<Mutex<Sender<BackendMsg>>>

Owner backend communication channel.

§sender: Sender<AudioRenderThreadMsg>

Rendering thread communication channel.

§state: Cell<ProcessingState>

State of the audio context on the control thread.

§sample_rate: f32

Number of samples that will be played in one second.

§dest_node: NodeId

The identifier of an AudioDestinationNode with a single input representing the final destination for all audio.

§listener: NodeId§make_decoder: Arc<dyn Fn() -> Box<dyn AudioDecoder> + Sync + Send>

Implementations§

source§

impl AudioContext

source

pub fn new<B: AudioBackend>( id: usize, client_context_id: &ClientContextId, backend_chan: Arc<Mutex<Sender<BackendMsg>>>, options: AudioContextOptions ) -> Self

Constructs a new audio context.

source

pub fn state(&self) -> ProcessingState

source

pub fn dest_node(&self) -> NodeId

source

pub fn listener(&self) -> NodeId

source

pub fn current_time(&self) -> f64

source

pub fn create_node(&self, node_type: AudioNodeInit, ch: ChannelInfo) -> NodeId

source

pub fn resume(&self) -> StateChangeResult

source

pub fn suspend(&self) -> StateChangeResult

source

pub fn close(&self) -> StateChangeResult

source

pub fn message_node(&self, id: NodeId, msg: AudioNodeMessage)

source

pub fn connect_ports(&self, from: PortId<OutputPort>, to: PortId<InputPort>)

source

pub fn disconnect_all_from(&self, node: NodeId)

source

pub fn disconnect_output(&self, out: PortId<OutputPort>)

source

pub fn disconnect_between(&self, from: NodeId, to: NodeId)

Disconnect connections from a node to another node

https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-destinationnode

source

pub fn disconnect_to(&self, from: NodeId, to: PortId<InputPort>)

Disconnect connections from a node to another node’s input

https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-destinationparam

source

pub fn disconnect_output_between(&self, out: PortId<OutputPort>, to: NodeId)

Disconnect all outgoing connections from a node’s output to another node

https://webaudio.github.io/web-audio-api/#dom-audionode-disconnect-destinationnode-output

source

pub fn disconnect_output_between_to( &self, out: PortId<OutputPort>, inp: PortId<InputPort> )

source

pub fn decode_audio_data(&self, data: Vec<u8>, callbacks: AudioDecoderCallbacks)

Asynchronously decodes the audio file data contained in the given buffer.

source

pub fn set_eos_callback( &self, callback: Box<dyn Fn(Box<dyn AsRef<[f32]>>) + Send + Sync + 'static> )

source

fn set_mute(&self, val: bool)

Trait Implementations§

source§

impl Drop for AudioContext

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl MediaInstance for AudioContext

source§

fn get_id(&self) -> usize

source§

fn mute(&self, val: bool) -> Result<(), ()>

source§

fn suspend(&self) -> Result<(), ()>

source§

fn resume(&self) -> Result<(), ()>

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, 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.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V