encode

Function encode 

Source
pub fn encode<M: CMath>(
    sample_stream: &[f32],
    sample_rate: f64,
    target_bit_rate: f64,
) -> EncodeResult
Expand description

Encodes a raw sample stream into a newly-allocated vector.

Like Decode, this function expects CosF and SinF to be defined by the user in the Pulsejet::Shims namespace before including the relevant pulsejet header(s). See the documentation for Decode for more information.

§Inputs

  • sample_stream - Input sample stream.
  • sample_rate - Input sample rate in samples per second (hz). pulsejet is designed for 44100hz samples only, and its psychoacoustics are tuned to that rate. However, other rates may do something useful/interesting, so this rate is not enforced, and the encoder will happily try to match a target bit rate at another sample rate if desired.
  • target_bit_rate - Target bit rate in kilobits per second (kbps). There’s no enforced lower/upper bound, but due to codec format details, the resulting bit rate will often plateau around 128kbps (or lower, depending on the material). ~64kbps is typically transparent, ~32-64kbps is typically high quality. For anything lower, it depends on the material, but it’s not uncommon for rates <=16kbps to actually be useful. <=0kbps will usually end up around 2-3kbps.