"""Streak level 7's sounds: 2 s each, one per animation in level7.py (same names as its ANIMS). Each fn() returns a buf from tools/sound_kit.py; gen_sounds.py normalises and writes it as .wav. Every random source is seeded (level 7: 2700-2799) so the output never changes. """ import math import random from sound_kit import SR, TAU, add_noise, add_pluck, add_tone, bell, sbuf def ignite(): """Embers ticking, a great WHOOMPH of flame, a soaring bird's cry over the roar, and a shimmering chord.""" b = sbuf() rng = random.Random(2700) for k in range(10): # embers add_noise(b, 0.02 + k * 0.045 + rng.uniform(0, 0.02), 0.012, 0.2, a=0.0005, d=0.004, lp0=0.95, seed=2701 + k) add_noise(b, 0.3, 0.3, 0.3, a=0.25, d=0.2, lp0=0.05, lp1=0.4, seed=2711) # the flames rise add_noise(b, 0.55, 1.45, 0.75, a=0.01, d=0.5, lp0=0.4, lp1=0.1, seed=2712) # WHOOMPH add_tone(b, 0.55, 0.5, 70, 40, 0.6, a=0.005, d=0.2) add_tone(b, 0.68, 0.7, 900, 1800, 0.18, a=0.06, d=0.6, vib=(9, 0.03)) # the cry, soaring add_tone(b, 0.68, 0.7, 1800, 3600, 0.05, a=0.06, d=0.5, vib=(9, 0.03)) for k, f in enumerate((587, 740, 880, 1175)): # the shimmer bell(b, 1.05 + k * 0.06, f, 0.16, 0.7) add_tone(b, 1.05, 0.95, 1760, amp=0.04, a=0.2, d=0.6, vib=(7, 0.012)) return b def toll(): """Clockwork whirring faster and faster, a click as the hands stop, then a great deep bell tolls twice.""" b = sbuf() st, gap = 0.12, 0.09 while st < 1.04: # the hands racing add_tone(b, st, 0.02, 3200, amp=0.12, a=0.0005, d=0.005, shape="square") add_noise(b, st, 0.015, 0.1, a=0.0005, d=0.004, lp0=0.9, seed=int(st * 1000) % 50 + 2720) st += gap gap = max(0.028, gap * 0.9) add_tone(b, 1.08, 0.04, 1500, 900, 0.4, a=0.0005, d=0.01) # click: stopped for st, f, a in ((1.17, 196, 0.5), (1.58, 196, 0.32)): # BONG ... BONG for ratio, amp, d in ((0.5, 0.6, 1.2), (1, 1.0, 0.9), (1.19, 0.45, 0.7), (1.5, 0.3, 0.6), (2.0, 0.35, 0.5), (2.74, 0.2, 0.35)): add_tone(b, st, 2.0 - st, f * ratio, amp=a * amp, a=0.003, d=d) add_noise(b, st, 0.05, 0.2 * a, a=0.0005, d=0.01, lp0=0.5, seed=2780 + int(st * 10)) return b def keystone(): """Stones clacking into place, pair by pair and rising in pitch, the keystone's huge thud, and a swelling brass chord.""" b = sbuf() for k, st in enumerate((0.25, 0.42, 0.58, 0.75)): for d in (0.0, 0.03): add_tone(b, st + d, 0.08, 500 + k * 90, 300 + k * 60, 0.3, a=0.001, d=0.025) add_noise(b, st + d, 0.05, 0.25, a=0.001, d=0.012, lp0=0.6, seed=2730 + k * 2 + int(d * 100)) add_noise(b, 0.85, 0.15, 0.2, a=0.1, d=0.05, lp0=0.3, lp1=0.6, seed=2740) # it whistles down add_tone(b, 1.0, 0.4, 85, 38, 0.9, a=0.001, d=0.13) # the keystone: THUD add_noise(b, 1.0, 0.35, 0.7, a=0.001, d=0.07, lp0=0.25, lp1=0.04, seed=2741) for f in (262, 330, 392, 523): # the glory chord add_tone(b, 1.12, 0.88, f, amp=0.09, a=0.15, d=0.9, shape="saw", vib=(5, 0.005)) return b def calving(): """Ice cracking like gunshots, a long groan, a colossal splash, then glassy chimes as the iceberg bobs up.""" b = sbuf() for k, st in enumerate((0.08, 0.22, 0.31, 0.47, 0.55)): # cracks add_noise(b, st, 0.05, 0.6, a=0.0005, d=0.01, lp0=0.95, seed=2750 + k) add_tone(b, st, 0.04, 1200, 400, 0.2, a=0.0005, d=0.012) add_tone(b, 0.4, 0.5, 90, 55, 0.25, a=0.1, d=0.4, shape="saw", vib=(6, 0.05)) # the groan add_noise(b, 0.85, 1.15, 0.9, a=0.008, d=0.35, lp0=0.55, lp1=0.06, seed=2756) # the splash add_tone(b, 0.85, 0.5, 60, 32, 0.6, a=0.003, d=0.2) rng = random.Random(2757) for k in range(14): # falling spray st = 1.0 + k * 0.03 + rng.uniform(0, 0.02) add_noise(b, st, 0.02, 0.15, a=0.001, d=0.006, lp0=0.8, seed=2760 + k) for k, f in enumerate((2093, 2637, 3136, 2349)): # glassy ice chimes bell(b, 1.2 + k * 0.13, f, 0.14, 0.4) return b def gallop(): """Galloping hooves, a leap, great wingbeats and a whinny, then a long glittering run of stars.""" b = sbuf() for k in range(3): # ba-da-dum, ba-da-dum for d in (0.0, 0.06, 0.12): st = 0.03 + k * 0.19 + d add_tone(b, st, 0.06, 240 - d * 400, 130, 0.35, a=0.001, d=0.02) add_noise(b, st, 0.03, 0.25, a=0.001, d=0.008, lp0=0.4, seed=2765 + k) add_noise(b, 0.58, 0.3, 0.35, a=0.1, d=0.1, lp0=0.1, lp1=0.5, seed=2768) # the leap for k in range(3): # wingbeats add_noise(b, 0.7 + k * 0.25, 0.15, 0.4, a=0.03, d=0.05, lp0=0.08, seed=2769 + k) add_tone(b, 0.75, 0.55, 900, 500, 0.15, a=0.03, d=0.35, shape="saw", vib=(14, 0.06)) # the whinny add_tone(b, 0.75, 0.55, 1350, 750, 0.05, a=0.03, d=0.3, vib=(14, 0.06)) scale = (784, 880, 988, 1175, 1319, 1568, 1760, 1976, 2349, 2637) for k, f in enumerate(scale): # stars bell(b, 1.0 + k * 0.06, f, 0.12, 0.35) return b def cascade(): """The thunder of falling water swelling up, a harp sweep as the curtain parts, and a bright chord ringing out.""" b = sbuf() add_noise(b, 0.0, 2.0, 0.6, a=0.35, d=1.2, lp0=0.3, lp1=0.45, seed=2780) # the roar add_noise(b, 0.0, 2.0, 0.25, a=0.3, d=1.2, lp0=0.04, seed=2781) rng = random.Random(2782) for k in range(18): # droplets f = rng.uniform(700, 1600) add_tone(b, 0.25 + k * 0.08 + rng.uniform(0, 0.04), 0.04, f, f * 1.5, 0.06, a=0.002, d=0.015) harp = (196, 247, 294, 392, 494, 587, 784, 988, 1175) for k, f in enumerate(harp): # the curtain parts add_pluck(b, 0.82 + k * 0.035, f, dur=1.1, amp=0.25, seed=2783 + k, damp=0.997) for f in (392, 494, 587, 784): # and it shines bell(b, 1.12, f, 0.13, 0.7) return b def quake(): """A deep rumble, boulders thudding together one by one, a grinding heave, then an enormous boom and a low triumphant horn.""" b = sbuf() add_noise(b, 0.0, 1.2, 0.5, a=0.15, d=0.8, lp0=0.03, seed=2785) # the rumble add_tone(b, 0.0, 1.0, 40, 33, 0.4, a=0.15, d=0.7) for k, st in enumerate((0.25, 0.33, 0.42, 0.58)): # blocks landing add_tone(b, st, 0.15, 110 - k * 8, 50, 0.55, a=0.001, d=0.05) add_noise(b, st, 0.1, 0.4, a=0.001, d=0.025, lp0=0.25, seed=2786 + k) add_tone(b, 0.8, 0.3, 70, 110, 0.15, a=0.05, d=0.2, shape="saw", vib=(18, 0.08)) # the heave add_noise(b, 1.08, 0.92, 0.9, a=0.002, d=0.25, lp0=0.4, lp1=0.03, seed=2790) # BOOM add_tone(b, 1.08, 0.6, 60, 28, 0.9, a=0.002, d=0.25) for f, a in ((110, 0.22), (165, 0.14), (220, 0.1)): # the horn add_tone(b, 1.2, 0.8, f, amp=a, a=0.08, d=0.8, shape="saw", vib=(4, 0.006)) return b def wisp(): """Three quick rubs on brass, a swirling whoosh of smoke, and a twinkling, exotic run of bells as the wish is granted.""" b = sbuf() for k in range(3): # rub, rub, rub add_tone(b, 0.05 + k * 0.1, 0.07, 1400, 1700, 0.12, a=0.01, d=0.03, shape="tri") add_noise(b, 0.05 + k * 0.1, 0.07, 0.12, a=0.01, d=0.03, lp0=0.8, seed=2792 + k) ph = 0.0 rng = random.Random(2795) y = 0.0 for k in range(int(SR * 0.85)): # the swirl of smoke t = k / SR c = 0.06 + 0.25 * (0.5 + 0.5 * math.sin(TAU * 4 * t)) y += c * (rng.uniform(-1, 1) - y) loud = min(1.0, t / 0.25) * min(1.0, (0.85 - t) / 0.2) b[int(0.3 * SR) + k] += y * 0.6 * loud ph += TAU * (300 + 500 * t / 0.85) / SR b[int(0.3 * SR) + k] += math.sin(ph) * 0.06 * loud run = (587, 622, 740, 784, 880, 932, 1109, 1175, 1480) # a hijaz-ish run for k, f in enumerate(run): bell(b, 1.08 + k * 0.05, f, 0.15, 0.4) add_tone(b, 1.08, 0.9, 2349, amp=0.05, a=0.1, d=0.5, vib=(8, 0.015)) return b SOUNDS = [ignite, toll, keystone, calving, gallop, cascade, quake, wisp]