; The first character in this line is a command to the preprocessor to pass the remainder of the line as a literal
; The next character is the Csound comment character. These two lines will appear in the csound input file
; Name: next8. 03/25/04 8:47am
;
; Current Title: Next Piece
;
<CsoundSynthesizer>

<CsOptions>
-W -G -m2 -+y -o sflib\next8.wav
</CsOptions>

<CsInstruments>
sr = 44100
ksmps = 10 ; any higher than 10 and I hear clicks - use 1 for final take
; typically save 5x processing time by increasing ksmps by 10x
nchnls = 2

instr 1

; p1 is always 1
; p2 start time
; p3 duration
; p4 velocity, 60-80 works best
; p5 tone - which tone is this note - 1-43 for Partch scale
; p6 Octave
; p7 voice
; p8 stereo - pan from left = 0 to right = 16
; p9 envelope - one of several function tables for envelopes 1 - 16
; p10 glissando - one of several function tables to modify pitch
; p11 upsample - use a sample higher (>0) or lower (<256) than normal
;
ifunc table p7,1 ; find the location of the sample wave tables
iwavchan table p7,2 ; is it mono (iwavchan = 1) or stereo sample file (iwavchan = 2)
; or are sustain points in separate table iwavchan=3
ioct = p6+3 ; I am used to Middle C = 6
inum = p6*12 + int(p5/43*12) ; convert to MIDI note number to pick ftable
ifno2 table inum, ifunc ; map midi note number to ftables
ifno = ifno2 + (p11 < 128 ? p11 : p11-256) ; offset the chosen ftable by parameter 11
iamp = ampdb(p4) ; velocity input is 60-80 - convert to amplitude
i9 = 298-p9 ; valid envelope table number are 298, 297, 296, 295 etc.
i10 = 301+p10 ; valid glissando table number are 301, 302, etc
kamp oscili iamp, 1/p3, i9 ; create an envelope from a function table
kpanl tablei p8/16, 4, 1 ; pan with a sine wave using f table #4
kpanr tablei 1.0 - p8/16, 4, 1; inverse of kpanl
ibasno table ifno-(3+ifunc), 1 + ifunc ; get basnot for each ftable
icent table ifno-(3+ifunc), 2 + ifunc ; get cents to flatten each note
iloop table ifno-(3+ifunc), 3 + ifunc ; get loop or not
ibasoct = ibasno/12 + 3 ; find the base octave
ibascps = cpsoct(ibasoct+(icent/1200))
ipitch table p5, 3 ; convert note number 1-43 to oct.fract format
kcps = cpspch(ioct+ipitch) ; convert oct.fract to Hz
kcpsm oscili 1, 1/p3, i10 ; create an set of shift multiplicands from table
kcps2 = kcps * kcpsm ; shift the frequency by values in glissando table
print p1,p5,p6,inum,p7,p11,ifno2,ifno,iwavchan,iloop
; Four choices: Mono looping, stereo looping, mono no-loop, stereo no-loop
if iwavchan = 5 goto akaister
if iwavchan = 4 goto akaimono
akaister:
if iloop = 0 goto noloops
; print p7, ifno,ibascps,iloop,i10,iwavchan
a1,a2 loscil kamp, kcps2, ifno, ibascps; stereo sample with looping
; ihertz = cpspch(ioct+ipitch) ; what frequency are you trying to make
; print p5, p6, ihertz, ifno ; show me the tone, octave, frequency, and function table containing the sample
; a3 oscili kamp/2, kcps, 4 ; make a square wave to compare the sample frequency to
; a4 = a1 + a3 ; add the sample to the square wave right
; a5 = a2 + a3 ; and left
outs a1 * kpanl ,a2 * kpanr
; outs a4 * kpanl ,a5 * kpanr ; if you need to have a comparison oscilator for pitch matching
goto skipstereo
noloops:
a1,a2 loscil kamp, kcps2, ifno, ibascps,0,1,2 ; stereo sample without looping - note that 1,2 is bogus workaround
outs a1 * kpanl ,a2 * kpanr
goto skipstereo
akaimono:
if iloop = 0 goto noloopm
a1 loscil kamp, kcps2, ifno, ibascps; mono AIFF sample with loop
outs a1 * kpanl ,a1 * kpanr
goto skipstereo
noloopm:
a1 loscil kamp, kcps2, ifno, ibascps,0,1,2 ; mono AIFF sample without loop
outs a1 * kpanl ,a1 * kpanr

skipstereo:
endin
</CsInstruments>

