Expand description
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:
f64
,(
Letter
,
Octave
)
, andPitch
for constant valuesShared
<A:
Automation
>
for values that can be changed by other codeSource
<Frame = f64>
for values that change over time
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 Source
s 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:
Re-exports
pub use gen::*;
Modules
- Re-export of the
cpal
crate - Wave generation
- Audio sources
- Read and write wave files
Structs
- An attack-decay-sustain evenlope
- Source returned from
Source::buffer
- A source that returns a constant value
- A builder for creating
InputDeviceSource
s andOutputDeviceMixer
s - An
UnrolledSource
that receives audio samples from the system audio input - Used to coordinate the dropping of
Source
s - Mixes audio sources and outputs them to a device
- A letter-octave pair representing a frequency
- A thread-safe, reference-counted, locked wrapper
- Stereo
Frame
type
Enums
- A error encountered when trying to build audio I/O sources
- The twelve notes of the western chromatic scale.
- Musical modes
Traits
- Trait for automating source control value
- A single multi-channel frame in an audio source
- An audio source with a static frame size
- A trait for converting to a
Duration
- An audio source with a dynamic frame size
Functions
- Create an audio input source using the default input device
- Get the default input device
- Create an audio output mixer using the default output device and start it playing immediately
- Create an audio input source using the default output device
- Get the default output device
- Linearly interpolate two numbers
- Convert a
Frame
to mono - Convert a mono
Frame
to stereo
Type Definitions
- A result type for trying to build audio I/O sources
- Mono
Frame
type - Type alias for an octave