TableTower/tools/theme_sounds/recipes.py
RobinFiredrake 61a548902f Theme tiers 1-2: theme folders, mascot recolour, background scene and tile, frame sets, picture threads, sounds; nine new built-in themes
- ThemeAssets loads a theme's files; FrameSet + GradientMap (3-stop) generalise the card frame;
  ThreadStrip draws threads from a picture; BoardBackdrop draws scene and tile; MascotArt
  recolours Morgan by role (logo SVG now uses the Keep File importer); SoundBoard plays
  roll / card turn / thread / click / ambient with View > Sound levels.
- Vaporwave, Synthwave, Cozy Autumn, Rustic, Woodsy, Sky Blue, Frutiger Aero, Gothic, Terminal:
  generated art (tools/theme_art), sounds (tools/theme_sounds), settings (tools/theme_defs).
- Ten OFL fonts; --theme=<id> flag; docs/THEMES.md format spec; test_theme_assets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:05:40 -06:00

117 lines
3.7 KiB
Python

"""The mockup's sound recipes (its `SFX` table), one function per recipe.
Each recipe takes a `Mix` and adds its sounds starting at time 0.
Where the mockup picks something at random, a fixed choice is used here
so every run gives the same audio.
"""
from synth import arpeggio, noise, tone
def harp(mix):
arpeggio(mix, 0, [392, 494, 587, 740, 880], 0.06, 0.9, wave_type="triangle", gain=0.1)
def swish(mix):
noise(mix, 0, 0.28, freq=1200, freq_end=4000, quality=0.8, gain=0.12, attack=0.08)
def dreamy(mix):
chord = [523, 659, 784, 988]
arpeggio(mix, 0, chord, 0.1, 1.5, gain=0.07, attack=0.08)
arpeggio(mix, 0, chord, 0.1, 1.5, gain=0.05, attack=0.08, detune_cents=14)
def tapestop(mix):
tone(mix, 0, 440, 0.55, wave_type="sawtooth", freq_end=90, lowpass=1400, gain=0.06)
def synth(mix):
arpeggio(mix, 0, [220, 262, 330, 440, 523, 659], 0.055, 0.22,
wave_type="sawtooth", lowpass=2200, gain=0.07)
def cassette(mix):
noise(mix, 0, 0.05, filter_type="lowpass", freq=700, gain=0.35)
tone(mix, 0.03, 90, 0.09, wave_type="square", gain=0.07, lowpass=500)
def windchime(mix):
# The mockup shuffles these five notes each time; this is one fixed shuffle.
shuffled = [523, 392, 659, 440, 587]
arpeggio(mix, 0, shuffled, 0.12, 0.7, wave_type="triangle", gain=0.11)
def rustle(mix):
noise(mix, 0, 0.22, filter_type="highpass", freq=2500, gain=0.12, attack=0.04)
noise(mix, 0.12, 0.18, filter_type="highpass", freq=3500, gain=0.08, attack=0.03)
def clack(mix):
for i, delay in enumerate([0, 0.13, 0.22]):
noise(mix, delay, 0.05, freq=1100 - i * 120, quality=6, gain=0.6)
tone(mix, delay, 170, 0.1, wave_type="triangle", gain=0.12)
def creak(mix):
tone(mix, 0, 70, 0.4, wave_type="sawtooth", freq_end=96, lowpass=420, gain=0.08, attack=0.05)
noise(mix, 0, 0.35, freq=350, quality=4, gain=0.1, attack=0.06)
def drops(mix):
for i, delay in enumerate([0, 0.16, 0.34]):
tone(mix, delay, 800 + i * 180, 0.14, freq_end=1500 + i * 200, glide=0.07, gain=0.13)
def leafswish(mix):
noise(mix, 0, 0.3, freq=700, freq_end=3000, quality=1.2, gain=0.13, attack=0.1)
def airchime(mix):
noise(mix, 0, 0.6, filter_type="lowpass", freq=500, freq_end=1500, gain=0.06, attack=0.25)
arpeggio(mix, 0.1, [1047, 1319, 1568, 2093], 0.07, 1.1, gain=0.06)
def whoosh(mix):
noise(mix, 0, 0.45, freq=350, freq_end=1600, quality=0.9, gain=0.18, attack=0.2)
def bubbles(mix):
for i, delay in enumerate([0, 0.07, 0.15, 0.24]):
tone(mix, delay, 280 + i * 60, 0.09, freq_end=900 + i * 150, glide=0.08, gain=0.1)
tone(mix, 0.32, 1568, 0.7, gain=0.06)
tone(mix, 0.36, 2093, 0.7, gain=0.05)
def tink(mix):
tone(mix, 0, 2637, 0.5, gain=0.07)
tone(mix, 0, 3951, 0.3, gain=0.04)
def bell(mix):
# Partials of a 98 Hz bell: (frequency multiple, gain, duration).
partials = [(1, 0.13, 2.6), (2, 0.06, 1.6), (2.4, 0.05, 1.4), (3, 0.04, 1), (4.2, 0.03, 0.8)]
for multiple, gain, duration in partials:
tone(mix, 0, 98 * multiple, duration, gain=gain, attack=0.004)
def scrape(mix):
noise(mix, 0, 0.6, filter_type="lowpass", freq=450, gain=0.2, attack=0.15)
def beeps(mix):
for freq, delay in [(880, 0), (1320, 0.1), (1760, 0.2)]:
tone(mix, delay, freq, 0.07, wave_type="square", gain=0.045)
def relay(mix):
noise(mix, 0, 0.02, filter_type="highpass", freq=4000, gain=0.4)
noise(mix, 0.06, 0.02, filter_type="highpass", freq=3500, gain=0.35)
RECIPES = {
recipe.__name__: recipe
for recipe in [harp, swish, dreamy, tapestop, synth, cassette, windchime, rustle,
clack, creak, drops, leafswish, airchime, whoosh, bubbles, tink,
bell, scrape, beeps, relay]
}