Schemas / Audio

rig.audio.analysis

v1.0.0 · stable maturity: stable 6 fields 2 required

Fields

FieldTypeMeaning
source enuminput · asset required input (live capture) or asset
asset entity optional Required when source is asset; an entity carrying rig.media.asset_ref
bandCount int required Number of frequency bands to produce
smoothing number0 – 1 optional Optional. 0-1; 0 = no smoothing between frames
onsetThreshold float optional Optional. Absent disables onset detection
features array<enum>onset · note · beat · color · temperature · centroid · spread · rolloff · flatness · flux · chroma · key · chord optional Optional. Which live signals to publish: onset, note, beat, color, temperature, centroid, spread, rolloff, flatness, flux, chroma, key, chord. Absent = host default set

Request for spectral analysis of an audio stream. Format when present.

This describes the analysis to perform, not its results. Band magnitudes, onset flags, MIDI, chroma, color, temperature, key, and chord change every frame and are host state - writing them into a document would make every save differ.

key is a tonic pitch class (0-11, C = 0, the same numbering as chroma) plus a mode. The mode uses the rig.music.pattern scale words: chromatic, major, minor, dorian, pentatonic.

chord is a root pitch class plus intervals, semitone offsets from that root. A major triad is [4, 7]; a minor triad is [3, 7]. Omit 0. The same intervals field is authored on rig.music.step and rig.music.note.

color is rgba feedback derived from the spectrum (hue + energy). temperature is 0 = cold, 1 = warm (bass vs treble). The same two names are used by rig.picture.analysis.

Band layout is deliberately unspecified beyond the count. Linear and logarithmic spacing both occur in the wild and neither is right for every use, so two hosts will agree on the request and may disagree on the bands. Do not build a document that depends on an exact band centre frequency.

To drive a property from a band, use rig.mod.binding.

JSON Schema

Resolves at https://rig.works/schemas/rig.audio.analysis.schema.json — raw file.

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rig.works/schemas/rig.audio.analysis.schema.json",
  "title": "rig.audio.analysis",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "source": {
      "type": "string",
      "enum": [
        "input",
        "asset"
      ]
    },
    "asset": {
      "$ref": "./_defs.schema.json#/$defs/entity"
    },
    "bandCount": {
      "$ref": "./_defs.schema.json#/$defs/int"
    },
    "smoothing": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "onsetThreshold": {
      "$ref": "./_defs.schema.json#/$defs/float"
    },
    "features": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "onset",
          "note",
          "beat",
          "color",
          "temperature",
          "centroid",
          "spread",
          "rolloff",
          "flatness",
          "flux",
          "chroma",
          "key",
          "chord"
        ]
      }
    }
  },
  "required": [
    "source",
    "bandCount"
  ],
  "x-rig-maturity": "stable"
}

Seen in

music-chord.json · visualizer.json