Crate hodaun

source ·
Expand description

github crates.io docs.rs

This crate provides interfaces for audio synthesis, mixing, input, and output.

Usage

Audio Sources

The Source trait generalizes streamed audio data. The associated type Source::Frame implements the Frame trait, and represents a single sample of audio data for multiple channels.

Source has many utility functions, much like Iterator, for processing and combining audio data.

Automation

Many Source functions take parameters that can be automated, meaning they may change either automatically over time or manually by some other code. The Automation trait is for any value which can be used as an automation parameter.

The primary Automation implementors are:

Mixing

Mixer is a Source that allows simple audio mixing.

Sources can be added to a Mixer with Mixer::add.

Synthesis

The gen module provides a functions for generating audio data.

Wave is a source that generates a wave corresponding to a Waveform.

There are helpful type aliases for common waveforms such as SineWave and SquareWave.

Noise is a source that generates white noise. It requires the noise feature.

Output

OutputDeviceMixer allows the mixing of audio Sources and output to an audio device. An OutputDeviceMixer for the default output device can be created with default_output. For more nuanced control, use DeviceIoBuilder::build_output.

Output functionality is only available when the output feature is enabled.

Input

InputDeviceSource is a Source interface for an audio input device. An InputDeviceSource for the default input device can be created with default_input. For more nuanced control, use DeviceIoBuilder::build_input.

Input functionality is only available when the input feature is enabled.

Audio Files

The wav module provides wav::WavSource for reading WAV files and wav::write_source for writing WAV files.

WAV functionality is only available when the wav feature is enabled.

Musical Notes

A Letter is a note in the western chromatic scale, such as A or C#.

When combined with an Octave, a Letter can be converted to a Pitch.

Pitch supports querying for frequency and number of half-steps. It also implements Automation.

Mode is a musical mode, such as major or minor. It can be used to choose notes from a scale.

Musical note functionality is only available when the notes feature is enabled.

A note on sample types

While this library can handle audio input and output streams that work with various sample types, the library itself works with f64 samples only, converting when necessary.

There are two reasons for this:

  • Floating point is more natural to work with, as we often conceive of amplitude as a non-discrete value.
  • f64 has higher precision than f32, which is important for this library’s audio synthesis algorithms.

Re-exports

  • pub use gen::*;

Modules

Structs

Enums

Traits

Functions

Type Definitions