Skip to content

Help center

Expressions and scripts

Drive any setting with a formula that moves to your song, and automate the workspaces with scripts: built-in ones, ones SW Agent writes from your words, and your own.

Describes Sonic Weaver v5.28, released .

An expression on a setting

Any setting you can keyframe can follow a formula instead. In Classic and Studio, open the Keyframes section and press f(x) beside the setting's diamond (Studio also has it under each number in the inspector). Type the formula: it is checked as you type, an error says where it is in plain words, and the line under it shows the motion over four bars of your song. Enter or Apply puts it on; Escape puts the field back; Remove takes it off. Each change is one undo step.

The formula runs on the setting's own value after its keyframes, so value * (1 + pulse(beat, 6) * 0.3) keeps your animation and adds a pulse on every beat. The preview, every export, the stream and the screensaver read the same value for the same moment.

Everyone can use expressions, signed in or not. A formula is never run as code: it is read by Sonic Weaver's own parser, which knows only the names below, and a project or template shared with you has its formulas checked again when it opens. A formula that cannot work at one instant (a division by zero) shows the setting's own value for that frame only.

What a formula can read

The song's time, its tempo and beat grid, and its sound, read from your project:

  • t: the song's time in seconds.
  • time: the song's time in seconds (the same as t).
  • beat: the beat position: whole beats since the song began plus the fraction into this one.
  • bar: the bar position: whole bars plus the fraction into this one.
  • bpm: the song's tempo in beats per minute.
  • energy: the music's overall loudness, 0 to 1.
  • bass: the bass level, 0 to 1.
  • mid: the mid level, 0 to 1.
  • treble: the treble level, 0 to 1.
  • value: the control's own value (its keyframed or set value).
  • seed: the look's seed, for noise and random values.
  • fps: the frame rate of the export or preview.
  • index: which copy this is, when a formula drives many (0, 1, 2...).
  • kick: the kick drum's hit, 1 on the hit and dying away to 0.
  • snare: the snare's hit, 1 on the hit and dying away to 0.
  • hat: the hi-hat's hit, 1 on the hit and dying away to 0.
  • onset: a new sound starting, 0 to 1.

Functions and presets

Shaping: pulse, wave, saw, tri, square, smoothstep, step, clamp, mix and the easings. Motion: wiggle and noise (seeded by your project, so they wander the same way in every export), loop, and valueAt, which reads the setting's own keyframes at another time: valueAt(loop(t, 4)) loops them every 4 seconds and valueAt(t - 0.5) follows half a second behind. Maths: sin, cos, abs, min, max, floor, round and the rest the calculator knows.

The presets under the field are ready to use or change:

  • Wiggle on the beat: value + wiggle(bpm / 60, 0.1) (any position or rotation).
  • Loop every 4 seconds: valueAt(loop(t, 4)) (any keyframed setting).
  • Bass pulse: value * (1 + bass * 0.3) (scale, glow, opacity).
  • Pulse on every beat: value * (1 + pulse(beat, 6) * 0.3) (scale, glow, speed).
  • Jump on the kick: value * (1 + kick * 0.25) (scale, glow).
  • Fade in over each phrase: value * smoothstep(0, 1, fract(bar / 4)) (opacity).

Scripts

A script is a list of steps, each one of SW Agent's own jobs with its values, or one of its chains with words, and a step can repeat over a list (up to 195 items, so every country fits). Say "run the countries batch script" or press Preview on one: every step is shown before anything runs. Run all, or Step by step to run one and see it before the next. A script can only do what you could do by asking, each step is one undo step in the editors, and the first step that cannot finish stops it with the reason.

Ask SW Agent to write one from your words ("write a script that makes a 9:16 clip for each of japan, brazil and kenya"): it reads each part into one of its jobs, shows the steps and the script as text, and keeps it in your scripts when you press Save to my scripts. Your scripts are private to you: on your account when you are signed in (My library), in this browser when you are not. In Classic or Studio, My library opens a script in the SW Agent tab.

Built-in scripts

Everyone can run these, or copy one into their own scripts and change it. Every chain SW Agent runs is a built-in script as well, 31 in all.

  • Picture to visualizer to project: Generates a visualizer from the attached picture and opens it as a project.
  • Song to 9:16 lyric video: Writes the words of the attached song and sets up a vertical lyric video of it.
  • Countries batch: One 9:16 Countries and Flags project for each country in its list, each ready to export as its own clip. Copy it and change the list (up to all 195).
  • Playlist to one video: Lays the attached songs on the Timeline with a look for each, as one video.
  • Project in all six shapes: Builds the look in 16:9, 9:16, 1:1, 4:5, 4:3 and 21:9, each ready to export.
  • Release thumbnail set: A YouTube thumbnail, a Shorts cover, a square cover and a channel banner from the attached picture.
  • Stream screens from a project: Starting soon, be right back and ending screens over the look, for a stream.
  • Animal scene: A wolf on the song that sniffs at 2 seconds, then runs away on the drop. Copy it to choose another animal and other actions.

For AI assistants

Assistants connected to Sonic Weaver's MCP server can list the built-in scripts, each with its steps, with list_scripts. Scripts run in your browser, on your project, so they are run from SW Agent's chat.

Still have a question about this?

SW Agent answers from this article and the rest of our docs, and can do it for you with the site's own tools.

Help center

Keep going

Was this page helpful?

Anonymous. Only this page’s address and your yes/no are recorded, and only if you allowed analytics cookies.