pub struct Encoder { /* private fields */ }Expand description
A safe wrapper around the glint MP3 encoder.
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn new(
sample_rate: u32,
channels: u32,
bitrate: u32,
) -> Result<Self, &'static str>
pub fn new( sample_rate: u32, channels: u32, bitrate: u32, ) -> Result<Self, &'static str>
Create a new MP3 encoder.
Returns an error if the configuration is invalid (e.g. unsupported sample rate or bitrate).
Sourcepub fn with_options(
sample_rate: u32,
channels: u32,
bitrate: u32,
mode: u32,
quality: u32,
path: u32,
vbr_quality: Option<u32>,
) -> Result<Self, &'static str>
pub fn with_options( sample_rate: u32, channels: u32, bitrate: u32, mode: u32, quality: u32, path: u32, vbr_quality: Option<u32>, ) -> Result<Self, &'static str>
Create an MP3 encoder with explicit knobs. mode: 0 mono, 1 dual,
2 joint, 3 stereo. quality: 0 speed / 1 normal / 2 best. path:
0 default, 1 double, 2 fixed. vbr_quality Some(0..9) selects VBR.
Sourcepub fn samples_per_frame(&self) -> usize
pub fn samples_per_frame(&self) -> usize
Number of samples per channel expected by each call to encode.
Sourcepub fn encode(&mut self, pcm: &[i16]) -> Vec<u8> ⓘ
pub fn encode(&mut self, pcm: &[i16]) -> Vec<u8> ⓘ
Encode one frame of interleaved 16-bit PCM audio.
pcm should contain samples_per_frame * channels samples in
interleaved order. If fewer samples are provided, the remainder
is zero-padded.
Trait Implementations§
Auto Trait Implementations§
impl !Sync for Encoder
impl Freeze for Encoder
impl RefUnwindSafe for Encoder
impl Unpin for Encoder
impl UnsafeUnpin for Encoder
impl UnwindSafe for Encoder
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