Skip to main content

SoundDoc

Struct SoundDoc 

Source
pub struct SoundDoc {
    pub name: String,
    pub duration: f32,
    pub sample_rate: u32,
    pub seed: u64,
    pub version: Option<u32>,
    pub engine: Option<u32>,
    pub stereo: Stereo,
    pub normalize: Option<Normalize>,
    pub playback: Playback,
    pub root: Node,
}
Expand description

A complete sound: metadata plus a single root node.

Fields§

§name: String

Human-readable label for the sound (e.g. "laser_zap").

§duration: f32

Length of the rendered sound in seconds.

§sample_rate: u32

Output sample rate in Hz.

§seed: u64

Seed for any stochastic node (noise). Same seed ⇒ identical audio.

§version: Option<u32>

DSL schema version. Omitted ⇒ 1, the semantics documents were authored under before versioning mattered; the authoring tools stamp new documents with the current SCHEMA_VERSION. Documents from a newer tono are rejected by validate instead of silently misrendered.

§engine: Option<u32>

DSP-kernel revision (see ENGINE_VERSION). Omitted ⇒ 0, the original kernels — so every existing document renders byte-for-byte as before. The authoring tools stamp new documents with the current ENGINE_VERSION; raising a document’s engine opts it into newer, higher-quality kernels (anti-aliased drive, …) and DOES change its output. A document from a newer tono (engine > ENGINE_VERSION) is rejected by validate rather than silently misrendered.

§stereo: Stereo

Optional stereo treatment applied to the final mono render. Defaults to mono (game SFX are usually authored mono and spatialised by the engine; use stereo for BGM, ambience, and UI stingers).

§normalize: Option<Normalize>

Optional output-stage loudness normalization + true-peak limiting. When set with target_lufs, the final render is gain-matched to that integrated loudness, then brick-wall limited so the inter-sample (true) peak never exceeds ceiling_dbtp. Leave unset for the default behaviour (a transparent −0.1 dBFS sample-peak safety limit only). Use it to ship a level-matched set: pick one target (e.g. −16 LUFS for SFX) for the pack.

§playback: Playback

Playback intent. oneshot (default) renders the sound as-is. loop extracts the loop region and equal-power crossfades its tail into its head so the rendered file repeats seamlessly — the right mode for ambience beds, engine drones, and BGM. The exported WAV carries a smpl loop chunk so engines (Godot / Unity / FMOD) loop at the sample-accurate points without manual setup.

§root: Node

The signal graph. Usually a mix, mul, or chain.

Implementations§

Source§

impl SoundDoc

Source

pub fn validate(&self) -> Result<(), ValidateError>

Validate ranges and structure beyond what serde already enforces. The error’s message is human-readable and names the offending field.

Source§

impl SoundDoc

Source

pub fn new(name: impl Into<String>, root: Node) -> Self

A new document around root, stamped with the current SCHEMA_VERSION and ENGINE_VERSION (this is the authoring constructor — new sounds get the current kernels) and every other field at its serde default: 0.3 s, 44 100 Hz, seed 0, mono, one-shot.

Source§

impl SoundDoc

Source

pub fn effective_version(&self) -> u32

The schema version this document’s render semantics follow (omitted ⇒ 1).

Source

pub fn effective_engine(&self) -> u32

The DSP-kernel revision this document renders under (omitted ⇒ 0, the original kernels). Gates byte-changing kernel upgrades so old documents stay bit-exact; see ENGINE_VERSION.

Source

pub fn sf2_paths(&self) -> Vec<&str>

Every SoundFont path the document references (each seq with wave: "sampler" and a non-empty sf2). validate is filesystem-free — the core is pure compute — so a loader (the CLI, the Python bindings, a game’s asset pipeline) calls this after validation to check the files exist and fail loud at load time.

Source

pub fn ensure_track_ids(&mut self) -> bool

Backfill missing track ids deterministically (layer_<position>, suffixed on collision with explicit ids). Runs at the build chokepoint so every persisted mixer document carries addressable layers; the rule is positional, so replaying a journal mints identical ids. Returns true if anything changed.

Trait Implementations§

Source§

impl Clone for SoundDoc

Source§

fn clone(&self) -> SoundDoc

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SoundDoc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SoundDoc

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<SoundDoc> for Patch

Source§

fn from(doc: SoundDoc) -> Self

Converts to this type from the input type.
Source§

impl JsonSchema for SoundDoc

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for SoundDoc

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more