Skip to content

Audio

Audio tracks provide background music, sound effects, and ambient sounds. They can be triggered by AI directives, rules, or automatic playlists.

AudioTrack Schema

json
{
  "id": "bgm-tavern",
  "name": "Tavern Theme",
  "type": "bgm",
  "url": "@asset:uuid-here",
  "allowAiControl": true,
  "loop": true,
  "volume": 0.4,
  "fadeIn": 2,
  "fadeOut": 1.5,
  "maxDuration": null
}
FieldTypeDescription
idstringUnique kebab-case ID
namestringDisplay name
type"bgm" | "sfx" | "ambient"Track type
urlstringAudio source — @asset:{id} or direct URL
allowAiControlboolean (optional)Whether AI directives can control this track. Defaults to enabled when omitted; false reserves control for custom UI, scripts, behaviors, and playlists.
loopbooleanWhether to loop (typical: true for BGM/ambient, false for SFX)
volumenumber0.0 to 1.0
fadeInnumber | nullFade-in duration in seconds
fadeOutnumber | nullFade-out duration in seconds
maxDurationnumber | nullAuto-stop after N seconds

AI Audio Directives

The AI triggers audio through bracket directives for tracks with allowAiControl enabled or omitted. Tracks with allowAiControl: false are excluded from the model's audio track list, and directives targeting them are ignored on send, regenerate, and continue. AI playback chains cannot target them, and AI crossfades leave them playing. This setting does not block custom UI, scripts, behaviors, or playlists.

[audio: bgm-tavern play]
[audio: sfx-sword play]
[audio: bgm-tavern stop]
[audio: bgm-battle crossfade 2.5]
[audio: ambient-rain volume 0.3]
[audio: sfx-magic play chain:bgm-ambient]
ActionDescription
playStart playing the track
stopStop the track
crossfade <seconds>Crossfade from current BGM to this track
volume <0-1>Change track volume
play chain:<trackId>Play this track, then auto-play the next

BGM Playlist

Auto-play a sequence of BGM tracks:

json
{
  "bgmPlaylist": {
    "tracks": ["bgm-explore-1", "bgm-explore-2", "bgm-explore-3"],
    "playMode": "shuffle",
    "gapSeconds": 0,
    "autoPlay": true,
    "waitForFirstMessage": true
  }
}
FieldTypeDescription
tracksstring[]Array of track IDs to cycle through
playMode"loop" | "shuffle" | "sequential"Playback order mode
gapSecondsnumberSilence between tracks (default: 0, max: 30)
autoPlaybooleanStart playing automatically (default: true)
waitForFirstMessagebooleanDon't start until the player sends their first message

Conditional BGM

Play specific tracks when conditions are met. Supports variable checks, keyword matching, turn count, and session start triggers.

json
{
  "conditionalBGM": [
    {
      "id": "combat-music",
      "name": "Combat Music",
      "targetTrackId": "bgm-battle",
      "triggerType": "variable",
      "conditions": [
        { "variableId": "in-combat", "operator": "eq", "value": true }
      ],
      "conditionLogic": "all",
      "priority": 10,
      "fadeInDuration": 1,
      "fadeOutDuration": 2,
      "stopPreviousBGM": true,
      "fallback": "default"
    }
  ]
}
FieldTypeDescription
idstringUnique identifier
namestringDisplay name
targetTrackIdstringTrack to play when triggered
triggerType"variable" | "ai-keyword" | "keyword" | "turn-count" | "session-start"What triggers the conditional BGM
conditionsCondition[]Variable conditions to check
conditionLogic"all" | "any"How multiple conditions combine (default: "all")
keywordsstring[]Keywords to match (for keyword / ai-keyword triggers)
matchWholeWordsbooleanMatch whole words only (for keyword triggers)
atTurnnumberFire at specific turn (for turn-count trigger)
everyNTurnsnumberFire every N turns (for turn-count trigger)
prioritynumberHigher priority wins when multiple triggers match
fadeInDurationnumberFade-in duration in seconds
fadeOutDurationnumberFade-out duration in seconds
stopPreviousBGMbooleanStop the currently playing BGM first
fallback"default" | "previous" | trackId stringWhat to play when the condition becomes false

Condition operators use short form: eq, neq, gt, lt, gte, lte, contains.

When the condition becomes true, the track starts. When false, it stops (with fade-out if configured) and falls back according to the fallback setting.