Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions docs/app-store/fixture/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Screenshot fixture: generated audio, fine to ship

Everything here is made by [`scripts/make_fixture.py`](../../../scripts/make_fixture.py) from sine waves and seeded
noise. No recording, sample or third-party multitrack is in it, so it can appear in App Store screenshots, an App
Preview, the website and marketing. Run the script again and it writes the same files.

It replaces the Cambridge-MT test Stems ("Scarlett") in screenshots. Those are test material only: never copy them
here or show them in anything public.

## Saturday Show Stems (committed)

A band's export, as a Folder of Stems: a 120 BPM groove in C, ten bars, 20 seconds, the same length for every file.
The first two bars are keys, hat and click only; the full band plays from 0:04, the vocal from 0:06, and bar 10 is
the last hit.

| File | Channels | Peak |
|---|---|---|
| 01 Kick | mono | -7 dBFS |
| 02 Snare | mono | -9 dBFS |
| 03 Hat | mono | -13 dBFS |
| 04 OH | stereo | -12 dBFS |
| 05 Bass | mono | -9 dBFS |
| 06 Gtr | mono | -7 dBFS |
| 07 Keys | stereo | -8 dBFS |
| 08 Vox | mono | -10 dBFS |
| 09 BV | mono | -18 dBFS |
| 10 Click | mono | -16 dBFS |

