"""Streak level 3's sounds: 2 s each, one per animation in level3.py (same names as its ANIMS). Seeds 2300-2399. """ import functools import random from sound_kit import add_noise, add_tone, bell, ease_off, sbuf def tail(fn): """Soften the last quarter second, so nothing still ringing stops dead at 2 s.""" @functools.wraps(fn) def wrapped(): return ease_off(fn(), 0.25) return wrapped def crackles(b, start, dur, rate, amp, seed, f=(2500, 6000)): """Random tiny clicks: fizz, sparks, crackling fireworks.""" rng = random.Random(seed) for _ in range(int(dur * rate)): st = start + rng.uniform(0, dur) add_tone(b, st, 0.012, rng.uniform(*f), amp=amp * rng.uniform(0.3, 1.0), a=0.0005, d=0.003) def pop(b, st, amp, seed): """A firework's thump and crackle.""" add_tone(b, st, 0.15, 160, 60, amp, a=0.001, d=0.05) add_noise(b, st, 0.25, amp * 0.7, a=0.001, d=0.06, lp0=0.6, lp1=0.2, seed=seed) crackles(b, st + 0.05, 0.4, 60, amp * 0.4, seed + 1) def organ(b, st, dur, f, amp): """A steam-organ pipe: square and triangle, with a wobble.""" add_tone(b, st, dur, f, amp=amp, a=0.01, d=0.5, shape="square", vib=(6, 0.008)) add_tone(b, st, dur, f * 2, amp=amp * 0.4, a=0.01, d=0.5, shape="tri", vib=(6, 0.008)) @tail def skyride(): """The big wheel creaks round while its lights tinkle on, climbing; fireworks thump behind it and a bright chord rings out as the hub lights up.""" b = sbuf() for k in range(3): add_tone(b, 0.05 + k * 0.25, 0.2, 180, 150, 0.08, a=0.05, d=0.1, shape="saw", vib=(30, 0.05)) for k, f in enumerate((784, 880, 988, 1175, 1319, 1568, 1760, 2093)): bell(b, 0.5 + k * 0.035, f, 0.1, 0.2) for f in (523, 659, 784, 1047): add_tone(b, 0.75, 1.2, f, amp=0.1, a=0.02, d=0.8, shape="tri", vib=(5, 0.006)) for k in range(4): pop(b, 0.67 + k * 0.25, 0.35, 2300 + 10 * k) return b @tail def clackety(): """The chain lift clacking up, a breathless pause, a roaring plunge round the loop with whoops, then fireworks and a cheer.""" b = sbuf() for k in range(14): # the chain st = 0.02 + k * 0.038 add_noise(b, st, 0.02, 0.35, a=0.0005, d=0.006, lp0=0.6, seed=2340 + k) add_tone(b, st, 0.02, 900, amp=0.08, a=0.0005, d=0.006) add_noise(b, 0.6, 0.9, 0.5, a=0.15, d=0.6, lp0=0.08, lp1=0.25, seed=2360) add_tone(b, 0.6, 0.9, 70, 110, 0.35, a=0.15, d=0.6, shape="saw") rng = random.Random(2361) for k in range(4): # whoops from the riders f = rng.uniform(700, 1000) add_tone(b, 0.65 + k * 0.12, 0.4, f, f * 1.5, 0.07, a=0.03, d=0.3, vib=(8, 0.04)) for k in range(3): pop(b, 1.08 + k * 0.17, 0.35, 2370 + 10 * k) add_noise(b, 1.1, 0.9, 0.15, a=0.2, d=0.8, lp0=0.2, seed=2399) return b @tail def hupla(): """A soft drumroll under two swinging whooshes, a sharp HUP, three somersault swishes, a slap as hands catch, and a cymbal and ta-da.""" b = sbuf() for k in range(13): add_noise(b, k * 0.04, 0.04, 0.08 + 0.006 * k, a=0.001, d=0.015, lp0=0.5, seed=2310 + k) for st in (0.0, 0.3): add_noise(b, st, 0.3, 0.2, a=0.12, d=0.12, lp0=0.15, lp1=0.4, seed=2330) for ratio, a in ((1, 1.0), (2, 0.5), (3, 0.3)): # the hup add_tone(b, 0.5, 0.1, 400 * ratio, 520 * ratio, 0.18 * a, a=0.005, d=0.05, shape="saw") for k in range(3): add_noise(b, 0.58 + k * 0.17, 0.15, 0.25, a=0.05, d=0.05, lp0=0.3, lp1=0.8, seed=2335 + k) add_noise(b, 1.08, 0.05, 0.6, a=0.0005, d=0.012, lp0=0.7, seed=2339) add_noise(b, 1.12, 0.85, 0.35, a=0.002, d=0.35, lp0=0.95, lp1=0.6, seed=2338) for f in (3200, 4700): add_tone(b, 1.12, 0.8, f, amp=0.04, a=0.002, d=0.3) for st, chord, dur in ((1.12, (392, 494, 587), 0.15), (1.3, (523, 659, 784), 0.65)): for f in chord: add_tone(b, st, dur, f, amp=0.1, a=0.01, d=0.5, shape="saw", vib=(5, 0.006)) return b @tail def photofinish(): """A starter's pistol, pounding footsteps getting faster, the tape snapping, then cheering, camera shutters and flashguns whining.""" b = sbuf() add_noise(b, 0.0, 0.2, 0.8, a=0.0005, d=0.04, lp0=0.9, lp1=0.3, seed=2350) st, k = 0.1, 0 while st < 0.74: add_tone(b, st, 0.06, 110, 70, 0.4, a=0.001, d=0.02) add_noise(b, st, 0.03, 0.2, a=0.001, d=0.01, lp0=0.3, seed=2351 + k) st += 0.11 - 0.004 * k k += 1 add_tone(b, 0.75, 0.06, 1500, 600, 0.4, a=0.0005, d=0.015) add_noise(b, 0.75, 0.08, 0.5, a=0.0005, d=0.02, lp0=0.95, seed=2372) for k in range(5): add_noise(b, 0.78 + k * 0.03, 1.2, 0.13, a=0.25, d=1.5, lp0=0.12 + 0.05 * k, seed=2373 + k) rng = random.Random(2380) for k in range(6): # shutters and flash whines st = 0.8 + k * 0.18 + rng.uniform(0, 0.05) add_noise(b, st, 0.03, 0.4, a=0.0005, d=0.008, lp0=0.8, seed=2381 + k) add_tone(b, st + 0.02, 0.2, 2500, 4500, 0.04, a=0.02, d=0.2) return b @tail def calliope(): """A steam-organ waltz, oom-pah-pah under a jolly tune, then fireworks bursting overhead.""" b = sbuf() beat = 0.19 bass = [131, 196, 196, 147, 220, 220, 131, 196, 196, 165, 247, 247] for k, f in enumerate(bass[:10]): organ(b, k * beat, beat * 0.8, f if k % 3 == 0 else f * 2, 0.08 if k % 3 == 0 else 0.05) tune = [(0, 659, 2), (2, 784, 1), (3, 880, 2), (5, 784, 1), (6, 1047, 3), (9, 988, 1)] for st, f, n in tune: organ(b, st * beat, n * beat * 0.92, f, 0.09) for f in (523, 659, 784): organ(b, 10 * beat, 0.4, f, 0.07) for k in range(3): pop(b, 0.83 + k * 0.17, 0.3, 2320 + 10 * k) return b @tail def airhorn(): """A thumping kick, a whistle up and over, then a blaring stadium air horn, twice, and fireworks.""" b = sbuf() add_tone(b, 0.25, 0.12, 120, 55, 0.8, a=0.001, d=0.04) add_noise(b, 0.25, 0.06, 0.5, a=0.0005, d=0.015, lp0=0.4, seed=2390) add_tone(b, 0.3, 0.55, 600, 1400, 0.08, a=0.05, d=0.5, shape="tri") for st, dur in ((0.83, 0.25), (1.15, 0.6)): for f in (466, 587, 698): for ratio, a in ((1, 1.0), (2, 0.4)): add_tone(b, st, dur, f * ratio, f * ratio * 0.99, 0.1 * a, a=0.01, d=1.0, shape="saw") for k in range(4): pop(b, 0.9 + k * 0.17, 0.3, 2391 + k) return b @tail def tossup(): """Clubs and balls slapping hand to hand, faster and faster, a big whoosh as everything flies up, a slide whistle, and a ringing catch with bells whirling round.""" b = sbuf() st, k = 0.05, 0 while st < 1.12: f = 500 if k % 2 else 380 add_tone(b, st, 0.05, f, f * 0.8, 0.25, a=0.001, d=0.02) add_noise(b, st, 0.03, 0.15, a=0.001, d=0.01, lp0=0.4, seed=2315 + k) st += max(0.07, 0.17 - 0.008 * k) k += 1 add_noise(b, 1.15, 0.35, 0.35, a=0.03, d=0.2, lp0=0.2, lp1=0.8, seed=2398) add_tone(b, 1.15, 0.3, 500, 1500, 0.12, a=0.02, d=0.4, shape="tri") bell(b, 1.27, 1568, 0.3, 0.6) for k in range(8): bell(b, 1.35 + k * 0.07, [1319, 1568, 1760, 2093][k % 4], 0.08, 0.2) return b @tail def kersplash(): """A throw, a clanging bullseye, the plank's clunk, a long fall, a huge SPLOOSH with drops raining down, and a honk of the clown's horn.""" b = sbuf() add_noise(b, 0.05, 0.35, 0.15, a=0.1, d=0.2, lp0=0.2, lp1=0.6, seed=2325) bell(b, 0.42, 880, 0.35, 0.35) add_noise(b, 0.42, 0.05, 0.4, a=0.0005, d=0.01, lp0=0.7, seed=2326) add_tone(b, 0.55, 0.1, 200, 110, 0.5, a=0.001, d=0.03) add_tone(b, 0.6, 0.2, 900, 400, 0.08, a=0.01, d=0.2, shape="tri") add_noise(b, 0.75, 0.6, 0.9, a=0.003, d=0.2, lp0=0.5, lp1=0.1, seed=2327) add_tone(b, 0.75, 0.25, 90, 45, 0.6, a=0.002, d=0.1) rng = random.Random(2328) for k in range(16): # drops falling back st = 0.95 + rng.uniform(0, 0.6) f = rng.uniform(700, 1600) add_tone(b, st, 0.05, f, f * 1.7, 0.1, a=0.002, d=0.02) for st in (1.35, 1.55): for ratio, a in ((1, 1.0), (2, 0.5), (3, 0.3)): add_tone(b, st, 0.15, 330 * ratio, 300 * ratio, 0.15 * a, a=0.005, d=0.1, shape="saw") return b SOUNDS = [skyride, clackety, hupla, photofinish, calliope, airhorn, tossup, kersplash]