Crate dynwave

source ·
Expand description

Dynamic audio player based on fixed samples stream

This crate provides a dynamic audio player that can play audio samples stream coming from an external generating source, such as an emulator.

The AudioPlayer acts as an audio stream player that will play the samples as they come. And will resample the audio if the generated sample rate is not supported by the audio device,

§Supported sample types

For now, we rely on rubato crate for resampling, it has the trait Sample that is implemented for:

§Example

Here’s an example of how to use the AudioPlayer:

// create a buffer, that can hold 1 second worth of samples
// (base it depend on how fast you generate samples, less buffer is better for latency)
let mut player = AudioPlayer::<f32>::new(44100, BufferSize::OneSecond).unwrap();

// Start playing the audio
player.play().unwrap();

// generate audio samples (can be done in a emulation loop for example)
let samples = generate_samples();
player.queue(&samples);

// pause the audio
player.pause().unwrap();

Modules§

  • Error types for the audio player.

Structs§

  • The AudioPlayer struct represents an audio player that can play audio samples stream coming from an external generating source, such as an emulator.

Enums§

  • The BufferSize enum represents the amount of audio samples that can be stored in the buffer. Limiting the number of samples in the buffer is crucial for minimizing audio delay in audio playing.