pub struct Player<S: Sample> { /* private fields */ }Expand description
Audio player that plays a DSP graph through a configurable backend.
Player wraps a DSP Graph and handles the conversion to an
audio stream that can be played through the system’s audio output.
§Examples
Using the default rodio backend (requires rodio feature):
ⓘ
use bbx_player::Player;
let player = Player::new(graph)?;
let handle = player.play()?;
std::thread::sleep(Duration::from_secs(5));
handle.stop();Using a custom backend:
ⓘ
use bbx_player::{Player, backends::CpalBackend};
let backend = CpalBackend::try_default()?;
let player = Player::with_backend(graph, backend);
let handle = player.play()?;Implementations§
Source§impl<S: Sample> Player<S>
impl<S: Sample> Player<S>
Sourcepub fn with_backend<B: Backend>(graph: Graph<S>, backend: B) -> Self
pub fn with_backend<B: Backend>(graph: Graph<S>, backend: B) -> Self
Create a new player with a custom backend.
Sourcepub fn play(self) -> Result<PlayHandle>
pub fn play(self) -> Result<PlayHandle>
Start non-blocking playback.
Returns a PlayHandle that can be used to stop playback.
The player is consumed by this method.
Auto Trait Implementations§
impl<S> Freeze for Player<S>
impl<S> !RefUnwindSafe for Player<S>
impl<S> Send for Player<S>
impl<S> !Sync for Player<S>
impl<S> Unpin for Player<S>where
S: Unpin,
impl<S> !UnwindSafe for Player<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more