"""Streak level 1's sounds: 2 s each, one per animation in level1.py (same names as its ANIMS). Seeds 2100-2199. """ 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 buzz(b, start, dur, f, amp=0.2, vib=(0, 0), seed=0): """A reedy, buzzy note (a kazoo-ish saw with a touch of breath).""" for ratio, a in ((1, 1.0), (2, 0.5), (3, 0.3)): add_tone(b, start, dur, f * ratio, amp=amp * a, a=0.02, d=2.0, shape="saw", vib=vib) add_noise(b, start, dur, amp * 0.25, a=0.02, d=1.0, lp0=0.5, seed=seed) @tail def dingaling(): """A wind-up, a hefty THWACK, a slide whistle racing up, a bright bell ringing out, and a slide back down.""" b = sbuf() add_noise(b, 0.05, 0.45, 0.12, a=0.3, d=0.2, lp0=0.2, lp1=0.6, seed=2100) add_tone(b, 0.58, 0.2, 140, 55, 0.9, a=0.001, d=0.06) add_noise(b, 0.58, 0.12, 0.7, a=0.001, d=0.03, lp0=0.4, seed=2101) add_tone(b, 0.6, 0.33, 500, 1900, 0.18, a=0.01, d=1.0, shape="tri") for st in (0.92, 1.12, 1.3): bell(b, st, 1320, 0.32 if st < 1 else 0.18, 0.7) add_tone(b, 1.45, 0.5, 1500, 400, 0.08, a=0.05, d=0.6, shape="tri") return b @tail def swoosh(): """Two bounces, a rising whoosh as the ball arcs, a soft net SWISH, a scoreboard buzzer, then the ball dribbling away.""" b = sbuf() add_tone(b, 0.02, 0.12, 130, 80, 0.5, a=0.001, d=0.04) add_noise(b, 0.15, 0.6, 0.18, a=0.3, d=0.4, lp0=0.15, lp1=0.5, seed=2110) add_noise(b, 0.83, 0.3, 0.55, a=0.01, d=0.08, lp0=0.95, lp1=0.6, seed=2111) for f in (440, 554, 659): add_tone(b, 0.88, 0.5, f, amp=0.1, a=0.005, d=1.0, shape="square") for k, st in enumerate((1.08, 1.42, 1.58, 1.72, 1.82)): add_tone(b, st, 0.1, 150, 85, 0.5 - k * 0.07, a=0.001, d=0.035) add_noise(b, st, 0.04, 0.2 - k * 0.03, a=0.001, d=0.01, lp0=0.3, seed=2112 + k) return b @tail def pinfall(): """A heavy ball rumbling down the lane, a great clattering crash of pins, and a two-note ding of triumph.""" b = sbuf() add_noise(b, 0.0, 0.7, 0.3, a=0.25, d=1.0, lp0=0.03, lp1=0.08, seed=2120) add_tone(b, 0.0, 0.7, 55, 70, 0.25, a=0.25, d=1.0) add_noise(b, 0.67, 0.4, 0.7, a=0.001, d=0.12, lp0=0.6, lp1=0.2, seed=2121) rng = random.Random(2122) for k in range(22): st = 0.67 + rng.uniform(0, 0.45) * (k / 22) ** 0.6 f = rng.uniform(600, 1500) add_tone(b, st, 0.06, f, f * 0.9, 0.18, a=0.001, d=0.02) add_tone(b, st, 0.05, f * 2.3, amp=0.06, a=0.001, d=0.01) bell(b, 1.3, 1047, 0.25, 0.4) bell(b, 1.45, 1568, 0.3, 0.6) return b @tail def crankle(): """A crank ratchets round, click by click; a capsule clunks down the chute and rattles off, then pops open with a springy boing and a sparkle.""" b = sbuf() for k in range(5): for m in range(3): st = k * 0.167 + m * 0.035 add_noise(b, st, 0.02, 0.35, a=0.001, d=0.005, lp0=0.8, seed=2130 + k * 3 + m) add_tone(b, st, 0.02, 2200, amp=0.06, a=0.001, d=0.006) add_tone(b, 0.7, 0.12, 200, 120, 0.6, a=0.001, d=0.04) for k in range(9): st = 0.78 + k * 0.045 add_tone(b, st, 0.03, 600 + 40 * (k % 3), amp=0.15 - k * 0.012, a=0.001, d=0.012) add_tone(b, 1.33, 0.07, 900, 300, 0.6, a=0.0005, d=0.02) add_tone(b, 1.35, 0.45, 220, 660, 0.25, a=0.005, d=0.4, vib=(18, 0.08)) rng = random.Random(2150) for k in range(6): bell(b, 1.45 + k * 0.06, rng.uniform(2600, 3600), 0.08, 0.15) return b @tail def arf(): """A little bark, a whoosh as the ball is flipped up, a pop, a soft plonk on the nose, then happy barking over flipper claps.""" b = sbuf() def bark(st, f, amp): for ratio, a in ((1, 1.0), (2, 0.6), (3, 0.4), (4, 0.2)): add_tone(b, st, 0.16, f * ratio, f * ratio * 0.7, amp * a, a=0.01, d=0.07, shape="saw") add_noise(b, st, 0.1, amp * 0.5, a=0.005, d=0.04, lp0=0.35, seed=int(st * 1000) + 2160) bark(0.1, 330, 0.35) add_noise(b, 0.45, 0.4, 0.2, a=0.1, d=0.3, lp0=0.2, lp1=0.6, seed=2161) add_tone(b, 0.92, 0.06, 1200, 400, 0.4, a=0.0005, d=0.02) add_tone(b, 1.25, 0.1, 500, 380, 0.4, a=0.001, d=0.04, shape="tri") for k, st in enumerate((1.35, 1.6, 1.82)): bark(st, 360 + 30 * k, 0.32) for k in range(5): add_noise(b, 1.28 + k * 0.17, 0.05, 0.4, a=0.001, d=0.015, lp0=0.7, seed=2170 + k) return b @tail def slinkety(): """Three metallic shimmy-clinks as the coil flops down step by step, then a long springy BOI-OING and a pop.""" b = sbuf() for k, st in enumerate((0.08, 0.5, 0.92)): add_tone(b, st, 0.3, 900 + 80 * k, 2200 + 80 * k, 0.08, a=0.05, d=0.2, vib=(30, 0.05)) land = st + 0.3 for m in range(4): add_tone(b, land + m * 0.025, 0.12, 3100 - m * 300, amp=0.12 - m * 0.02, a=0.001, d=0.03) add_tone(b, land, 0.1, 180, 120, 0.3, a=0.001, d=0.03) add_tone(b, 1.3, 0.6, 180, 520, 0.4, a=0.005, d=0.35, vib=(16, 0.12)) add_tone(b, 1.3, 0.6, 360, 1040, 0.12, a=0.005, d=0.3, vib=(16, 0.12), shape="tri") add_tone(b, 1.42, 0.06, 1400, 500, 0.4, a=0.0005, d=0.02) rng = random.Random(2185) for k in range(5): bell(b, 1.5 + k * 0.07, rng.uniform(2200, 3200), 0.07, 0.15) return b @tail def unwrap(): """Two papery hops, a big pop as the lid flies, a flurry of rising squeals from the streamers, and a bright ta-da.""" b = sbuf() for k, st in enumerate((0.33, 0.71)): add_tone(b, st, 0.12, 180, 110, 0.4, a=0.001, d=0.04) add_noise(b, st, 0.15, 0.3, a=0.003, d=0.06, lp0=0.7, seed=2140 + k) add_tone(b, 1.0, 0.08, 1300, 350, 0.6, a=0.0005, d=0.02) add_noise(b, 1.0, 0.1, 0.5, a=0.0005, d=0.03, lp0=0.9, seed=2143) rng = random.Random(2144) for k in range(7): f = rng.uniform(700, 1100) add_tone(b, 1.03 + k * 0.04, 0.3, f, f * 2.2, 0.08, a=0.01, d=0.2, vib=(25, 0.03)) for f in (523, 659, 784, 1047): add_tone(b, 1.3, 0.65, f, amp=0.09, a=0.01, d=0.5, shape="tri", vib=(5, 0.005)) return b @tail def razz(): """A party blower's raspy toot as it unrolls, half back, then one long proud BLAAAT and a little twinkle.""" b = sbuf() buzz(b, 0.15, 0.38, 392, 0.25, vib=(9, 0.02), seed=2190) add_tone(b, 0.5, 0.12, 392, 330, 0.05, a=0.01, d=0.05, shape="saw") buzz(b, 0.72, 0.95, 523, 0.3, vib=(7, 0.025), seed=2191) for k in range(4): bell(b, 1.75 + k * 0.05, 2400 + k * 400, 0.06, 0.12) return b SOUNDS = [dingaling, swoosh, pinfall, crankle, arf, slinkety, unwrap, razz]