<CsScore>
; The next function table transforms a note number into a cpsoct value
; These are the values required for the Partch 43 tone scale
f3 0 64 -2 .0000000 .0021506 .0053273 .0084467 .0111731 .0150637 .0165004
.0182404 .0203910 .0231174 .0266871 .0294135 .0315641 .0347408 .0386314 .0417508
.0435084 .0470781 .0498045 .0519551 .0551318 .0582512 .0617488 .0648682 .0680449
.0701955 .0729219 .0764916 .0782492 .0813686 .0852592 .0884359 .0905865 .0933129
.0968826 .0996090 .1017596 .1034996 .1049363 .1088269 .1115533 .1146727 .1178494
.1200000
; the next function table is for stereo panning
f4 0 1025 9 .25 1 0 ;The first quadrant of a sin
; glissando function tables
; 1st take 2nd take 3rd take 4th take 5th take 6th take sum of takes = size of table
; these are useful for taking a note up or down an octave without moving the sample up or down - built in munchkinization
f301 0 256 -7 1 256 1 ; g0 = no change; g1 oct up 1; g2 oct up 2; g3 oct down 1
f302 0 256 -7 .75 256 .75 ; g1 down 4/3
f303 0 256 -7 1.5 256 1.5 ; g2 up 3/2
f304 0 256 -7 .5 256 .5 ; g3 1 octave down no slide
f305 0 256 -7 1.111111 256 1.111111 ; g4 up 10:9
f306 0 256 -7 .9090909 256 .9090909 ; g5 down 11:10
f307 0 1024 -7 1 512 1 0 1.09090909 256 1.09090909 0 .8571429 256 .8571429 0 ; g6 1 2 6 = F G-- D++
f308 0 1024 -7 1 512 1 0 1.1 256 1.1 0 .9166667 256 .9166667 0 ; g7 2 3 1 = G-- Ab F
f309 0 1024 -7 1 512 1 0 1.111111 256 1.111111 0 .9090909 256 .9090909 0 ; g8 3 4 2 = Ab A# G--
f310 0 1024 -7 1 512 1 0 1.125 256 1.125 0 .9000000 256 .9000000 0 ; g9 4 5 3 = A# C Ab
f311 0 1024 -7 1 512 1 0 1.14285714 256 1.14285714 0 .8888889 256 .8888888 0 ; g10 5 6 4 = C D++ A#
f312 0 1024 -7 1 512 1 0 1.16666667 256 1.16666667 0 .8750000 256 .8750000 0 ; g11 6 1 5 = D++ F C
f315 0 129 -6 1 4 1 4 1 16 1.3750 16 1.7500 4 1.7300 4 1.7100 4 1.7300 4 1.7500 4 1.7300 4 1.7100 4 1.7300 4 1.7500 4 1.7300 4 1.7100 4 1.7300 4 1.7500 4 1.7300 4 1.7100 4 1.7300 4 1.7500 4 1.7300 4 1.7100 4 1.7300 4 1.7500 4 1.7300 4 1.7100 ; g14
f316 0 129 -6 1 4 1 4 1 16 1.2500 16 1.5000 4 1.4800 4 1.4600 4 1.4800 4 1.5000 4 1.4800 4 1.4600 4 1.4800 4 1.5000 4 1.4800 4 1.4600 4 1.4800 4 1.5000 4 1.4800 4 1.4600 4 1.4800 4 1.5000 4 1.4800 4 1.4600 4 1.4800 4 1.5000 4 1.4800 4 1.4600 ; g15
f317 0 129 -6 1 4 1 4 1 16 1.1667 16 1.3333 4 1.3133 4 1.2933 4 1.3133 4 1.3333 4 1.3133 4 1.2933 4 1.3133 4 1.3333 4 1.3133 4 1.2933 4 1.3133 4 1.3333 4 1.3133 4 1.2933 4 1.3133 4 1.3333 4 1.3133 4 1.2933 4 1.3133 4 1.3333 4 1.3133 4 1.2933 ; g16
f318 0 129 -6 1 4 1 4 1 16 1.1250 16 1.2500 4 1.2300 4 1.2100 4 1.2300 4 1.2500 4 1.2300 4 1.2100 4 1.2300 4 1.2500 4 1.2300 4 1.2100 4 1.2300 4 1.2500 4 1.2300 4 1.2100 4 1.2300 4 1.2500 4 1.2300 4 1.2100 4 1.2300 4 1.2500 4 1.2300 4 1.2100 ; g17
f319 0 129 -6 1 4 1 4 1 16 1.1000 16 1.2000 4 1.1800 4 1.1600 4 1.1800 4 1.2000 4 1.1800 4 1.1600 4 1.1800 4 1.2000 4 1.1800 4 1.1600 4 1.1800 4 1.2000 4 1.1800 4 1.1600 4 1.1800 4 1.2000 4 1.1800 4 1.1600 4 1.1800 4 1.2000 4 1.1800 4 1.1600 ; g18
f320 0 129 -6 1 4 1 4 1 16 1.0714 16 1.1429 4 1.1229 4 1.1029 4 1.1229 4 1.1429 4 1.1229 4 1.1029 4 1.1229 4 1.1429 4 1.1229 4 1.1029 4 1.1229 4 1.1429 4 1.1229 4 1.1029 4 1.1229 4 1.1429 4 1.1229 4 1.1029 4 1.1229 4 1.1429 4 1.1229 4 1.1029 ; g19
f321 0 129 -6 1 4 1 4 1 16 1.0625 16 1.1250 4 1.1050 4 1.0850 4 1.1050 4 1.1250 4 1.1050 4 1.0850 4 1.1050 4 1.1250 4 1.1050 4 1.0850 4 1.1050 4 1.1250 4 1.1050 4 1.0850 4 1.1050 4 1.1250 4 1.1050 4 1.0850 4 1.1050 4 1.1250 4 1.1050 4 1.0850 ; g20
f322 0 129 -6 1 4 1 4 1 16 1.0556 16 1.1111 4 1.0911 4 1.0711 4 1.0911 4 1.1111 4 1.0911 4 1.0711 4 1.0911 4 1.1111 4 1.0911 4 1.0711 4 1.0911 4 1.1111 4 1.0911 4 1.0711 4 1.0911 4 1.1111 4 1.0911 4 1.0711 4 1.0911 4 1.1111 4 1.0911 4 1.0711 ; g21
f323 0 129 -6 1 4 1 4 1 16 1.0500 16 1.1000 4 1.0800 4 1.0600 4 1.0800 4 1.1000 4 1.0800 4 1.0600 4 1.0800 4 1.1000 4 1.0800 4 1.0600 4 1.0800 4 1.1000 4 1.0800 4 1.0600 4 1.0800 4 1.1000 4 1.0800 4 1.0600 4 1.0800 4 1.1000 4 1.0800 4 1.0600 ; g22
f324 0 129 -6 1 4 1 4 1 16 1.0833 16 1.1667 4 1.1467 4 1.1267 4 1.1467 4 1.1667 4 1.1467 4 1.1267 4 1.1467 4 1.1667 4 1.1467 4 1.1267 4 1.1467 4 1.1667 4 1.1467 4 1.1267 4 1.1467 4 1.1667 4 1.1467 4 1.1267 4 1.1467 4 1.1667 4 1.1467 4 1.1267 ; g23
f325 0 129 -6 1 4 1 4 1 16 1.0455 16 1.0909 4 1.0709 4 1.0509 4 1.0709 4 1.0909 4 1.0709 4 1.0509 4 1.0709 4 1.0909 4 1.0709 4 1.0509 4 1.0709 4 1.0909 4 1.0709 4 1.0509 4 1.0709 4 1.0909 4 1.0709 4 1.0509 4 1.0709 4 1.0909 4 1.0709 4 1.0509 ; g24
f326 0 129 -6 1 4 0.99 4 0.98 4 0.99 4 1 4 0.99 4 0.98 4 0.99 4 1 4 0.99 4 0.98 4 0.99 4 1 4 0.99 4 0.98 4 0.99 4 1 4 0.99 4 0.98 4 0.99 4 1 4 0.99 4 0.98 4 0.99 4 1 4 0.99 4 0.98 4 0.99 4 1 4 0.99 4 0.98 4 0.99 4 1 ; - g25 down & back vibrato
f327 0 129 -6 1.01 4 1.00 4 0.99 4 1.00 4 1.01 4 1.00 4 0.99 4 1.00 4 1.01 4 1.00 4 0.99 4 1.00 4 1.01 4 1.00 4 0.99 4 1.00 4 1.01 4 1.00 4 0.99 4 1.00 4 1.01 4 1.00 4 0.99 4 1.00 4 1.01 4 1.00 4 0.99 4 1.00 4 1.01 4 1.00 4 0.99 4 1.00 4 1.01 ; g26
; Envelopes
; autoscale all following tables to 1
;#7 0 siz 7 start take getto take getto take getto
f297 0 1024 7 0 2 1024 990 512 32 0 ; e1 - Attack and decay slowly
;#5 0 siz exp start take reach take reach
f296 0 513 5 1024 512 1 ; e2 - exponential - dead piano
;#6 0 siz exp min values mid val max val mid val min val mid val max val mid val min
f295 0 129 6 0 8 .5 8 1 16 .6 16 .3 16 .5 16 .6 24 .3 24 0 ; e3 big hump, small hump
f284 0 1025 6 1 1 1 1 1 192 .99 192 .98 16 .5 16 0 303 0 303 0 ; e14 hit and sustain 1/3 the normal length
f282 0 1025 6 0 1 .2 1 .4 479 .7 479 1 32 .5 32 0 ; e16 sustain piano sound
; set the tempo
t0 5200 2872 5000
f5 0 128 -17 0 9 53 10 56 11 59 12 62 13 65 14 68 15 71 16 74 17 77 18 80 19 127
f6 0 32 -2 0 52 55 58 61 64 67 70 73 76 79 82
f7 0 32 -2 0 0 0 0 -8 -7 +2 -7 +6 +5 0 -5
f8 0 32 -2 0 1 1 1 1 1 1 1 1 1 1 1
f20 0 128 -17 0 24 22 25 32 26 39 27 45 28 52 29 57 30 63 31 68 32 78 33 84 34 92 35 98 36 102 37 127
f21 0 32 -2 0 21 31 38 44 51 56 62 67 77 83 91 97 101 106
f22 0 32 -2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
f23 0 32 -2 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
f11 0 0 1 "McGill/Partition E/TROMBONE-TNR/TNRBONEA#2.aif" 0 4 0
f12 0 0 1 "McGill/Partition E/TROMBONE-TNR/TNRBONEC#3.aif" 0 4 0
f13 0 0 1 "McGill/Partition E/TROMBONE-TNR/TNRBONEE3.aif" 0 4 0
f14 0 0 1 "McGill/Partition E/TROMBONE-TNR/TNRBONEG3.aif" 0 4 0
f15 0 0 1 "McGill/Partition E/TROMBONE-TNR/TNRBONEA#3.aif" 0 4 0
f16 0 0 1 "McGill/Partition E/TROMBONE-TNR/TNRBONEC#4.aif" 0 4 0
f17 0 0 1 "McGill/Partition E/TROMBONE-TNR/TNRBONEE4.aif" 0 4 0
f18 0 0 1 "McGill/Partition E/TROMBONE-TNR/TNRBONEG4.aif" 0 4 0
f26 0 0 1 "McGill/Partition D/GRAND PIANO/MF D2.aif" 0 4 0
f27 0 0 1 "McGill/Partition D/GRAND PIANO/MF G#2.aif" 0 4 0
f28 0 0 1 "McGill/Partition D/GRAND PIANO/MF D#3.aif" 0 4 0
f29 0 0 1 "McGill/Partition D/GRAND PIANO/MF G#3.aif" 0 4 0
f30 0 0 1 "McGill/Partition D/GRAND PIANO/MF D4.aif" 0 4 0
f31 0 0 1 "McGill/Partition D/GRAND PIANO/MF G4.aif" 0 4 0
f32 0 0 1 "McGill/Partition D/GRAND PIANO/MF F5.aif" 0 4 0
f1 0 16 -2 0 5 20
f2 0 16 -2 0 5 5
;Inst Start Dur Vel Ton Oct Voice Stere Envlp Gliss Upsamp;Channel
i1 0.0000000000 144 77 14 6 1 4 1 0 254 ; 1
i1 128.0000000000 96 77 0 6 1 10 1 0 254 ; 1
i1 224.0000000000 28 77 8 6 1 10 1 0 254 ; 1
i1 256.0000000000 120 77 14 6 1 4 1 0 254 ; 1
i1 384.0000000000 128 77 14 6 1 8 1 0 0 ; 1
i1 512.0000000000 96 77 0 6 1 8 1 0 0 ; 1
i1 608.0000000000 32 77 8 6 1 8 1 0 0 ; 1
i1 640.0000000000 120 77 14 6 1 8 1 0 254 ; 1
i1 768.0000000000 128 77 14 6 1 7 1 0 254 ; 1
i1 896.0000000000 128 77 14 6 1 12 1 0 0 ; 1
i1 0.0000000000 36 77 14 5 1 8 1 0 254 ; 2
i1 32.0000000000 70 77 34 5 1 8 1 0 254 ; 2
i1 96.0000000000 36 77 20 5 1 8 1 0 254 ; 2
i1 128.0000000000 36 77 14 5 1 10 1 0 0 ; 2
i1 160.0000000000 64 77 34 5 1 10 1 0 0 ; 2
i1 224.0000000000 36 77 20 5 1 10 1 0 0 ; 2
i1 256.0000000000 120 81 0 6 1 8 1 0 0 ; 2
i1 384.0000000000 120 79 0 6 1 8 1 0 0 ; 2
i1 512.0000000000 36 77 14 5 1 4 1 0 254 ; 2
i1 544.0000000000 70 77 34 5 1 4 1 0 254 ; 2
i1 608.0000000000 28 77 20 5 1 4 1 0 254 ; 2
i1 640.0000000000 36 77 14 5 1 8 1 0 254 ; 2
i1 672.0000000000 70 77 34 5 1 8 1 0 254 ; 2
i1 736.0000000000 28 77 20 5 1 8 1 0 254 ; 2
i1 768.0000000000 120 79 0 6 1 6 1 0 0 ; 2
i1 896.0000000000 32 77 14 5 1 4 1 0 0 ; 2
i1 928.0000000000 64 77 34 5 1 4 1 0 0 ; 2
i1 992.0000000000 32 77 20 5 1 4 1 0 0 ; 2
i1 0.0000000000 128 86 14 4 2 9 16 0 0 ; 3
i1 0.0000000000 128 86 25 4 2 9 16 0 0 ; 3
i1 0.0000000000 128 86 0 5 2 9 16 0 0 ; 3
i1 128.0000000000 128 83 0 5 2 7 16 0 0 ; 3
i1 128.0000000000 128 83 14 5 2 7 16 0 0 ; 3
i1 128.0000000000 128 83 25 5 2 7 16 0 0 ; 3
i1 256.0000000000 128 83 0 3 2 9 16 0 0 ; 3
i1 256.0000000000 32 83 0 5 2 9 16 0 0 ; 3
i1 256.0000000000 32 83 14 5 2 9 16 0 0 ; 3
i1 256.0000000000 32 83 25 5 2 9 16 0 0 ; 3
i1 288.0000000000 64 83 34 4 2 9 16 0 0 ; 3
i1 288.0000000000 64 83 8 5 2 9 16 0 0 ; 3
i1 288.0000000000 64 83 20 5 2 9 16 0 0 ; 3
i1 352.0000000000 32 83 25 4 2 9 16 0 0 ; 3
i1 352.0000000000 32 83 0 5 2 9 16 0 0 ; 3
i1 352.0000000000 32 83 14 5 2 9 16 0 0 ; 3
i1 384.0000000000 128 83 0 5 2 6 16 0 0 ; 3
i1 384.0000000000 128 83 14 5 2 6 16 0 0 ; 3
i1 384.0000000000 128 83 25 5 2 6 16 0 0 ; 3
i1 512.0000000000 128 83 0 5 2 8 16 0 0 ; 3
i1 512.0000000000 128 83 14 5 2 8 16 0 0 ; 3
i1 512.0000000000 128 83 25 5 2 8 16 0 0 ; 3
i1 640.0000000000 128 86 14 4 2 9 16 0 0 ; 3
i1 640.0000000000 128 86 25 4 2 9 16 0 0 ; 3
i1 640.0000000000 128 86 0 5 2 9 16 0 0 ; 3
i1 768.0000000000 128 83 0 3 2 9 16 0 0 ; 3
i1 768.0000000000 32 83 0 5 2 9 16 0 0 ; 3
i1 768.0000000000 32 83 14 5 2 9 16 0 0 ; 3
i1 768.0000000000 32 83 25 5 2 9 16 0 0 ; 3
i1 800.0000000000 64 83 34 4 2 9 16 0 0 ; 3
i1 800.0000000000 64 83 8 5 2 9 16 0 0 ; 3
i1 800.0000000000 64 83 20 5 2 9 16 0 0 ; 3
i1 864.0000000000 32 83 0 5 2 9 16 0 0 ; 3
i1 864.0000000000 32 83 14 5 2 9 16 0 0 ; 3
i1 864.0000000000 32 83 25 5 2 9 16 0 0 ; 3
i1 896.0000000000 128 83 0 3 2 8 16 0 0 ; 3
i1 896.0000000000 32 83 0 5 2 8 16 0 0 ; 3
i1 896.0000000000 32 83 14 5 2 8 16 0 0 ; 3
i1 896.0000000000 32 83 25 5 2 8 16 0 0 ; 3
i1 928.0000000000 64 83 20 4 2 8 16 0 0 ; 3
i1 928.0000000000 64 83 34 4 2 8 16 0 0 ; 3
i1 928.0000000000 64 83 8 5 2 8 16 0 0 ; 3
i1 992.0000000000 32 83 0 5 2 8 16 0 0 ; 3
i1 992.0000000000 32 83 14 5 2 8 16 0 0 ; 3
i1 992.0000000000 32 83 25 5 2 8 16 0 0 ; 3
i99 0 1056 1.5
</CsScore>
</CsoundSynthesizer>