Module input

Source
Expand description

Raw audio input data streams and sources.

Inputs in Songbird are based on symphonia, which provides demuxing, decoding and management of synchronous byte sources (i.e., any items which impl Read).

Songbird adds support for the Opus codec to symphonia via OpusDecoder, the DCA1 file format via DcaReader, and a simple PCM adapter via RawReader; the format and codec registries in codecs install these on top of those enabled in your Cargo.toml when you include symphonia.

§Common sources

  • Any owned byte slice: &'static [u8], Bytes, or Vec<u8>,
  • File offers a lazy way to open local audio files,
  • HttpRequest streams a given file from a URL using the reqwest HTTP library,
  • YoutubeDl uses yt-dlp (or any other youtube-dl-like program) to scrape a target URL for a usable audio stream, before opening an HttpRequest.

§Adapters

Songbird includes several adapters to make developing your own inputs easier:

  • cached::*, which allow seeking and shared caching of an input stream (storing it in memory in a variety of formats),
  • ChildContainer for managing audio given by a process chain,
  • RawAdapter, for feeding in a synchronous f32-PCM stream, and
  • AsyncAdapterStream, for passing bytes from an AsyncRead (+ AsyncSeek) stream into the mixer.

§Opus frame passthrough.

Some sources, such as Compressed or any WebM/Opus/DCA file, support direct frame passthrough to the driver. This lets you directly send the audio data you have without decoding, re-encoding, or mixing. In many cases, this can greatly reduce the CPU cost required by the driver.

This functionality requires that:

  • only one track is active (including paused tracks),
  • that track’s input supports direct Opus frame reads,
  • this input’s frames are all sized to 20ms.
  • and that track’s volume is set to 1.0.

Inputs which are almost suitable but which have any illegal frames will be blocked from passthrough to prevent glitches such as repeated encoder frame gaps.

Re-exports§

pub use symphonia_core as core;

Modules§

cached
In-memory, shared input sources for reuse between calls, fast seeking, and direct Opus frame passthrough.
codecs
Codec registries extending Symphonia’s probe and registry formats with Opus and DCA support.
utils
Utility methods for seeking or decoding.

Structs§

AsyncAdapterStream
An adapter for converting an async media source into a synchronous one usable by symphonia.
AsyncReadOnlySource
AsyncReadOnlySource wraps any source implementing [tokio::io::AsyncRead] in an unseekable [symphonia_core::io::MediaSource], similar to [symphonia_core::io::ReadOnlySource]
AudioStream
An unread byte stream for an audio file.
AuxMetadata
Extra information about an Input which is acquired without parsing the file itself (e.g., from a webpage).
ChildContainer
Handle for a child process which ensures that any subprocesses are properly closed on drop.
File
A lazily instantiated local file.
HlsRequest
Lazy HLS stream
HttpRequest
A lazily instantiated HTTP request.
Metadata
In-stream information about an Input acquired by parsing an audio file.
Parsed
An audio file which has had its headers parsed and decoder state built.
RawAdapter
Adapter around a raw, interleaved, f32 PCM byte stream.
YoutubeDl
A lazily instantiated call to download a file, finding its URL via youtube-dl.

Enums§

AudioStreamError
Errors encountered when creating an AudioStream or requesting metadata from a Compose.
AuxMetadataError
Errors encountered when trying to access out-of-band AuxMetadata for an Input or Compose.
Input
An audio source, which can be live or lazily initialised.
LiveInput
An initialised audio source.
MakePlayableError
Errors encountered when readying or pre-processing an Input.
MetadataError
Errors encountered when trying to access in-stream Metadata for an Input.

Traits§

AsyncMediaSource
An async port of symphonia’s MediaSource.
Compose
Data and behaviour required to instantiate a lazy audio source.