;------------------------------------------------------------------------- ; ; Combination Study 1 ; by Dave Seidel (dave at mysterybear dot com) ; ; Copyright 2004, Dave Seidel. Some rights reserved. ; This work is licensed under a Creative Commons "Attribution" License. ; http://creativecommons.org/licenses/by/2.0/ ; ; Tested with canonical Csound version 4.23f12 (c0nsound64.exe) ; on Windows XP. ; ;------------------------------------------------------------------------- ;-o devaudio -W -o combostudy1.wav ;------------------------------------------------------------------------- ; globals ;------------------------------------------------------------------------- sr = 44100 kr = 441 ksmps = 100 nchnls = 2 ;------------------------------------------------------------------------- ; zak channels ;------------------------------------------------------------------------- zakinit 16, 16 ;------------------------------------------------------------------------- ; function tables for waveforms ;------------------------------------------------------------------------- giTblSz init 131072 ; pure sine wave giFn1 ftgen 1, 0, giTblSz, 10, 1 ; harmonics in the Fibonacci series giFn2 ftgen 2, 0, giTblSz, 10, 1, .5, .3333, 0, .2, 0, 0, .125, 0, 0, 0, 0, .0769;, 0, 0, 0, 0, 0, 0, 0, .0476 ; harmonics in the Fibonacci series (smaller set) giFn3 ftgen 3, 0, giTblSz, 10, 1, .5, .3333;, 0, .2, 0, 0, .125, 0, 0, 0, 0, .0769, 0, 0, 0, 0, 0, 0, 0, .0476 ; multiples of 2, 3 and 7 ;giFn4 ftgen 4, 0, giTblSz, 10, 1, .5, .3333, .25, 0, .16667, .14286, .125, .111110, 0, 0, .08333, 0, .07142, 0, .0625, 0, .05556, 0, 0, .0476 ;--------------------------------------------------------------------------------------- ; transpose a frequency (by octaves) into the range defined by a min/max frequency ;--------------------------------------------------------------------------------------- opcode reduce, i, iii ifreq,ilo,ihi xin loop: if (ifreq < ilo) then ifreq = ifreq*2 elseif (ifreq > ihi) then ifreq = ifreq/2 endif if (ifreq < ilo || ifreq > ihi) then goto loop endif xout ifreq endop ;--------------------------------------------------------------------------------------- ; combination tone chord organ: given a note and a ratio, produces the chord formed ; by that interval plus the set of notes equivalent to the combination tones produced ; by that interval ;--------------------------------------------------------------------------------------- instr 2 idur = p3 ; duration iamp = p4/9 ; amplitude ifn1 = p5 ; function table number (waveform) for dyad ifn2 = p6 ; function table number (waveform) for combo tones izch = p7 ; zak output channel ipch1 = p8 ; primary pitch (as a frequency) immm = p9 ; numerator of dyad innn = p10 ; denomiator of dyad iflng = p11 ; flanger flag (0 = yes, 1 = no) iredf = p12 ; reduction factor (0 = none, >0 = 8ve spread) iredb = p13 ; reduction base (8ve multiplier for low range) ipch2 = ipch1*(immm/innn) ; secondary pitch (primary * ratio) idiff = ipch2-ipch1 ; difference tone idiff2 = (2*ipch2)-ipch1 ; 2nd order difference tone idiff3 = (3*ipch2)-(2*ipch1) ; 3rd order difference tone iper = ipch1/innn ; periodicity pitch, shifted up one 8ve isum = ipch1+ipch2 ; summation tone isum2 = (2*ipch1)+ipch2 ; 2nd order summation tone ae1 linen iamp, 2, idur, 3 ; envelope for primary/secondary tones ae2 linen iamp, 6, idur, .5 ; envelope for summation tones and periodicity pitch ae3 linen iamp, 6, idur, .5 ; envelope for difference tones if (iredf == 0) then ; if non-zero, "reduce" the chord by transposing goto noreduce ; all derived tones into the given octave span endif if (iredb < 0) then ilo = ipch1/(2^abs(iredb-1)) else ilo = ipch1*(2^(iredb-1)) endif ihi = ilo*(2*iredf) idiff reduce idiff, ilo, ihi idiff2 reduce idiff2, ilo, ihi idiff3 reduce idiff3, ilo, ihi iper reduce iper, ilo, ihi isum reduce isum, ilo, ihi isum2 reduce isum2, ilo, ihi noreduce: prints "\\n%d:%d %f %f %f %f %f %f (%f %f)\\n", immm, innn, ipch1, ipch2, idiff, idiff2, idiff3, iper, isum, isum2 asig1 poscil ae1, ipch1, ifn1 asig2 poscil ae1, ipch2, ifn1 adiff poscil ae2, idiff, ifn2 adiff2 poscil ae2, idiff2, ifn2 adiff3 poscil ae2, idiff3, ifn2 aper poscil ae2, iper, ifn2 asum poscil ae3, isum, ifn2 asum2 poscil ae3, isum2, ifn2 aout = asig1+asig2+((adiff+adiff2+adiff3+aper)*.75)+(asum*.50)+(asum2*.25) if (iflng == 1) then goto FLANGER endif zaw aout, izch goto DONE FLANGER: imax = idur/1000 adel line 0, idur*2, imax kfb = 0.5 aflang flanger aout, adel, kfb zaw aout+(aflang*.5), izch goto DONE DONE: endin ;--------------------------------------------------------------------------- ; Risset harmonic arpeggio instrument, adapted from: ; ACCCI: 02_43_1.ORC ; timbre: tibetan chant ; synthesis: additive same units(02) ; basic instrument with minimal differences in frequency(43) ; arpeggio instrument by Risset ; source: Phase6, Lorrain(1980); Boulanger(1990): risset1.orc ; coded: jpg 9/93 ;--------------------------------------------------------------------------- instr 4 idur = p3 ; duration iamp = p4/10 ; amplitude ifn = p5 ; function table number (waveform) izch = p6 ; zak output channel ifreq = p7*(p8/p9) ; pitch (base * (n/m)) ioff1 = p10 ; oscillator offset for arpeggio ioff2 = 2*p10 ; . ioff3 = 3*p10 ; . ioff4 = 4*p10 ; . ae linen iamp, 2, idur, 3 ; simple envelope a1 oscil ae, ifreq, ifn a2 oscil ae, ifreq+ioff1, ifn ; nine oscillators with the same ae a3 oscil ae, ifreq+ioff2, ifn ; and waveform, but slightly different a4 oscil ae, ifreq+ioff3, ifn ; frequencies create harmonic arpeggio a5 oscil ae, ifreq+ioff4, ifn a6 oscil ae, ifreq-ioff1, ifn a7 oscil ae, ifreq-ioff2, ifn a8 oscil ae, ifreq-ioff3, ifn a9 oscil ae, ifreq-ioff4, ifn zaw a1+a2+a3+a4+a5+a6+a7+a8+a9, izch endin ;--------------------------------------------------------------------------- ; mixer (adapted from Mikelson, "Modelling a Multieffects Processor") ; added 4 more channels and a simple reverb at the end ;--------------------------------------------------------------------------- instr 3099 asig1 zar p4 igl1 init p5*p6 igr1 init p5*(1-p6) asig2 zar p7 igl2 init p8*p9 igr2 init p8*(1-p9) asig3 zar p10 igl3 init p11*p12 igr3 init p11*(1-p12) asig4 zar p13 igl4 init p14*p15 igr4 init p14*(1-p15) asig5 zar p16 igl5 init p17*p17 igr5 init p17*(1-p18) asig6 zar p19 igl6 init p20*p21 igr6 init p20*(1-p21) asig7 zar p22 igl7 init p23*p24 igr7 init p23*(1-p24) asig8 zar p25 igl8 init p26*p27 igr8 init p26*(1-p27) asigl = asig1*igl1 + asig2*igl2 + asig3*igl3 + asig4*igl4 + asig5*igl5 + asig6*igl6 + asig7*igl7 + asig8*igl8 asigr = asig1*igr1 + asig2*igr2 + asig3*igr3 + asig4*igr4 + asig5*igr5 + asig6*igr6 + asig7*igr7 + asig8*igr8 irvtime = p28 irvfqc = p29 irvlev = p30 aoutl nreverb asigl, irvtime, irvfqc aoutr nreverb asigr, irvtime, irvfqc outs asigl+(aoutl/irvlev), asigr+(aoutr/irvlev) zacl 0, 16 endin ;--------------------------------------------------------------------------- ; score macros ;--------------------------------------------------------------------------- ; 60Hz base pitch (US version) #define BASE #60# ; 50Hz base pitch (Euro version) ;#define BASE #50# ; base pitch in specified octave above base #define BOCT(O) #[$BASE.*(2^$O.)]# ; pitch at ratio-defined interval from base in specified octave #define BRAT(O#N#D) #[$BOCT.($O.)*($N./$D.)]# ;--------------------------------------------------------------------------- ; score ;--------------------------------------------------------------------------- ; tempo: 55 bpm t 0 55 ; mixer ; ; channel 1: chords ; channel 2-5: drones ; channel 6-8: unused ; i 3099 0 445 \ 1 4 .5 \ 2 1.5 .80 \ 3 1.5 .20 \ 4 1.5 .75 \ 5 1.5 .25 \ 6 0 .5 \ 7 0 .5 \ 8 0 .5 \ 5 .3 6 ; drone (starts 20b before chords, ends 20b after chords) i 4 0 440 1300 2 2 $BOCT.(1) 3 2 .02 i . 1 439 . . 3 . 2 1 .03 i . 2 438 . . 4 . 2 1 .03 i . 3 437 . . 5 . 1 1 .04 ; chord sequence... i 2 20 11 4500 3 1 1 $BOCT.(2) 8 5 1 1 1 i . + . . . . . . 7 5 . . . i . + 13 . . . . . 6 5 . . . i . + 11 . . . . . 8 5 . . . i . + . . . . . . 7 5 . . . i . + . . . . . . 6 5 . . . i . + 15 . . . . . 7 6 . . . i . + 11 . . . . . 8 5 . . . i . + . . . . . . 7 5 . . . i . + . . . . . . 6 5 . . . i . + 15 . . . . . 7 6 . . . i . + 11 . . . . . 9 8 . . . i . + . . . . . . 5 4 . . . i . + . . . . . . 9 8 . . . i . + 25 . . . . . 5 4 . . . ; ...repeated (after 5-beat rest) i . ^+30 11 . . . . . 8 5 1 0 0 i . + . . . . . . 7 5 . . . i . + 13 . . . . . 6 5 . . . i . + 11 . . . . . 8 5 . . . i . + . . . . . . 7 5 . . . i . + . . . . . . 6 5 . . . i . + 15 . . . . . 7 6 . . . i . + 11 . . . . . 8 5 . . . i . + . . . . . . 7 5 . . . i . + . . . . . . 6 5 . . . i . + 15 . . . . . 7 6 . . . i . + 11 . . . . . 9 8 . . . i . + . . . . . . 5 4 . . . i . + . . . . . . 9 8 . . . i . + 30 . . . . . 5 4 . . . e