"""Streak level 6's sounds: 2 s each, one per animation in level6.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 6: 2600-2699) so the output never changes. """ import math import random from sound_kit import SR, TAU, add_noise, add_tone, bell, sbuf def scorch(): """A wingbeat, a long hissing breath in, then a roaring blast of fire that crackles away.""" b = sbuf() add_noise(b, 0.05, 0.25, 0.5, a=0.01, d=0.08, lp0=0.08, seed=2600) # the wingbeat add_tone(b, 0.05, 0.2, 70, 50, 0.4, a=0.005, d=0.07) add_noise(b, 0.35, 0.4, 0.25, a=0.35, d=0.3, lp0=0.2, lp1=0.6, seed=2601) # the breath in add_noise(b, 0.72, 1.1, 0.8, a=0.02, d=0.6, lp0=0.35, lp1=0.12, seed=2602) # the blast add_noise(b, 0.72, 1.0, 0.3, a=0.01, d=0.4, lp0=0.9, lp1=0.5, seed=2603) add_tone(b, 0.72, 1.0, 82, 58, 0.45, a=0.03, d=0.5, shape="saw", vib=(9, 0.08)) # the roar add_tone(b, 0.72, 0.9, 123, 92, 0.2, a=0.03, d=0.4, shape="saw", vib=(7, 0.06)) rng = random.Random(2604) for k in range(22): # crackles st = 1.0 + k * 0.042 + rng.uniform(0, 0.03) add_noise(b, st, 0.015, 0.25 * (1 - k / 26), a=0.0005, d=0.004, lp0=0.95, seed=2610 + k) return b def hydraulic(): """A diesel engine chugging, hydraulics whining, a crunching bite of earth, clods thudding, and a bright ta-da.""" b = sbuf() ph = 0.0 for k in range(len(b)): # the engine t = k / SR f = 38 + (8 if 0.25 < t < 1.0 else 0) ph += TAU * f / SR am = 0.55 + 0.45 * math.sin(TAU * 11 * t) b[k] += ((((ph / TAU) % 1.0) * 2 - 1) * 0.22) * am * min(1.0, t / 0.05) * min(1.0, (2.0 - t) / 0.3) add_tone(b, 0.0, 0.4, 320, 520, 0.08, a=0.05, d=0.4, shape="tri") # whine: down add_noise(b, 0.38, 0.25, 0.7, a=0.003, d=0.08, lp0=0.5, lp1=0.15, seed=2620) # the bite add_tone(b, 0.38, 0.15, 90, 50, 0.4, a=0.002, d=0.05) add_tone(b, 0.55, 0.45, 380, 700, 0.09, a=0.05, d=0.4, shape="tri") # whine: up rng = random.Random(2621) for k in range(6): # clods st = 0.7 + k * 0.08 + rng.uniform(0, 0.03) add_tone(b, st, 0.08, rng.uniform(110, 170), 60, 0.25, a=0.002, d=0.03) add_noise(b, st, 0.05, 0.15, a=0.001, d=0.015, lp0=0.3, seed=2622 + k) for k, f in enumerate((587, 784, 1175)): # the number: ta-da bell(b, 0.85 + k * 0.08, f, 0.2, 0.55) add_noise(b, 1.35, 0.4, 0.4, a=0.01, d=0.15, lp0=0.4, lp1=0.1, seed=2630) # the load dumped return b def gush(): """An underground rumble, gurgling bubbles, then a roaring rush of water and spray pattering down.""" b = sbuf() add_tone(b, 0.0, 0.7, 45, 38, 0.5, a=0.2, d=0.5) add_noise(b, 0.0, 0.7, 0.4, a=0.2, d=0.4, lp0=0.03, seed=2640) rng = random.Random(2641) for k in range(9): # gurgles f = rng.uniform(180, 420) add_tone(b, 0.08 + k * 0.065, 0.06, f, f * 2.2, 0.22, a=0.004, d=0.03) add_tone(b, 0.62, 0.2, 60, 30, 0.6, a=0.002, d=0.08) # the burst add_noise(b, 0.62, 1.38, 0.75, a=0.04, d=0.7, lp0=0.25, lp1=0.65, seed=2642) # the rush add_noise(b, 0.66, 1.2, 0.25, a=0.1, d=0.6, lp0=0.95, seed=2643) for k in range(26): # spray falling back st = 1.0 + k * 0.035 + rng.uniform(0, 0.02) f = rng.uniform(1400, 3000) add_tone(b, st, 0.03, f, f * 0.7, 0.07, a=0.001, d=0.01) return b def quarry(): """Five heavy stone blocks thud down, each a little higher, a capstone clunks on, and a bright shining chord rings out.""" b = sbuf() for k in range(5): st = 0.04 + k * 0.17 add_tone(b, st, 0.2, 70 + k * 9, 40 + k * 6, 0.6, a=0.002, d=0.07) add_noise(b, st, 0.12, 0.45, a=0.001, d=0.03, lp0=0.12, seed=2650 + k) add_noise(b, st + 0.04, 0.12, 0.08, a=0.01, d=0.05, lp0=0.7, seed=2660 + k) # grit trickling add_tone(b, 0.98, 0.12, 300, 180, 0.4, a=0.001, d=0.04) # the capstone add_noise(b, 0.98, 0.06, 0.3, a=0.001, d=0.015, lp0=0.6, seed=2670) for k, f in enumerate((523, 659, 784, 1047)): # the blaze bell(b, 1.08 + k * 0.035, f, 0.18, 0.7) add_tone(b, 1.08, 0.9, 2093, amp=0.04, a=0.2, d=0.5, vib=(6, 0.01)) return b def screech(): """Wind whistling past in a dive, a piercing raptor's scream, then great heavy wingbeats climbing away.""" b = sbuf() add_noise(b, 0.0, 0.45, 0.45, a=0.3, d=0.15, lp0=0.05, lp1=0.5, seed=2680) # the stoop for st, f0, f1, a in ((0.38, 2900, 1900, 0.3), (1.45, 2600, 1800, 0.14)): # the screams add_tone(b, st, 0.42, f0, f1, a, a=0.01, d=0.25, shape="saw", vib=(38, 0.035)) add_tone(b, st, 0.42, f0 * 0.5, f1 * 0.5, a * 0.4, a=0.01, d=0.25, shape="tri", vib=(38, 0.035)) for k in range(5): # the wingbeats st = 0.75 + k * 0.24 add_noise(b, st, 0.16, 0.6 - k * 0.06, a=0.03, d=0.05, lp0=0.07, seed=2690 + k) add_tone(b, st, 0.12, 62, 48, 0.3 - k * 0.03, a=0.02, d=0.04) return b def clank(): """A chain paying out link by link, a thundering slam of timber, and a short brassy flourish.""" b = sbuf() rng = random.Random(2697) st = 0.05 for k in range(18): # the chain f = rng.uniform(1800, 2600) add_tone(b, st, 0.05, f, amp=0.22, a=0.001, d=0.012, shape="square") add_noise(b, st, 0.03, 0.15, a=0.001, d=0.006, lp0=0.9, seed=2698) st += 0.06 - k * 0.0012 add_tone(b, 0.98, 0.35, 75, 40, 0.8, a=0.001, d=0.1) # the slam add_noise(b, 0.98, 0.3, 0.7, a=0.001, d=0.06, lp0=0.25, lp1=0.05, seed=2699) for st, chord, dur in ((1.3, (392, 523), 0.12), (1.44, (523, 659, 784), 0.55)): # ta-ra! for f in chord: add_tone(b, st, dur, f, amp=0.1, a=0.015, d=0.45, shape="saw", vib=(5, 0.005)) return b def winch(): """A motor whines up with a ratchet clicking, the cable creaks, it clunks to a stop and the sign swings, ting.""" b = sbuf() ph = 0.0 for k in range(int(SR * 1.05)): # the motor t = k / SR f = 110 + 120 * min(1.0, t / 0.5) + 15 * math.sin(TAU * 3 * t) ph += TAU * f / SR loud = min(1.0, t / 0.08) * min(1.0, (1.05 - t) / 0.05) b[k] += ((((ph / TAU) % 1.0) * 2 - 1) * 0.16 + math.sin(ph * 2) * 0.08) * loud for k in range(16): # the ratchet add_noise(b, 0.1 + k * 0.058, 0.02, 0.22, a=0.0005, d=0.005, lp0=0.85, seed=2672 + k) add_tone(b, 0.55, 0.4, 340, 300, 0.07, a=0.1, d=0.3, shape="tri", vib=(17, 0.05)) # the creak add_tone(b, 1.05, 0.15, 140, 70, 0.6, a=0.001, d=0.05) # clunk add_noise(b, 1.05, 0.08, 0.4, a=0.001, d=0.02, lp0=0.4, seed=2689) for k, f in enumerate((1568, 2093)): # ting-ting bell(b, 1.25 + k * 0.18, f, 0.22, 0.45) add_tone(b, 1.3, 0.5, 260, 230, 0.05, a=0.1, d=0.3, shape="tri", vib=(12, 0.06)) # swaying creak return b def oarstroke(): """A rowing drum and the oars' swish, a wave crashing as the ship slams down, and a deep war horn.""" b = sbuf() for k in range(3): # drum + stroke st = 0.03 + k * 0.28 add_tone(b, st, 0.2, 110, 70, 0.6, a=0.002, d=0.08) add_noise(b, st + 0.06, 0.2, 0.25, a=0.08, d=0.06, lp0=0.4, lp1=0.1, seed=2676 + k) add_noise(b, 0.85, 0.9, 0.9, a=0.01, d=0.3, lp0=0.6, lp1=0.08, seed=2679) # the crash add_tone(b, 0.85, 0.3, 70, 40, 0.5, a=0.002, d=0.1) for f, a in ((147, 0.3), (294, 0.14), (441, 0.06)): # the horn add_tone(b, 1.05, 0.95, f * 0.97, f, a, a=0.12, d=1.2, shape="saw", vib=(4, 0.006)) return b SOUNDS = [scorch, hydraulic, gush, quarry, screech, clank, winch, oarstroke]