diff --git a/docs/app-store/fixture/README.md b/docs/app-store/fixture/README.md new file mode 100644 index 0000000..136aca3 --- /dev/null +++ b/docs/app-store/fixture/README.md @@ -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`). diff --git a/docs/app-store/fixture/Saturday Show Stems/01 Kick.flac b/docs/app-store/fixture/Saturday Show Stems/01 Kick.flac new file mode 100644 index 0000000..8e05c9e Binary files /dev/null and b/docs/app-store/fixture/Saturday Show Stems/01 Kick.flac differ diff --git a/docs/app-store/fixture/Saturday Show Stems/02 Snare.flac b/docs/app-store/fixture/Saturday Show Stems/02 Snare.flac new file mode 100644 index 0000000..07ddc8e Binary files /dev/null and b/docs/app-store/fixture/Saturday Show Stems/02 Snare.flac differ diff --git a/docs/app-store/fixture/Saturday Show Stems/03 Hat.flac b/docs/app-store/fixture/Saturday Show Stems/03 Hat.flac new file mode 100644 index 0000000..32ec5ec Binary files /dev/null and b/docs/app-store/fixture/Saturday Show Stems/03 Hat.flac differ diff --git a/docs/app-store/fixture/Saturday Show Stems/04 OH.flac b/docs/app-store/fixture/Saturday Show Stems/04 OH.flac new file mode 100644 index 0000000..3d87308 Binary files /dev/null and b/docs/app-store/fixture/Saturday Show Stems/04 OH.flac differ diff --git a/docs/app-store/fixture/Saturday Show Stems/05 Bass.flac b/docs/app-store/fixture/Saturday Show Stems/05 Bass.flac new file mode 100644 index 0000000..2bf4855 Binary files /dev/null and b/docs/app-store/fixture/Saturday Show Stems/05 Bass.flac differ diff --git a/docs/app-store/fixture/Saturday Show Stems/06 Gtr.flac b/docs/app-store/fixture/Saturday Show Stems/06 Gtr.flac new file mode 100644 index 0000000..83d559b Binary files /dev/null and b/docs/app-store/fixture/Saturday Show Stems/06 Gtr.flac differ diff --git a/docs/app-store/fixture/Saturday Show Stems/07 Keys.flac b/docs/app-store/fixture/Saturday Show Stems/07 Keys.flac new file mode 100644 index 0000000..9c2d1d2 Binary files /dev/null and b/docs/app-store/fixture/Saturday Show Stems/07 Keys.flac differ diff --git a/docs/app-store/fixture/Saturday Show Stems/08 Vox.flac b/docs/app-store/fixture/Saturday Show Stems/08 Vox.flac new file mode 100644 index 0000000..2e77b0f Binary files /dev/null and b/docs/app-store/fixture/Saturday Show Stems/08 Vox.flac differ diff --git a/docs/app-store/fixture/Saturday Show Stems/09 BV.flac b/docs/app-store/fixture/Saturday Show Stems/09 BV.flac new file mode 100644 index 0000000..7e8d575 Binary files /dev/null and b/docs/app-store/fixture/Saturday Show Stems/09 BV.flac differ diff --git a/docs/app-store/fixture/Saturday Show Stems/10 Click.flac b/docs/app-store/fixture/Saturday Show Stems/10 Click.flac new file mode 100644 index 0000000..d29f9c0 Binary files /dev/null and b/docs/app-store/fixture/Saturday Show Stems/10 Click.flac differ diff --git a/scripts/make_fixture.py b/scripts/make_fixture.py new file mode 100755 index 0000000..8e00800 --- /dev/null +++ b/scripts/make_fixture.py @@ -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 + Writes a ShowRecorder Show into /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 `. + +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("= 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__)