; Bruce A. Maxwell ; January 2015 ; ; Example instruments using random values for some game noises ; -g -W -o sampleSounds.aif ; an instrument that sounds somthing like a shot ; ; white noise with a spline envelope instr 1 ; create a linear indexer kndx line 0, p3, 1 ; index into the bell-shape table kenv table kndx, 4, 1 k1 linen 1, 0, p3, 0.3*p3 a1 oscil p4*kenv*0.5*k1, 1, 3 a2 oscil p4*kenv*0.1*k1, 10, 1 a3 oscil p4*kenv*0.1*k1, 20, 1 a4 oscil p4*kenv*0.1*k1, 40, 1 a5 oscil p4*kenv*0.1*k1, 60, 1 a6 oscil p4*kenv*0.1*k1, 80, 1 aout = a1+a2+a3+a4+a5+a6 out aout endin ; an instrument that sounds something like an explosion ; ; several white noise oscillators with different envelopes ; instr 2 ; create a linear indexer kndx line 0, p3, 1 ; index into the bell-shape table kenv table kndx, 4, 1 ;; add some additional shaping ; first envelope starts fast k1 linen 1, 0.05*p3, p3, 0.45*p3 ; second envelope starts a little later k2 linen 1, 0.2*p3, p3, 0.5*p3 ; third envelope is faster k3 linen 1, 0.02*p3, p3, 0.2*p3 a10 oscil p4*k1*0.3*kenv, 0.5, 3 a11 oscil p4*k1*0.4*kenv, 40, 1 a12 oscil p4*k1*0.4*kenv, 60, 1 a13 oscil p4*k1*0.4*kenv, 20, 1 a20 oscil p4*k2*0.2*kenv, 1, 2 a21 oscil p4*k2*0.4*kenv, 30, 1 a22 oscil p4*k2*0.4*kenv, 50, 1 a30 oscil p4*k3*0.1*kenv, 2, 2 a31 oscil p4*k3*0.4*kenv, 30, 1 a32 oscil p4*k3*0.4*kenv, 45, 1 aout = a10+a11+a12+a13+a20+a21+a22+a30+a31+a32 out aout endin ; an instrument that sounds like a swish instr 3 ; envelope k1 linen 1, 0.3*p3, p3, 0.3*p3 a1 oscil p4*k1*0.5, 1, 3 a2 oscil p4*k1*0.5, 1, 2 aout = a1 + a2 out aout endin ; function tables here, these are reference shapes ; function table 1: a sine wave ; table number, start time, size (power of 2), function type, harmonic partials f 1 0 8192 10 1 ; function table 2: Gaussian noise (range [-1, 1]) f 2 0 4096 21 6 1 ; function table 3: uniform noise (range [0, 1]) f 3 0 4096 21 1 1 ; function table 4: spline that rises quickly and falls slowly f 4 0 1025 8 0.5 32 1 64 0.5 128 0.25 512 0.01 160 0.0 ; Note Instr Start Dur(p3) Amp(p4) ; swish i 3 0 0.4 10000 ; explosion i 2 1 1.3 32000 ; shot i 1 3 0.4 30000