clip_asset.h
| File Path | engine/include/conjure/audio/clip_asset.h |
| API ↗ | Clips and decoding |
The conjure.audio.clip cooked blob, import settings, importer and loader. The pure functions cook_clip and load_clip_blob hold the whole import and load logic; audio_clip_importer and audio_clip_loader are the thin assets-module adapters over them. The loader needs no audio_engine: the clip is a self-contained CPU payload.
Structs
| File | Description |
|---|---|
clip_blob_header |
32-byte little-endian header of a cooked clip, written verbatim and followed by dataBytes of interleaved f32 samples (PCM) or the original encoded file (STREAMED). |
clip_import_settings |
Importer settings, mirrored by the JSON object { "storage": "auto", "streamThresholdSeconds": 10.0, "forceMono": false, "sampleRate": 0, "normalize": false }. forceMono, sampleRate and normalize apply to PCM storage only; STREAMED keeps the file, and the importer reports a warning when one of them is set on a clip it streams. |
Classes
| File | Description |
|---|---|
audio_clip_importer |
The conjure.audio.clip importer: .wav .ogg .mp3 .flac -> one cooked clip blob (cook_clip). Deterministic and stateless; runs on a worker thread. |
audio_clip_loader |
The conjure.audio.clip loader: blob -> audio_clip on the load job; finalise returns the clip unchanged; the fallback is the silent clip. |
Enumerations
clip_storage_setting
The storage choice of an import: AUTO picks STREAMED above streamThresholdSeconds.
Constants
| Name | Type | Value | Description |
|---|---|---|---|
CLIP_BLOB_VERSION |
inline constexpr u32 |
1 |
Blob format version written into clip_blob_header::version. |
CLIP_EXTENSIONS |
inline constexpr std:: |
{".wav", |
|
CLIP_IMPORTER_ID |
inline constexpr std:: |
"conjure.audio.clip" |
Importer identity and the extensions it claims. |
CLIP_IMPORTER_VERSION |
inline constexpr u32 |
1 |
Functions
Public
cook_clip
cook_clip[[nodiscard]] CONJURE_API core::result<std::vector<byte>> cook_clip(
std::span<const byte> encoded,
const clip_import_settings &settings);Imports a source file into a cooked blob (header + payload). PCM storage decodes with decode_options built from the settings; STREAMED storage copies the file byte for byte and records the probed format. Deterministic for the same input and build. Errors are those of probe() / decode_to_pcm().
is_clip_extension
is_clip_extension[[nodiscard]] CONJURE_API bool is_clip_extension(
std::string_view extension) noexcept;True when the lower-case extension (".wav") is one the importer claims.
load_clip_blob
load_clip_blob[[nodiscard]] CONJURE_API core::result<audio_clip> load_clip_blob(
std::span<const byte> blob);Turns a blob into a self-contained clip: PCM samples are copied into a fresh pcm_buffer, STREAMED bytes are copied and opened with the header's frameCount (no full decode) to check that their format matches the header. Errors: INVALID_CLIP for a bad header or a streamed payload whose format disagrees with it, DECODE_FAILED / UNSUPPORTED_FORMAT when streamed bytes do not decode.
read_clip_blob_header
read_clip_blob_header[[nodiscard]] CONJURE_API core::result<clip_blob_header> read_clip_blob_header(
std::span<const byte> blob);Validates and returns the header of a blob: magic, version, storage and encoding values, channels 1 or 2, sample rate in range, dataBytes equal to the payload size and (PCM) equal to frameCount * channels * 4. Fails with INVALID_CLIP naming the mismatch.
register_asset_types
register_asset_types[[nodiscard]] CONJURE_API core::result<void> register_asset_types(
assets::asset_type_registry &types,
assets::importer_registry &importers);Registers conjure.audio.clip (with its loader) and the clip importer. Main thread, from audio_subsystem::startup. Errors are those of the two registries (TYPE_DUPLICATE, ...).
to_string
to_string[[nodiscard]] CONJURE_API std::string_view to_string(
clip_storage_setting value) noexcept;Lower-case JSON spelling ("auto", "pcm", "streamed").