16. Projects & the timeline — layering songs and clips
One .track file is one song — a drum beat, a bassline, a whole tune. But real music is
usually several songs (and maybe a real recorded voice) playing together: drums, bass, and a
vocal all at once. Stacking them like that is called a project, saved as a .sb file.
A project doesn’t replace .track — it layers several .track songs (and recorded audio
clips) into one mix.
A project is made of layers. A note layer points at a .track song and plays it in
full, like pressing play on a whole tune:
bpm 120
layer drums = "drums.track"
layer bass = "bass.track"
mix
drums gain 0dB pan 0
bass gain -2dB pan 0
master limit -1dB
mix sets each layer’s overall volume (gain, in decibels) and left–right placement (pan,
same idea as lesson 11). master limit is the same safety net from lesson 15, now covering the
whole stacked project.
A clip layer is different: instead of a .track song, it points at a real recorded sound
file (.wav) and places it exactly where you put it, without stretching it to fit the tempo —
like sticking a photo onto a page instead of redrawing it to fit the page’s grid. Where a note
layer plays, a clip layer is placed, with at:
layer vox = clip "vox.wav"
at 0
at 16
at 20s
Leave at off entirely and a layer gets one placement at beat 0 automatically — that’s what
drums and bass did above, with no at in sight. Add an indented at line for every extra
placement: at 16 means 16 beats in (beats are the default unit); add an s to count seconds
instead, like at 20s.
Clips don’t have to play in full, and they can repeat. trim A B keeps only beats A to
B of the clip, and loop repeats that trimmed slice until the next placement comes along:
layer vox = clip "vox.wav"
at 0 trim 0 4 loop
at 16
That’s a 4-beat slice of vox.wav, looping from beat 0 until beat 16, where the full clip takes
over.
Placements can also fade, and carry their own gain on top of the lane’s overall volume — handy for a tail that should trail off quieter than the rest:
layer vox = clip "vox.wav"
at 0 fade in 0.5
at 8 gain -6dB fade out 1
fade in 0.5 eases the clip in over half a second; the second placement fades out over a
second, at -6dB — quieter than the first. (pan is not a placement option — it always lives
up in the mix block, one setting per layer.)
You don’t have to write all of this by hand. Open a .sb file and run smallBANG: Open
Studio to see and edit it visually: each layer is a colored lane, and each placement is a
block on it. Drag a block’s middle to move it, drag an edge to trim it, drag the right edge
past the end of the clip to loop it, and drag a corner dot to draw a fade. Ctrl/Cmd+D (or
Alt-drag) duplicates a block, Delete removes it, and the arrow keys nudge it. Click the ruler to
seek and play from there. Playback is live — edit the timeline while it’s playing and it swaps
in seamlessly.
Real names: the whole stacked file is a project; note layers and clip layers; placements (each
at); trim and loop; fades; the mix and the master limiter you already met in lesson 15.
✅ Live now: projects (
.sb), note and clip layers,atplacements (default beat-0, multiple placements, beats orNsseconds),trim,loop,fade in|out, per-placementgain, themixblock (gain/pan),master limit, and the visual Studio timeline editor with live playback — all real today. v1 limit: clip layers must be.wav(no mp3).
Try it yourself: open examples/timeline/timeline.sb for a full multi-placement project, or
examples/dummy/dummy.sb for a simple three-clip playground to drag around in the Studio
editor.