Fragments of a Bohlen-Pierce Composition Jacob Joaquin Feb 11, 2010 jacobjoaquin@gmail.com csound.noisepages.com sr = 44100 kr = 44100 ksmps = 1 nchnls = 2 0dbfs = 1.0 # define TUNE # 261.62556530059862 # ; 440 * 2 ^ (-9 / 12) # define AMP # 1.0 # # define Setup # 1 # # define Player # 2 # # define Synth # 3 # # define Reverb # 4 # ; Just Intonation Bohlen-Pierce Tuning gitemp ftgen 13, 0, 64, -2, 13, 3, $TUNE, 60, \ 1, \ 27 / 25, \ 25 / 21, \ 9 / 7, \ 7 / 5, \ 75 / 49, \ 5 / 3, \ 9 / 5, \ 49 / 25, \ 15 / 7, \ 7 / 3, \ 63 / 25, \ 25 / 9, \ 3 ; Sine wave gitemp ftgen 1, 0, 2 ^ 16, 10, 1 opcode Get_Ratio, i, i i_interval xin iratio cpstuni 60 + i_interval, 13 iratio = iratio / $TUNE print iratio xout iratio endop instr $Setup chn_a "verb_left", 3 chn_a "verb_right", 3 a0 = 0 chnset a0, "verb_left" chnset a0, "verb_right" endin instr $Player itime = p4 ; Time the Player instr is active ibase_dur = p5 ; Base duration of notes generated ibase_interval = p6 ; Base interval ibase_width = p7 ; Base interval width ; Play Synth iratio Get_Ratio int(rnd(14)) idur = ibase_dur * iratio iamp = rnd(0.7) + 0.2 ibase = ibase_interval + int(rnd(ibase_width)) i_interval = int(rnd(14)) iratio Get_Ratio int(rnd(14)) i_index = iratio idistance = 0.6 + rnd(0.4) ipan = rnd(1) event_i "i", $Synth, 0, idur, iamp, ibase, i_interval, i_index, \ idistance, ipan ; Play Player inext = idur * 0.4 itime = itime - inext if (itime > 0) then event_i "i", $Player, inext, 1, itime, ibase_dur, ibase_interval, \ ibase_width endif turnoff endin instr $Synth idur = p3 ; Duration iamp = p4 ; Amplitude ibase = p5 ; Base note iratio_interval = p6 ; Modulation ratio i_index = p7 ; Modulation index idistance = p8 ; Front to back, 0 .. 1 ipan = p9 ; Pan position ; Stream Bohlen-Pierce ratios iratio Get_Ratio iratio_interval ; Amp envelope iratio_env Get_Ratio int(rnd(12)) + 1 iratio_env = (iratio_env - 1) / 2 kenv expseg 0.001, idur * iratio_env, 1, idur * (1 - iratio_env), 0.001 ; FM synth kfreq cpstun 1, ibase, 13 a1 foscil iamp, kfreq, 1, iratio, i_index, 1 a1 = a1 * kenv ; Pan aleft = a1 * sqrt(1 - ipan) aright = a1 * sqrt(ipan) ; Send to out and bus outs aleft * sqrt(1 - idistance) * $AMP, aright * sqrt(1 - idistance) * $AMP chnmix aleft * sqrt(idistance), "verb_left" chnmix aright * sqrt(idistance), "verb_right" endin instr $Reverb iroom_size = p4 ; Size of room idamp = p5 ; High frequency dampening aleft chnget "verb_left" aright chnget "verb_right" aleft delay aleft, 0.2 aright delay aright, 0.2 al, ar freeverb aright, aright, iroom_size, idamp outs al * $AMP, ar * $AMP chnclear "verb_left" chnclear "verb_right" endin # define Setup # 1 # # define Player # 2 # # define Synth # 3 # # define Reverb # 4 # t 0 60 i $Setup 0 1 i $Player 0 1 60 2 43 26 i $Player 63 1 60 0.4 60 19 i $Player 123 1 30 4 43 13 i $Reverb 0 163 0.7 0.7