Expand description
Raw audio input data streams and sources.
Input
s 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
, orVec<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
usesyt-dlp
(or any otheryoutube-dl
-like program) to scrape a target URL for a usable audio stream, before opening anHttpRequest
.
§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 synchronousf32
-PCM stream, andAsyncAdapterStream
, for passing bytes from anAsyncRead
(+ 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
.
Input
s 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§
- Async
Adapter Stream - An adapter for converting an async media source into a synchronous one usable by symphonia.
- Async
Read Only Source AsyncReadOnlySource
wraps any source implementing [tokio::io::AsyncRead
] in an unseekable [symphonia_core::io::MediaSource
], similar to [symphonia_core::io::ReadOnlySource
]- Audio
Stream - 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). - Child
Container - 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
- Http
Request - 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. - Youtube
Dl - A lazily instantiated call to download a file, finding its URL via youtube-dl.
Enums§
- Audio
Stream Error - Errors encountered when creating an
AudioStream
or requesting metadata from aCompose
. - AuxMetadata
Error - Errors encountered when trying to access out-of-band
AuxMetadata
for anInput
orCompose
. - Input
- An audio source, which can be live or lazily initialised.
- Live
Input - An initialised audio source.
- Make
Playable Error - Errors encountered when readying or pre-processing an
Input
. - Metadata
Error - Errors encountered when trying to access in-stream
Metadata
for anInput
.
Traits§
- Async
Media Source - An async port of symphonia’s
MediaSource
. - Compose
- Data and behaviour required to instantiate a lazy audio source.