3. Levels¶
3.1 The idea¶
A level is one state of an event. For music, levels are intensity tiers — calm → build → peak — each with its own tracks and mix. For SFX, levels are alternate sample sets behind one trigger — the classic example is footstep surfaces:

The Footsteps demo's footsteps_walk event has four levels — one per
surface. The game keeps triggering the same event; switching the level
switches what plays:
PFA.set_level("footsteps_walk", 2) # stepped onto stone
PFA.trigger("footsteps_walk") # each step
pfa.setLevel('footsteps_walk', 2);
pfa.trigger('footsteps_walk');
Levels are indexed from 0 in game code, left to right as shown in the level bar.
3.2 Working with levels¶
The level bar sits above the timeline:
- Click a level tab to select it — the timeline below always shows the
current level's tracks. The active tab is highlighted, and the
Current:label confirms it. +adds a level,−removes the last one (Simple Music and SFX; an Advanced Music event manages levels as Section nodes — add and remove them in the node editor, ch. 6).- Each track decides per level what to play (per-level sample sets) or can play the same material on every level — that's the track's level behavior, ch. 5.
During preview, switching tabs is the same operation your game performs with
set_level() — you hear the transition the players will get, with the
differences ch. 9.1 lists (among them: the tab that already plays, clicked
while a switch waits, cancels that switch here and is ignored in-game).
3.3 Level switching (music)¶
For music events the level switch is a musical crossfade, controlled by the right side of the level bar:
- Switch — quantization of the moment the switch happens: on the next Bar, next Beat, or Instant.
- Fade — crossfade duration, 0–10 s (double-click the slider to reset to 2.0 s), with a live readout.
- Curve —
Equal Power,Linear,S-Curve,Exponential,Logarithmic.
These three settings are global for the event — every level switch uses the same crossfade. When you need different transitions per direction (e.g. a fast rise into combat, a slow drop out of it), that is authored with fade nodes in the node graph (ch. 6), which give you a fade per transition rather than per level.
Two details that make switches feel professional:
- Phase-synced entry. Levels stay aligned to the same musical timeline:
when you enter a level mid-bar, it continues from the equivalent
position, not from its beginning. Fresh-start behavior is an explicit
opt-in per node in the node graph (
Restart on entry, ch. 6). - Per-level playback state. Each level remembers its own variation
rotation and play-chance dice, and that state keeps advancing in the
background while another level is audible — re-entering a level doesn't
restart its musical "story". One difference to know: the game engines
seed every level's dice at
play()and tick them all from the start, while the editor's preview seeds a level the first time it is heard and simulates only levels it has already played — a level's first entry can land on a different variation in preview than in the game; later re-entries agree (ch. 9.1).
3.4 Simple mode vs the node graph¶
The level system is adaptive music for most games: a handful of tiers, one
crossfade rule, set_level() from code. When you need different transitions
per direction, tempo changes between sections, one-shot stingers on top of
transitions, or probability-driven routing — switch the event to the node
graph (ch. 6). Levels remain the foundation: each node in the graph plays
one level's tracks.