Audio Loader#
-
struct AudioPCM#
PCM container.
Always mono, float32 in [-1, 1]; the decoder mixes multi-channel input down.
sampleRateis the rate the samples are at: the decoder resamples to the rate it was asked for,audioUtils::wrapPcmrecords the rate the caller states.samplesstays readable for as long as this container holds it: a decoder attaches storage it allocated,wrapPcmattaches memory the caller keeps valid for the request.Public Functions
-
int64_t numSamples() const noexcept#
Sample count in the single channel; zero when no samples are attached.
-
int64_t numSamples() const noexcept#
- bool trt_edgellm::rt::audio::loadAudioBytes(
- uint8_t const *bytes,
- size_t size,
- int32_t targetSampleRate,
- AudioPCM &out
Load raw audio bytes (wav / mp3 / flac) into mono float32 PCM resampled to
targetSampleRate. Internally decodes the container via vendored miniaudio (auto-detects format from magic bytes) and mixes multi-channel to mono.http(s)://URLs are not handled here — bytes are expected to be a complete container blob already.- Parameters:
bytes – Pointer to the encoded audio bytes.
size – Length of
bytesin bytes.targetSampleRate – Output sample rate (e.g. 16000 for Whisper).
out – Populated on success; on failure
outis left in an unspecified state (do not consume its contents).
- Returns:
true on success, false on decode failure.
- bool trt_edgellm::rt::audio::loadAudioFile(
- std::filesystem::path const &path,
- int32_t targetSampleRate,
- AudioPCM &out
Load a local audio file (wav / mp3 / flac) into mono float32 PCM resampled to
targetSampleRate.Used by the CLI / offline path. The HTTP server uses loadAudioBytes.
- Parameters:
path – Local filesystem path.
targetSampleRate – Output sample rate.
out – Populated on success; on failure
outis left in an unspecified state (do not consume its contents).
- Returns:
true on success, false on open/decode failure.