Skip to content

Engine → Audio

audio_types.h

Formats, identifiers and constants shared by every audio header. The mixer renders interleaved f32 stereo at audio_settings::sampleRate; every other format is converted by the backend (miniaudio) or at import (decoder).

Structs

File Description
audio_format Sample rate, channel count and sample format of a buffer or of the mixer output.

Enumerations

attenuation_model

enum class attenuation_model : u8 {
    NONE,
    INVERSE,
    LINEAR,
    EXPONENTIAL
};

Distance attenuation curve of a spatial voice.

audio_backend_kind

enum class audio_backend_kind : u8 {
    AUTO,
    MINIAUDIO,
    NULL_BACKEND
};

Which backend audio_engine talks to. AUTO picks MINIAUDIO when it is compiled in and falls back to NULL_BACKEND when no device can be opened.

clip_encoding

enum class clip_encoding : u8 {
    UNKNOWN,
    WAV,
    OGG_VORBIS,
    MP3,
    FLAC
};

Container / codec of the source file a clip was imported from.

clip_storage

enum class clip_storage : u8 {
    PCM,
    STREAMED
};

How a clip keeps its samples: decoded at import (PCM) or decoded incrementally while playing from the compressed bytes kept in memory (STREAMED).

device_state

enum class device_state : u8 {
    STOPPED,
    STARTING,
    RUNNING,
    LOST
};

Device state published by a backend (atomic, readable from any thread).

sample_format

enum class sample_format : u8 {
    F32
};

Sample format of pcm_buffer and of the mixer. F32 is the only one in v1.

voice_state

enum class voice_state : u8 {
    FREE,
    PRIMING,
    PLAYING,
    PAUSED,
    STOPPING,
    FINISHED,
    STOPPED
};

Lifecycle of a voice. PRIMING covers a streamed voice waiting for its first chunk and a voice waiting for a stolen mixer slot; FINISHED and STOPPED are terminal.

Constants

Name Type Value Description
COMMAND_RING_CAPACITY inline constexpr u32 8192
DEFAULT_RAMP_SECONDS inline constexpr f32 0.005f
DEFAULT_SPEED_OF_SOUND inline constexpr f32 343.0f
EVENT_RING_CAPACITY inline constexpr u32 4096
MAX_GROUP_DEPTH inline constexpr u32 8
MAX_GROUPS inline constexpr u32 32
MAX_SAMPLE_RATE inline constexpr u32 192000
MAX_STREAMING_VOICES inline constexpr u32 32
MAX_VOICES inline constexpr u32 256
MIN_SAMPLE_RATE inline constexpr u32 8000
MIX_BLOCK_FRAMES inline constexpr u32 256
MIX_CHANNELS inline constexpr u32 2
STEAL_FADE_SECONDS inline constexpr f32 0.002f
STREAM_CHUNK_FRAMES inline constexpr u32 4096
STREAM_RING_FRAMES inline constexpr u32 16384

Macros

CONJURE_AUDIO_ENUM_FORMATTER

CONJURE_AUDIO_ENUM_FORMATTER(conjure::audio::sample_format)

Functions

Public

is_active_state

[[nodiscard]] constexpr bool is_active_state(
    voice_state state) noexcept;

True for PRIMING, PLAYING and PAUSED: the states in which audio_engine::is_playing() holds.

is_terminal_state

[[nodiscard]] constexpr bool is_terminal_state(
    voice_state state) noexcept;

True for FINISHED and STOPPED: the voice has been acknowledged as ended by the mixer.

to_string

[[nodiscard]] CONJURE_API std::string_view to_string(
    sample_format value) noexcept;

Enumerator names ("F32", "PCM", "PLAYING", ...); "UNKNOWN" for out-of-range values.

[[nodiscard]] CONJURE_API std::string_view to_string(
    clip_storage value) noexcept;
[[nodiscard]] CONJURE_API std::string_view to_string(
    clip_encoding value) noexcept;
[[nodiscard]] CONJURE_API std::string_view to_string(
    audio_backend_kind value) noexcept;
[[nodiscard]] CONJURE_API std::string_view to_string(
    device_state value) noexcept;
[[nodiscard]] CONJURE_API std::string_view to_string(
    voice_state value) noexcept;
[[nodiscard]] CONJURE_API std::string_view to_string(
    attenuation_model value) noexcept;