v0.23.0: Routine, first public version
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
"""Streak level 5's sounds: 2 s each, one per animation in level5.py (same names as its ANIMS).
|
||||
|
||||
Seeds 2500-2599 (see level0_sounds.py).
|
||||
"""
|
||||
import math
|
||||
import random
|
||||
|
||||
from sound_kit import SR, TAU, add_noise, add_tone, bell, ease_off, sbuf
|
||||
|
||||
|
||||
def brass(b, st, dur, f, amp=0.1, d=0.6, vib=(5, 0.006), a=0.02):
|
||||
for ratio, g in ((1, 1.0), (2, 0.45), (3, 0.2)):
|
||||
add_tone(b, st, dur, f * ratio, amp=amp * g, a=a, d=d, shape="saw", vib=vib)
|
||||
|
||||
|
||||
def organ(b, st, dur, f, amp=0.08, d=1.5):
|
||||
for ratio, g in ((0.5, 0.6), (1, 1.0), (2, 0.5), (3, 0.25), (4, 0.2)):
|
||||
add_tone(b, st, dur, f * ratio, amp=amp * g, a=0.03, d=d)
|
||||
|
||||
|
||||
def nova():
|
||||
"""A deep throbbing swell, a sudden sucking hush, then an enormous boom that rings off into shimmer."""
|
||||
b = sbuf()
|
||||
for k in range(int(0.75 * SR)): # the swell, throbbing
|
||||
tt = k / SR
|
||||
b[k] += math.sin(TAU * (45 + 40 * tt) * tt) * 0.35 * (tt / 0.75) * (0.6 + 0.4 * math.sin(TAU * 7 * tt))
|
||||
add_noise(b, 0.0, 0.75, 0.2, a=0.7, d=0.3, lp0=0.05, lp1=0.3, seed=2500)
|
||||
add_noise(b, 0.75, 0.17, 0.3, a=0.15, d=0.05, lp0=0.9, lp1=0.2, seed=2501)
|
||||
add_tone(b, 0.75, 0.17, 400, 1600, 0.12, a=0.15, d=0.1)
|
||||
add_tone(b, 0.92, 0.7, 70, 28, 0.9, a=0.001, d=0.3)
|
||||
add_noise(b, 0.92, 1.08, 0.8, a=0.001, d=0.3, lp0=0.6, lp1=0.04, seed=2502)
|
||||
for f in (523, 659, 784, 1046):
|
||||
add_tone(b, 1.0, 1.0, f, f * 1.005, 0.06, a=0.25, d=0.6, vib=(4, 0.01))
|
||||
bell(b, 1.0, 2093, 0.08, 0.5)
|
||||
return ease_off(b, 0.35)
|
||||
|
||||
|
||||
def totality():
|
||||
"""A dimming, falling hush, a single glinting ping, then a vast bright chord like a choir."""
|
||||
b = sbuf()
|
||||
for f in (220, 262, 330):
|
||||
add_tone(b, 0.0, 0.92, f, f * 0.84, 0.08, a=0.2, d=1.0, shape="tri")
|
||||
add_noise(b, 0.0, 0.9, 0.08, a=0.3, d=0.5, lp0=0.05, seed=2510)
|
||||
bell(b, 0.92, 2637, 0.25, 0.45)
|
||||
bell(b, 0.92, 3951, 0.1, 0.3)
|
||||
rng = random.Random(2511)
|
||||
for f in (131, 196, 262, 330, 392, 523, 659): # the choir: detuned voices
|
||||
for v in range(2):
|
||||
ff = f * (1 + rng.uniform(-0.004, 0.004))
|
||||
add_tone(b, 1.0, 1.0, ff, amp=0.035, a=0.15, d=1.5, shape="saw", vib=(5 + v, 0.007))
|
||||
add_tone(b, 1.0, 1.0, ff, amp=0.04, a=0.12, d=1.5, shape="sine", vib=(5 - v, 0.006))
|
||||
return ease_off(b, 0.35)
|
||||
|
||||
|
||||
def cosmos():
|
||||
"""A deep, slowly swirling drone, wheeling glassy notes, and a bright bloom as the core lights up."""
|
||||
b = sbuf()
|
||||
for k in range(len(b)): # the drone, swirling
|
||||
tt = k / SR
|
||||
sw = 0.5 + 0.5 * math.sin(TAU * 1.5 * tt)
|
||||
b[k] += (math.sin(TAU * 55 * tt) * 0.2 + math.sin(TAU * 110.4 * tt) * 0.1 * sw
|
||||
+ math.sin(TAU * 165.2 * tt) * 0.05 * (1 - sw)) * min(1.0, tt / 0.3)
|
||||
notes = [523, 659, 784, 988, 1175, 988, 784, 659]
|
||||
for k in range(18):
|
||||
st = 0.05 + k * 0.105
|
||||
bell(b, st, notes[k % len(notes)] * (2 if k >= 9 else 1), 0.07, 0.25)
|
||||
for f in (262, 392, 523, 659, 784):
|
||||
add_tone(b, 0.5, 1.5, f, amp=0.05, a=0.3, d=1.0, vib=(3, 0.006))
|
||||
add_noise(b, 0.5, 0.6, 0.12, a=0.25, d=0.3, lp0=0.6, seed=2520)
|
||||
return ease_off(b, 0.4)
|
||||
|
||||
|
||||
def warpjump():
|
||||
"""An engine winding up higher and higher, a punching jump with a thunderclap, and a rush of light."""
|
||||
b = sbuf()
|
||||
for ratio, a in ((1, 0.25), (2.01, 0.1), (3, 0.06)):
|
||||
add_tone(b, 0.0, 0.85, 70 * ratio, 700 * ratio, a, a=0.5, d=0.5, shape="saw")
|
||||
add_noise(b, 0.25, 0.6, 0.3, a=0.55, d=0.2, lp0=0.05, lp1=0.7, seed=2530)
|
||||
add_tone(b, 0.85, 0.4, 1200, 60, 0.6, a=0.001, d=0.12)
|
||||
add_noise(b, 0.85, 0.5, 0.7, a=0.001, d=0.12, lp0=0.8, lp1=0.1, seed=2531)
|
||||
add_tone(b, 0.85, 0.5, 55, 35, 0.5, a=0.001, d=0.2)
|
||||
add_noise(b, 0.95, 1.0, 0.18, a=0.3, d=0.4, lp0=0.2, lp1=0.9, seed=2532)
|
||||
for f in (392, 587, 784, 1175):
|
||||
add_tone(b, 1.05, 0.95, f * 0.9, f, 0.06, a=0.08, d=0.6, shape="tri", vib=(6, 0.006))
|
||||
return ease_off(b, 0.3)
|
||||
|
||||
|
||||
def toccata():
|
||||
"""A rippling organ flourish, then three thundering chords, the last held huge."""
|
||||
b = sbuf()
|
||||
for k, (st, f) in enumerate(((0.0, 880), (0.07, 784), (0.14, 880), (0.26, 784), (0.31, 698),
|
||||
(0.36, 659), (0.41, 587), (0.46, 554), (0.53, 587))):
|
||||
organ(b, st, 0.1 if k < 8 else 0.25, f, 0.06, 0.4)
|
||||
for st, chord, dur in ((0.5, (73, 147, 220, 294, 349), 0.42), (1.0, (69, 139, 220, 277, 330), 0.42),
|
||||
(1.5, (73, 147, 220, 294, 370, 440), 0.5)):
|
||||
for f in chord:
|
||||
organ(b, st, dur, f, 0.05, 2.0)
|
||||
add_noise(b, st, 0.1, 0.08, a=0.01, d=0.05, lp0=0.3, seed=int(2540 + st * 10))
|
||||
return ease_off(b, 0.15)
|
||||
|
||||
|
||||
def powerchord():
|
||||
"""A count-in on the hi-hat, then a thumping kick, a huge crunching power chord and the whoosh of the pyro."""
|
||||
b = sbuf()
|
||||
for k in range(3): # count-in
|
||||
add_noise(b, 0.05 + k * 0.2, 0.05, 0.2, a=0.001, d=0.015, lp0=0.95, seed=2550 + k)
|
||||
add_tone(b, 0.05 + k * 0.2, 0.03, 1500, amp=0.06, a=0.001, d=0.01)
|
||||
g = sbuf() # the guitar, driven hard
|
||||
for f in (82.4, 123.5, 164.8):
|
||||
for det in (1.0, 1.006):
|
||||
add_tone(g, 0.67, 1.33, f * det, amp=0.5, a=0.005, d=1.2, shape="saw", vib=(5, 0.004))
|
||||
for k in range(len(b)):
|
||||
b[k] += 0.3 * math.tanh(3.0 * g[k])
|
||||
for k in range(int((2.0 - 0.67) / 0.25) + 1): # kick on the beat
|
||||
st = 0.67 + k * 0.25
|
||||
add_tone(b, st, 0.15, 120, 45, 0.6, a=0.001, d=0.05)
|
||||
add_noise(b, 0.67, 1.0, 0.35, a=0.002, d=0.35, lp0=0.95, lp1=0.6, seed=2560)
|
||||
for st in (0.67, 1.25): # pyro whoosh
|
||||
add_noise(b, st, 0.5, 0.35, a=0.03, d=0.2, lp0=0.12, lp1=0.4, seed=int(2561 + st * 10))
|
||||
return ease_off(b, 0.25)
|
||||
|
||||
|
||||
def aria():
|
||||
"""A soprano climbs to a soaring top note and holds it, until a row of glasses shatters."""
|
||||
b = sbuf()
|
||||
for k, (st, f, dur) in enumerate(((0.33, 523, 0.17), (0.5, 659, 0.17), (0.67, 784, 0.2), (0.87, 1046, 1.13))):
|
||||
vib = (5.5, 0.01 + 0.012 * (k == 3))
|
||||
for ratio, a in ((1, 0.3), (2, 0.1), (3, 0.06), (4, 0.025)):
|
||||
add_tone(b, st, dur, f * ratio, amp=a, a=0.04, d=2.0 if k == 3 else 0.5, vib=vib)
|
||||
add_tone(b, 0.0, 0.33, 196, 196, 0.08, a=0.05, d=0.2, shape="tri") # the pianist's chord before
|
||||
add_tone(b, 0.0, 0.33, 262, 262, 0.06, a=0.05, d=0.2, shape="tri")
|
||||
st = 1.08
|
||||
add_noise(b, st, 0.4, 0.5, a=0.001, d=0.08, lp0=0.95, seed=2570)
|
||||
rng = random.Random(2571)
|
||||
for k in range(24):
|
||||
add_tone(b, st + rng.uniform(0, 0.55), 0.15, rng.uniform(3000, 6000), amp=0.07, a=0.001, d=0.04)
|
||||
return ease_off(b, 0.3)
|
||||
|
||||
|
||||
def klieg():
|
||||
"""The hum of the searchlights, cameras popping and whining, then a sweeping red-carpet fanfare."""
|
||||
b = sbuf()
|
||||
for k in range(len(b)): # the arc lamps' buzz
|
||||
tt = k / SR
|
||||
b[k] += 0.05 * math.sin(TAU * 60 * tt) + 0.03 * math.sin(TAU * 120 * tt + 0.3)
|
||||
rng = random.Random(2580)
|
||||
for k in range(9): # flashbulbs: pop, then the recharge whine
|
||||
st = 0.05 + k * 0.2 + rng.uniform(0, 0.08)
|
||||
add_noise(b, st, 0.03, 0.3, a=0.0005, d=0.006, lp0=0.9, seed=2581 + k)
|
||||
add_tone(b, st + 0.02, 0.15, 2500, 5500, 0.03, a=0.02, d=0.1)
|
||||
for st, chord, dur in ((0.92, (294, 370, 440), 0.12), (1.06, (294, 370, 440), 0.12),
|
||||
(1.2, (392, 494, 587, 784), 0.8)):
|
||||
for f in chord:
|
||||
brass(b, st, dur, f, 0.07, 0.6)
|
||||
add_noise(b, 1.2, 0.8, 0.12, a=0.002, d=0.3, lp0=0.95, seed=2595)
|
||||
bell(b, 1.2, 1568, 0.08, 0.4)
|
||||
return ease_off(b, 0.3)
|
||||
|
||||
|
||||
SOUNDS = [nova, totality, cosmos, warpjump, toccata, powerchord, aria, klieg]
|
||||
Reference in New Issue
Block a user