Crate fon

Source
Expand description

Rust audio types and conversions.

An audio buffer can be cheaply converted to and from raw samples (i16, u8, f32, and f64) buffers, enabling interoperability with other crates.

Many audio formats are supported:

§Getting Started

To understand some of the concepts used in this library, this MDN article is a good read (although the stuff about compression isn’t relevant to this crate’s functionality). This crate uses the MDN definitions for what an audio frame and audio channel are.

§8-Bit Sawtooth Wave Example

use fon::chan::{Ch16, Ch32};
use fon::pos::Mono;
use fon::Audio;

let mut a = Audio::<Ch32, 1>::with_silence(48_000, 256);
let mut counter = 0.0;
for f in a.iter_mut() {
    f[Mono] = counter.into();
    counter += 0.05;
    counter %= 1.0;
}

let mut audio = Audio::<Ch16, 1>::with_audio(48_000, &a);

Modules§

  • Audio channels (left, right, etc.). Each channel contains a single sample.
  • Speaker/channel positions within a speaker configuration.

Structs§

Traits§

  • Audio sink - a type that consumes audio samples.