pub struct SineWaveSource {
format: AudioFormat,
frequency: f32,
amplitude: f32,
next_frame: u64,
}Expand description
Sine-wave source. Emits amplitude · sin(2π · frequency · t) on
every channel.
Fields§
§format: AudioFormat§frequency: f32Hz.
amplitude: f320..=1 (clipped at f32 bounds when written).
next_frame: u64Frames emitted so far.
Implementations§
Source§impl SineWaveSource
impl SineWaveSource
Sourcepub fn new(format: AudioFormat, frequency_hz: f32, amplitude: f32) -> Self
pub fn new(format: AudioFormat, frequency_hz: f32, amplitude: f32) -> Self
Construct a sine source at the given format / frequency /
amplitude. amplitude is clamped to [0, 1].
Sourcepub fn format(&self) -> AudioFormat
pub fn format(&self) -> AudioFormat
Format of the emitted chunks.
Sourcepub fn frames_emitted(&self) -> u64
pub fn frames_emitted(&self) -> u64
Cumulative number of frames emitted across next_chunk calls.
Sourcepub fn next_chunk(&mut self, frames: u64) -> AudioChunk
pub fn next_chunk(&mut self, frames: u64) -> AudioChunk
Emit the next frames of audio. Always returns a chunk of
exactly frames × channels samples (or fewer if the requested
count is zero).
Trait Implementations§
Source§impl Clone for SineWaveSource
impl Clone for SineWaveSource
Source§fn clone(&self) -> SineWaveSource
fn clone(&self) -> SineWaveSource
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SineWaveSource
impl RefUnwindSafe for SineWaveSource
impl Send for SineWaveSource
impl Sync for SineWaveSource
impl Unpin for SineWaveSource
impl UnsafeUnpin for SineWaveSource
impl UnwindSafe for SineWaveSource
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