16-bit, 48 kHz FLAC, about 3.4 MB in all. The app plays FLAC (`StemFolderScan.audioExtensions`). The channel rules put
these on USB channels 1 to 12: "04 OH" is stereo and "05 Bass" is numbered right after it, so the numbers are read as
track order (#62) and each file follows the one before.

To write them again (needs macOS's `afconvert`):

```sh
python3 scripts/make_fixture.py stems
```

## Saturday Show, a ShowRecorder Show (made when needed)

The same groove as a ShowRecorder Show with Markers, in ShowRecorder's format: `Show.json`, and a folder per Take with
its `Take.json` and 24-bit 48 kHz WAV Stems on USB channels 1 to 12, named by the Mixer.

- **Take 01**, 40 seconds, one Marker: "Line check".
- **Take 02**, 2:40, a Marker per song: "Walk-in", "Song 1", "Song 2", "Song 3", "Outro".

It is about 330 MB, too big to commit, so it is written to a folder outside the repo:

```sh
python3 scripts/make_fixture.py take /tmp/fixture
```

Open it in a Debug build with `-previewTake /tmp/fixture` (see `App/DebugPreview.swift`).
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
280 changes: 280 additions & 0 deletions scripts/make_fixture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
#!/usr/bin/env python3
"""Make the App Store screenshot fixture: a band's Stems, synthesized here, so they are ours to ship.

Every sound is made by this script from sine waves and seeded noise: a 120 BPM groove in C, ten bars (20 seconds).
No recording, sample or third-party multitrack goes in. Run it again and it writes the same audio.

python3 scripts/make_fixture.py stems
Writes the Folder of Stems to docs/app-store/fixture/Saturday Show Stems/ as 16-bit 48 kHz FLAC (committed).
Needs macOS's afconvert for the FLAC step.

python3 scripts/make_fixture.py take <folder>
Writes a ShowRecorder Show into <folder>/Shows/Saturday Show/: Show.json, and Take 01 and Take 02, each with its
Take.json (with Markers) and 24-bit 48 kHz WAV Stems, the format ShowRecorder records. Too big to commit (about
300 MB), so it is made when the screenshots are taken. Open it with `-previewTake <folder>`.

Standard library only (no numpy).
"""
import json
import math
import random
import struct
import subprocess
import sys
import tempfile
import wave
from pathlib import Path

RATE = 48_000
BPM = 120
BEAT = 60 / BPM
BAR = 4 * BEAT
BARS = 10
LENGTH = int(BARS * BAR * RATE) # 20 s

# The band's export, named the way a DAW writes it. Stereo Stems are (left, right).
STEMS = [
("01 Kick", 1), ("02 Snare", 1), ("03 Hat", 1), ("04 OH", 2), ("05 Bass", 1),
("06 Gtr", 1), ("07 Keys", 2), ("08 Vox", 1), ("09 BV", 1), ("10 Click", 1),
]
# X Air hues for the Take's channels, as a mixer's scribble strips would have them.
HUES = {"Kick": "red", "Snare": "red", "Hat": "red", "OH": "red", "Bass": "blue", "Gtr": "green",
"Keys": "cyan", "Vox": "yellow", "BV": "yellow", "Click": "white"}

# C, Am, F, G: root and chord tones (Hz) per bar.
def hz(note): # MIDI note number to Hz
return 440 * 2 ** ((note - 69) / 12)

PROGRESSION = [(36, [60, 64, 67]), (33, [57, 60, 64]), (29, [57, 60, 65]), (31, [59, 62, 67])]

rng = random.Random(20261203)


def db(value):
return 10 ** (value / 20)


def silence():
return [0.0] * LENGTH


def add(track, start_seconds, samples, gain=1.0):
start = int(start_seconds * RATE)
for i, s in enumerate(samples):
j = start + i
if j >= LENGTH:
break
track[j] += s * gain


def env(n, attack, decay):
"""Attack (s) then exponential decay with time constant `decay` (s), n samples."""
a = max(1, int(attack * RATE))
return [(i / a if i < a else math.exp(-(i - a) / (decay * RATE))) for i in range(n)]


def kick():
n = int(0.45 * RATE)
out, phase = [], 0.0
for i in range(n):
t = i / RATE
f = 48 + 90 * math.exp(-t / 0.03)
phase += 2 * math.pi * f / RATE
out.append(math.sin(phase) * math.exp(-t / 0.16))
return out


def snare():
n = int(0.3 * RATE)
return [(0.55 * (rng.random() * 2 - 1) * math.exp(-i / (0.07 * RATE))
+ 0.5 * math.sin(2 * math.pi * 190 * i / RATE) * math.exp(-i / (0.05 * RATE))) for i in range(n)]


def hat(open_=False):
n = int((0.25 if open_ else 0.06) * RATE)
decay = 0.08 if open_ else 0.015
out, last = [], 0.0
for i in range(n):
x = rng.random() * 2 - 1
out.append((x - last) * 0.5 * math.exp(-i / (decay * RATE))) # first difference: a crude high-pass
last = x
return out


def crash():
n = int(1.6 * RATE)
out, last = [], 0.0
for i in range(n):
x = rng.random() * 2 - 1
out.append((x - last) * 0.4 * math.exp(-i / (0.5 * RATE)))
last = x
return out


def tone(freq, seconds, harmonics, attack=0.005, decay=0.3, vibrato=0.0, detune=0.0):
n = int(seconds * RATE)
shape = env(n, attack, decay)
out, phase = [], 0.0
for i in range(n):
f = freq * (1 + detune) * (1 + vibrato * math.sin(2 * math.pi * 5.5 * i / RATE) * min(1, i / (0.3 * RATE)))
phase += 2 * math.pi * f / RATE
out.append(shape[i] * sum(a * math.sin(k * phase) for k, a in harmonics))
# A short fade so a note never ends in a click.
fade = min(n, int(0.01 * RATE))
for i in range(fade):
out[n - 1 - i] *= i / fade
return out


def render():
rng.seed(20261203) # the same noise on every run
t = {name: (silence(), silence()) if ch == 2 else (silence(),) for name, ch in STEMS}
k, s, h, oh, bass, gtr, keys, vox, bv, click = (t[name] for name, _ in STEMS)
kick_hit, snare_hit = kick(), snare()
for bar in range(BARS):
start = bar * BAR
root, chord = PROGRESSION[bar % 4]
full = 2 <= bar <= 8
# Click: every beat, the downbeat higher.
for beat in range(4):
add(click[0], start + beat * BEAT, tone(1_500 if beat == 0 else 1_000, 0.03, [(1, 1)], 0.001, 0.008), db(-12))
# Keys: a pad on every bar, the two sides a little apart.
for note in chord:
add(keys[0], start, tone(hz(note), BAR, [(1, 1), (2, 0.3)], 0.15, 1.6, detune=-0.002), db(-14))
add(keys[1], start, tone(hz(note), BAR, [(1, 1), (2, 0.3)], 0.15, 1.6, detune=0.002), db(-14))
# Hat: eighths from the start; an open hat on the last eighth of bar 2.
for eighth in range(8):
open_ = bar == 1 and eighth == 7
add(h[0], start + eighth * BEAT / 2, hat(open_), db(-8 if eighth % 2 == 0 else -12))
if not full and bar != 9:
continue
# Drums.
for beat in ([0, 2, 2.5] if bar != 9 else [0]):
add(k[0], start + beat * BEAT, kick_hit, db(-4))
for beat in ([1, 3] if bar != 8 else [1, 3, 3.5, 3.75]):
add(s[0], start + beat * BEAT, snare_hit, db(-5))
if bar in (2, 6, 9):
hit = crash()
add(oh[0], start, hit, db(-9))
add(oh[1], start, hit[50:], db(-10))
if bar == 9:
continue
# Bass: eighth notes on the root, up an octave on the last one.
for eighth in range(8):
note = root + (12 if eighth == 7 else 0)
add(bass[0], start + eighth * BEAT / 2,
tone(hz(note), BEAT / 2 * 0.9, [(1, 1), (2, 0.5), (3, 0.25), (4, 0.12)], 0.004, 0.25), db(-8))
# Guitar: a short chord on 2 and 4.
for beat in (1, 3):
for note in chord:
add(gtr[0], start + beat * BEAT, tone(hz(note), 0.3, [(1, 1), (2, 0.6), (3, 0.4), (5, 0.2)], 0.002, 0.08), db(-14))
# Vox: a phrase in bars 3 to 8, over the chord tones.
if bar >= 3:
melody = [chord[2] + 5, chord[1] + 12, chord[2] + 12, chord[0] + 12]
for i, note in enumerate(melody):
if i == 3 and bar % 2:
continue
add(vox[0], start + i * BEAT, tone(hz(note - 12), BEAT * 0.85, [(1, 1), (2, 0.5), (3, 0.3), (4, 0.15)],
0.04, 0.6, vibrato=0.006), db(-9))
# BV: a third above on the long notes, bars 5 to 8.
if bar >= 5:
add(bv[0], start, tone(hz(chord[1]), BAR * 0.9, [(1, 1), (2, 0.3)], 0.25, 1.2, vibrato=0.004), db(-15))
# The overheads hear the kit too, from further away.
for i in range(LENGTH):
kit = 0.35 * k[0][i] + 0.6 * s[0][i] + 0.8 * h[0][i]
oh[0][i] += kit * 0.45
oh[1][i] += kit * 0.4
return [t[name] for name, _ in STEMS]


# The whole band 4 dB down, so the loudest hits peak near -7 dBFS and the meters sit in their -18 to -6 band.
TRIM = db(-4)


def interleave(channels, scale):
out = []
for i in range(LENGTH):
for c in channels:
out.append(max(-1.0, min(1.0, c[i] * TRIM)) * scale)
return out


def write_wav(path, channels, bits):
with wave.open(str(path), "wb") as w:
w.setnchannels(len(channels))
w.setsampwidth(bits // 8)
w.setframerate(RATE)
w.writeframes(pcm(channels, bits))


def pcm(channels, bits, repeat=1):
full = 2 ** (bits - 1) - 1
values = [int(round(v)) for v in interleave(channels, full)]
if bits == 16:
data = struct.pack(f"<{len(values)}h", *values)
else:
data = b"".join(struct.pack("<i", v)[:3] for v in values)
return data * repeat


def stems_command(root):
out = root / "docs" / "app-store" / "fixture" / "Saturday Show Stems"
out.mkdir(parents=True, exist_ok=True)
tracks = render()
with tempfile.TemporaryDirectory() as tmp:
for (name, _), channels in zip(STEMS, tracks):
wav = Path(tmp) / f"{name}.wav"
write_wav(wav, channels, 16)
subprocess.run(["afconvert", "-f", "flac", "-d", "flac", str(wav), str(out / f"{name}.flac")], check=True)
print(f"Wrote {len(STEMS)} Stems to {out}")


def take_command(folder):
tracks = render()
show_name = "Saturday Show"
show = folder / "Shows" / show_name
show.mkdir(parents=True, exist_ok=True)
# Take 01 is a short line check (2 loops, 40 s); Take 02 is the set (8 loops, 2:40) with a Marker per song.
takes = [
(1, 2, "2026-11-28T19:02:00Z", [("Line check", 0)]),
(2, 8, "2026-11-28T20:15:00Z", [("Walk-in", 0), ("Song 1", 20), ("Song 2", 60), ("Song 3", 100), ("Outro", 140)]),
]
for number, loops, started, markers in takes:
take = show / f"Take {number:02d}"
take.mkdir(exist_ok=True)
usb, channel = [], 1
for (name, count), channels in zip(STEMS, tracks):
label = name.split(" ", 1)[1]
file = f"{channel:02d} {label}.wav"
with wave.open(str(take / file), "wb") as w:
w.setnchannels(count)
w.setsampwidth(3)
w.setframerate(RATE)
w.writeframes(pcm(channels, 24, repeat=loops))
entry = {"usbChannel": channel, "stemFile": file, "name": label, "hasMixerName": True,
"color": {"hue": HUES[label], "inverted": False}}
if count == 2:
entry["channels"] = 2
usb.append(entry)
channel += count
metadata = {
"show": show_name, "take": number, "startedAt": started, "sampleRate": RATE, "timeReference": 0,
"usbChannels": usb,
"markers": [{"position": seconds * RATE, "name": name, "origin": "operator"} for name, seconds in markers],
"gaps": [], "repairs": [],
}
(take / "Take.json").write_text(json.dumps(metadata, indent=2, sort_keys=True) + "\n")
show_file = {"name": show_name, "startedAt": "2026-11-28T19:00:00Z", "endedAt": "2026-11-28T20:20:00Z",
"venue": "The Blue Room", "takes": 2}
(show / "Show.json").write_text(json.dumps(show_file, indent=2, sort_keys=True) + "\n")
print(f"Wrote {show_name} (2 Takes) to {show}")


if __name__ == "__main__":
repo = Path(__file__).resolve().parent.parent
if len(sys.argv) >= 2 and sys.argv[1] == "stems":
stems_command(repo)
elif len(sys.argv) == 3 and sys.argv[1] == "take":
take_command(Path(sys.argv[2]).resolve())
else:
sys.exit(__doc__)
Loading