-dW -o spiral.wav ; Setup sr = 44100 ; Sample rate kr = 4410 ; Control rate (k-rate) nchnls = 1 ; One channel ; Variables giMax = 32767 ; Maximum amplitude ;---------------------------------------------- ; Infinite loop 1 ; This instrument outputs a down-looping sound ; for a given period of time, with a small ; fade-in, fade-out envelope. ; ; - p4 : base frequency ; - p5 : Duration of one octave slide (seconds) instr 1 iBaseFreq = p4 iDuration = p5 iFrequency = 1 / iDuration kPhase phasor iFrequency, 0 kFreq1 = iBaseFreq / powoftwo(kPhase) kFreq2 = kFreq1 * 2 kFreq3 = kFreq1 * 4 kEnv1 table (kPhase + 2) / 3, 2, 1, 0, 1 kEnv2 table (kPhase + 1) / 3, 2, 1, 0, 1 kEnv3 table (kPhase + 0) / 3, 2, 1, 0, 1 a1 oscil giMax * kEnv1, kFreq1, 1 a2 oscil giMax * kEnv2, kFreq2, 1 a3 oscil giMax * kEnv3, kFreq3, 1 ; Overall envelope kEnv linseg 0, 1, 1, p3 - 2, 1, 1, 0 aout = kEnv * (a1 + a2 + a3) / 3 out aout endin ;---------------------------------------------- ; Infinite loop 2 ; This instrument outputs a single down-sliding ; sinewave with an amplitude envelope, making ; it suitable for a cascading suite of several ; tones. ; ; - p4 : base frequency ; - p5 : Duration of one three-octave slide (seconds) instr 2 iBaseFreq = p4 iDuration = p5 kIndex line 0, iDuration, 3 kFreq = iBaseFreq / powoftwo(kIndex) kEnv table (kIndex / 3), 2, 1, 0, 1 asine oscil giMax * kEnv / 3, kFreq, 1 out asine endin ; Tables f1 0 16384 10 1 ; Sinewave f2 0 257 20 2 1 ; Amplitude envelope ; Score ; First spiral (30 seconds) i1 0 30 110 10 ; Second spiral (80 seconds) i2 35 30 440 30 i2 45 30 440 30 i2 55 30 440 30 i2 65 30 440 30 i2 75 30 440 30 i2 85 30 440 30 e