Mark Van Peteghem 44100 1 2 44100 1 2 true false false false true true true true false false true true true true false false 0 false Sine giSineFunc ftgen 1, 0, 65536, 10, 1 iDur init p3 iVol init p4 iStartPitch init p5 iEndPitch init p6 iAttack init p7 iDecay init iDur - iAttack iPanStart init p8 iPanEnd init p9 ;***** SYNTH SECTION ***** kEnv linseg 0, iAttack, iVol, iDecay, 0 kPitch expseg iStartPitch, iDur, iEndPitch aSig oscili kEnv, kPitch, giSineFunc kPan linseg iPanStart, iDur, iPanEnd aLeft = aSig * kPan aRight = aSig * (1 - kPan) outs aLeft, aRight false 0.0 1 Master 0.0 false false Schroeder Reverb true 2 2 irvt = <reverbTime> ilptcmb = <combLoop> ilptap1 = <loopDel1> ilptap2 = <loopDel2> idrymix = <dryMix> icutoff = <cutoff> ;comb filters adel delayr ilptcmb*2 acomb1 deltapi ilptcmb afilt1 tone acomb1, icutoff afilt1 balance afilt1, acomb1 igain1 pow .001, ilptcmb/irvt acomb2 deltapi ilptcmb*1.7 afilt2 tone acomb2, icutoff afilt2 balance afilt2, acomb2 igain2 pow .001, (ilptcmb*1.7)/irvt acomb3 deltapi ilptcmb*.333 afilt3 tone acomb3, icutoff afilt3 balance afilt3, acomb3 igain3 pow .001, (ilptcmb*.333)/irvt acomb4 deltapi ilptcmb*1.666 afilt4 tone acomb4, icutoff afilt4 balance afilt4, acomb4 igain4 pow .001, (ilptcmb*1.666)/irvt delayw (((afilt1*igain1)+(afilt2*igain2)+(afilt3*igain3)+(afilt4*igain4))/4)+ain1+ain2 acombL = (acomb1+acomb2)/2 acombR = (acomb3+acomb4)/2 ;all-pass filters aap1L alpass acombL, irvt, ilptap1 aap2L alpass aap1L, irvt, ilptap2 aap1R alpass acombR, irvt, ilptap1 aap2R alpass aap1R, irvt, ilptap2 arvbL = aap2L arvbR = aap2R ;mix wet and dry aout1 dcblock (ain1*idrymix)+(arvbL*(1-idrymix)) aout2 dcblock (ain2*idrymix)+(arvbR*(1-idrymix)) combLoop 173 27 true 0.0 0.2 0.070382446 60 true 159 107 reverbTime 18 11 true 0.0 4.0 3.2461355 120 true 44 150 loopDel1 34 187 true 0.0 0.1 0.049102403 60 true loopDel2 125 188 true 0.0 0.1 0.1 60 true 28 267 118 269 dryMix 211 187 true 0.0 1.0 1.0 60 true 226 267 cutoff 37 294 true 0.0 10000.0 1.0 376.0 200 true 95 320 Master Master 0.0 false false ;i1 0.0 0.5 25000 80 40 0.01 1.0 1.0 ;i1 0.3 0.5 10000 400 400 0.01 0.0 0.0 ;i1 0.0 3.0 10000 450 300 1.50 0.5 0.5 ;i1 0.0 1.5 10000 300 450 0.75 0.2 0.8 ;i1 1.5 1.5 10000 300 450 0.75 0.8 0.2 ;i1 00 0.5 30000 160 80 0.01 1.0 1.0 ;i1 + 0.5 30000 80 40 0.01 0.0 0.0 ;i1 + 0.3 30000 160 80 0.01 1.0 1.0 ;i1 + 0.3 30000 80 40 0.01 0.0 0.0 ;i1 0.0 0.5 30000 80 40 0.01 0.5 0.5 ;i1 0.333 0.5 10000 80 40 0.01 0.5 0.5 ;i1 0.5 0.5 30000 80 40 0.01 0.5 0.5 ;i1 1.0 0.5 30000 80 40 0.01 0.5 0.5 ;i1 1.166 0.5 30000 80 40 0.01 0.5 0.5 ;i1 1.5 0.5 30000 80 40 0.01 0.5 0.5 csound -Wdo devaudio -L stdin false false 2.0 0.0 root -10066279 0 true 68 0 false 1.0 0 5 320.0 0.0 PythonObject -12566464 2 import math import random from ScriptingUtils import * score = "" pans = [ (0.5,0.5), (0.2, 0.2), (0.8, 0.8), (0.2, 0.8), (0.8, 0.2) ] def GongComponent(start, len, amp, freq, atk, pan): if 1==1: sc = "" nr_parts = 3 for i in range(0, nr_parts): sc += "i1 %6.2f %4.2f %6f %5.2f %5.2f %0.5f %3.2f %3.2f\n" % (start, len/(i+1), amp/nr_parts, freq, freq, atk, pan, pan) else: sc = "i1 %6.2f %4.2f %6f %5.2f %5.2f %0.5f %3.2f %3.2f\n" % (start, len, amp, freq, freq, atk, pan, pan) return sc def PlayGong(start, len, amp): freq = 150 atk = 0.002 sc = "\n; Gong\n" sc += GongComponent(start, len, amp*1.0000, freq, atk, 0.5) sc += GongComponent(start, len, amp*0.8333, freq*1.1541, atk, 0.5) sc += GongComponent(start, len, amp*0.6667, freq*1.6041, atk, 0.2) sc += GongComponent(start, len, amp*1.0000, freq*1.5208, atk, 0.8) sc += GongComponent(start, len, amp*0.3333, freq*1.4166, atk, 0.2) sc += GongComponent(start, len, amp*0.3333, freq*2.7916, atk, 0.8) sc += GongComponent(start, len, amp*0.3333, freq*3.3833, atk, 0.2) return sc # Continued fractions can be used to find rational numbers that approximate frequency intervals in equal temperament, # but here I use them in a different way, namely to get a list of numbers that are used to create different frequencies. # As the original number is slowly increased, the generated numbers vary, where the first ones vary slowly but the later # ones vary quicker. This gives interesting effects. def GetContinuedFraction(f, nr): f_list = [] for i in range(0, nr): f_list.append(f) n = math.floor(f) f = 1/(f-n) return f_list def AddSeq(seq_start, len, amp, base_freq, f, nr, pan_idx): sc = "" start = seq_start step = len/(2.0*nr) attack = len/4.0 f_list = GetContinuedFraction(f, nr) amp_list = [amp/f for f in f_list] amp_sum = sum(amp_list) max_amp = 32768*2.3 if amp_sum>max_amp: amp_list = [amp*max_amp/amp_sum for amp in amp_list] for i in range(0, nr): freq = base_freq*f_list[i] pan_begin, pan_end = pans[(i+pan_idx)%5] sc += "i1 %6.2f %2.2f %5.0f %8.2f %8.2f %2.2f %1.2f %1.2f\n" % (start, len, amp_list[i], freq, freq, attack, pan_begin, pan_end) start += step len -= step sc += "\n" return sc def AddSeq2Sqrts(seq_start, len, n1, n2, nr): return AddSeq(seq_start, len, math.sqrt(n1)+math.sqrt(n2), nr) def AddSequence(start, f): # calling this once would suffice, and the number used doesn't matter much, # but it is a nice touch to use the number that is also used further below random.seed(f) speed_avg = 1 speed_drift = 0.019 nr_notes = 4 nr_notes_drift = 0.2 amp = 1 amp_drift = 0.1 freq = 1 freq_drift = 0.008 pan_idx = 0 sc = "" while True: speed_avg += speed_drift speed = speed_avg + random.uniform(-0.2, 0.2) if nr_notes<10: nr_notes += nr_notes_drift amp += amp_drift freq = freq + freq_drift len = 5/(speed*speed*speed) sc += AddSeq(start, len, 2000*amp*amp, 100*freq*freq, f, int(nr_notes), pan_idx) f += 0.001 start += len+len/10 pan_idx = pan_idx+1 if len<0.2: sc += PlayGong(start-8, 2, 6000) sc += PlayGong(start-4, 2, 12000) sc += PlayGong(start, 4, 18400) break return (sc, start+4) def PlaySong(): start = 1 (sc1, start) = AddSequence(start, math.pi) (sc2, start) = AddSequence(start+2, math.e) #(sc3, start) = AddSequence(start+2, (math.sqrt(5.0)+1)/2) score = "; Using pi:\n"+sc1 +"\n; Using e:\n"+sc2 # +"\n; Using the golden section:\n"+sc3 score += "\n\n; End:\n" score += AddSeq(start+ 2, 5, 20000, 100, math.pi, 6, 1) score += AddSeq(start+ 7, 6, 10000, 100, math.e, 5, 1) score += AddSeq(start+13, 7, 5000, 100, math.pi, 4, 1) score += AddSeq(start+21, 8, 2500, 100, math.e, 3, 1) return score #score = PlayGong(0, 4, 18400) score = PlaySong() #infoTabs(score, "score") true 0.0 -1.0 false false false