Flyback Download

Embed

Put a patch on your own page.

Two lines of HTML turn a patch's text into highlighted code with a Play button. Play opens the patch in a player over your page or beside it, picture and sound, with nothing to install.

Try it

This is the Sidebands preset, its numbers rounded, as it would sit in a blog post. Play opens it over the page.

// Frequency modulation built by hand: one sine into another's phase, the amount
// struck and left to fall, and an Analyzer on what comes out.

description "One sine bending another's phase at audio rate, on an Analyzer showing the"
  "partials that grows."
tags "synthesis"

// Every two seconds, and nothing sustained: the note is all decay, which lets the
// partials be watched leaving.
let strike = pulse(freq: 0.5, width: 0.1)
               |> adsr(gate: _, attack: 2ms, decay: 1.5s, sustain: 0, release: 300ms)

// How hard the next strike bends the carrier, wandering between a mellow note and a
// clangorous one so no two strikes are the same bell.
let depth = sine(freq: 0.07) |> remap(-1..1, 0.2..1.6)

// A modulator three and a half times above A3. Not a whole number, so the partials
// are not harmonics: the difference between an organ and a bell.
let root      = note(A3)
let modulator = sine(freq: root * 3.5)

// The index falls with the strike, so the note starts bright and rings pure: on the
// chart a comb of peaks closing up into one.
let voice     = sine(freq: root, phase: modulator * (strike * depth)) * strike

voice |> out.left
analyzer(voice, window: 50ms, range: 72) |> out.color

out.volume = 0.3

This one, the Lissajous preset, is embedded to open beside the page instead, so the code stays readable while it plays.

// Two sines, one to each speaker, drawn against each other by a Beam. A fifth is
// three cycles against two, which is the knot; the right one is a fifth of a hertz
// sharp, so the knot turns, back to the same shape every two and a half seconds.

description "Two sines a fifth apart, left against right on a Beam: a knot that turns"
  "because the fifth is a little sharp."
tags "basics" "scope"

let left  = sine(freq: 110, amp: 0.85)
let right = sine(freq: 165.2, amp: 0.85)

left |> out.left
right |> out.right

// Thirty milliseconds of phosphor: a few turns of the knot.
beam(x: left, y: right, persistence: 30ms, intensity: 1.2) |> out.color

out.volume = 0.2

How to embed

Write the patch's text inside a pre with a data-flyback attribute naming it, and load embed.js once anywhere on the page:

<pre data-flyback="FM bell" data-opens="overlay">
let voice = sine(freq: 220) * 0.3
voice |> out.left
</pre>
<script src="https://flybackmodular.app/embed.js" async></script>

Every pre data-flyback on the page gets the same treatment: the text is colored the way the editor's text view colors it, with line numbers, a Copy button and a Play button. The code is read-only; to change it, copy it into Flyback or press Open in Flyback in the player.

Over the page or beside it

Whoever embeds the patch picks where the player opens, with data-opens:

  • overlay, the default: the page dims and the player opens over it. Esc, the close button or a click on the dimmed page closes it.
  • side: the player docks on the right and the page moves over to make room, so the code can be read while the patch plays. The block's button turns into Pause.

A screen too narrow for a panel beside the page, such as a phone's, always gets the overlay.

What it loads

Until someone presses Play, the page loads only embed.js, its stylesheet and the highlighter: a few kilobytes. Play loads the web viewer, about 9.5 MB the first time and from the browser's cache after that. The patch's text travels to the player in the part of the address after #, which browsers never send to a server, so nothing about the patch reaches this site.