/*
RESERVED
p1 = instrument #
p2 = start time
p3 = duration

COMMON
p4 = amplitude (xamp in manual)
p5 = frequency (xcps in manual)

oscil: a simple oscillator.
oscil arguments: xamp, xcps, ifn [, iphs]
	xamp = amplitude
	xcps = frequency (in Hz)
	ifn = function table (requires wrap-around guard point)
(opt)	iphs = phasing (0.5=begins halfway through wave table, for example)

linen: applies a straight line rise and decay pattern to an input amp signal.
linen arguments: xamp, irise, idur, idec
	xamp = amplitude
	irise = rise time in seconds
	idur = overall duration in seconds
	idec = decay time in seconds

butterlp: a low-pass Butterworth filter.
butterlp arguments: asig, kfreq, [, iskip]
	asig = input signal to be filtered
	kfreq = cutoff or center frequency for each of the filters.
(opt)	iskip = skip initialization and non-zero, default is 0

rand: generates a controlled random # series
rand arguments: xamp
	xamp = range over which #'s are distributed

butterbp: a band-pass Butterworth filter.
butterbp arguments: asig, kfreq, kband [, iskip]
	asig = input signal to be filtered
	kfreq = cutoff or center frequency for each of the filters
	kband = bandwidth of the bandpass and bandreject filters
(opt)	iskip = skip initialization if present and non-zero, default is 0

GEN07: constructs functions from segments of straight lines
GEN07 syntax: f# time size 7 a n1 b n2 c ...
	f# = function table number
	time = ?
	size = number of points in the table, power of 2 or 2 plus 1
	a, b, c = ordinate values in odd-numbered p-fields
	n1, n2, n3 = ...
*/

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
kr = 441
ksmps = 100
nchnls = 1

;----------------------------;
;***Square/Sine Instrument***;
;----------------------------;
	instr	1
idur	=	p3
iamp	=	ampdb(p4)
ifrq	=	cpspch(p5)
iatk	=	p6
irel 	=	p7
ivibdel =	p8
imoddpt =	p9
imodfrq =	p10
kvibenv	linseg 0, ivibdel, 1, idur-ivibdel, 3
klfo	oscil	kvibenv*imoddpt, imodfrq, 1
kenv	linen	iamp, iatk, idur, irel
a1	oscil	kenv*.5, ifrq+klfo, 1
a2	oscil kenv, ifrq*2+klfo, 8
amix =	a1+a2
alpf		butterlp amix, 3000
out	alpf
	endin

;---------------------;
;***Bell Instrument***;
;---------------------;
	instr 2
idur =	p3
iamp = 	ampdb(p4)
ifrq = 	cpspch(p5)
iatk = 	p6
irel =	p7
icut = 	p8
kenv envlpx	iamp, iatk, idur, irel, 3, .001, .01
kenv2 linen	iamp, .001, idur, .5
a1 oscil  kenv, ifrq, 2
a2 oscil  kenv, ifrq*2, 2
a3 oscil  kenv, ifrq/2, 2
amix = a1+a2+a3
alpf butterlp amix*kenv2, icut
out	alpf
	endin

;----------------------;
;***Conga Instrument***;From the Csound Catalogue
;----------------------;
	instr 3
idur   = p3
iamp   = p4
ifenv  = 51                    ; wood drum settings:
ifdyn  = 31                    ; amp and index envelopes see flow chart
ifq1   = cpspch(p5)*16         ; N1:N2 is 80:55 = 16:11, imax=25
if1    = 4                     ; duration = .2 sec
ifq2   = cpspch(p5)*11
if2    = 4
imax   = 25
aenv  oscili   iamp, 1/idur, ifenv             ; envelope
adyn  oscili   ifq2*imax, 1/idur, ifdyn        ; dynamic
amod  oscili   adyn, ifq2, if2                 ; modulator
a1    oscili   aenv, ifq1+amod, if1            ; carrier
out      a1
	endin

;----------------------;
;***Noise Percussion***;
;----------------------;
	instr	4
idur	=	p3
iamp	=	ampdb(p4)
ifrq	=	p5
iatk	=	p6
irel	=	p7
kenv expseg	.001, iatk, iamp, idur, iamp*.1, irel, .01
anoise rand	ifrq*kenv
abpf butterbp anoise, 2000, 100
out  	abpf
	endin

;----------------------------;
;***Double Drum Instrument***;From the Csound Catalogue
;----------------------------;
	instr 5
idur  =  p3
iamp7 =  p4
ifq1  =  p5
iamp2 =  p4 * .8
ifq3  =  p5 * .1
iamp4 =  p4 * .3
a5     randi   iamp7, 1500
a5     oscili  a5, 1/idur, 52
a5     oscili  a5, 2000, 5
a3     oscili  iamp4, 1/idur, 52
a3     oscili  a3, ifq3, 11
a1     oscili  iamp2, 1/idur, 50
a1     oscili  a1,    ifq1, 5
out     a1+a3+a5
	endin

;-------------------;
;***FM Instrument***;From the Csound Catalogue
;-------------------;
	instr 6
iamp			=	ampdb(p4)
ifc			=	p6*cpspch(p5)                           ; CARRIER FREQUENCY
ifm			=	p7*cpspch(p5)                           ; MODULATION FREQUENCY
kndx           envlpx    11, p3/2, p3, p3/2, 7, 1, .01         ; F7 IS STRAIGHT LINE
kamp           envlpx    iamp, .1*p3, p3, .2*p3, 7, .8, .01
amod           oscil     kndx*ifm, ifm, 6                      ; F6 IS SIMPLE SINE WAVE
asig           oscil     kamp, ifc+amod, 6
asigo          tone      asig, 9000                            ; I DON'T WANT FOLDOVER AS AN ADDED FACTOR.
out            asigo
	endin

;-----------------------;
;***Bamboo Instrument***;
;-----------------------;
	instr 7
a1  bamboo p4, 0.01
out a1
	endin

;----------------------------------------------------------------------------------------------------

</CsInstruments>
<CsScore>

a 0 0 0
t 0 45 32 50 48 55 52 60

;---------------------;
;***Function Tables***;
;---------------------;
;Function 1 uses the GEN07 subroutine to compute a square wave
f1	0	1024	7	1	512	1	0	-1	512	-1
;Function 2 uses the GEN10 subroutine to compute a sine wave
f2	0	4096	10	1
;Function 3 uses the GEN05 subroutine to compute an exponential Attack for use with envlpx
f3	0	513	5	.001	128	.8	128	.6	256	1
f4	0	512	10	1
f5	0	2048	10	1
f6	0	256	10	1
f7	0	257	7	0	256 1
;Function 8 uses the GEN10 subroutine to compute a sine wave
f8	0	4096	10	1
f11	0	512	9	10	1	0	16	1.5	0	22	2	0	23	1.5	0
f50	0	513	5	256	512	1
f52	0	513	5	4096	512	1
f31	0	512	7	1	64	0	448	0			; index envelope
f51	0	513	5	.8	113	1	10	1	390	.0001	; amplitude envelope

;-----------------------;
;***Pitch Names Macro***;
;-----------------------;
#define	C	#0.00+#
#define	Db	#0.01+#
#define	D	#0.02+#
#define	Eb	#0.03+#
#define	E	#0.04+#
#define	F	#0.05+#
#define	Gb	#0.06+#
#define	G	#0.07+#
#define	Ab	#0.08+#
#define	A	#0.09+#
#define	Bb	#0.10+#
#define	B	#0.11+#

;---------------------;
;***Drum Loop Macro***;
;---------------------;
#define	Drums	#
;-------------------------------------;
;inst	st	dur	db	frq	atk	rel;
;------------------------------------;
i 4	.5	.2	10	6000	.005	.1
i .	1.5	.	8	.	.	.3
i .	2.5	.	9	.	.	.1
i .	3.5	.	8	.	.	.3
i .	4.5	.	9	.	.	.1
i .	5.5	.	7	.	.	.3
i .	6.5	.	6	.	.	.1
i .	7.5	.	7	.	.	.2
i .	7.75	.	7	.	.	.3

;-------------------------;
;inst	st	dur	amp	pch;
;-------------------------;
i 3	0	.5	7000	0.00
i 3	.75	.	.	.
i 3	1.75	.	.	.
i 3	2	.	.	.
i 3	2.75	.	.	.
i 3	4	.	.	.
i 3	4.75	.	.	.
i 3	5.75	.	.	.
i 3	6	.	.	.
i 3	6.75	.	.	.
i 3	7.75	.	.	.

;-------------------------;
;inst	st	dur	amp	frq;
;-------------------------;
i 5	0     1	6000	100
i 5	.75	.	.	110
i 5	1.75	.	.	100
i 5	2	.	.	.
i 5	2.75	.	.	100
i 5	4	.	.	100
i 5	4.75	.	.	110
i 5	5.75	.	.	100
i 5	6	.	.	.
i 5	6.75	.	.	175
i 5	7.75	.	.	110#

;---------------------;
;***FM Pedal Macro***;
;-------------------;
#define	FMPedal(dec) #
i 6	0	8	$dec.	[$Eb.6]	1	1
i 6	4	8	$dec.	[$Eb.6]	1	1#


;BAR 1------------------------------------------------------------

;-----------------------;
;***Square Instrument***;
;-----------------------;
;---------------------------------------------------------------;
;inst	st	dur	db	pitch		atk	rel	del	modpt modfrq;
;--------------------------------------------------------------;
i 1	0	.5	55	[$Eb.8]	.3	.05	1.2	3	5
i .	+	.	57	[$Bb.8]	.	.	.	.	.
i .	+	.25	<	[$Ab.8]	.05	.	.	.	.
i .	+	.	<	[$Gb.8]	.	.	.	.	.
i .	+	.	48	[$F.8]	.	.	.	.	.
i .	+	.	>	[$Gb.8]	.	.	.	.	.
i .	+	.75	51	[$Ab.8]	.4	.	.	.	.
i .	+	.25	58	[$Bb.8]	.25	.	.	.	.
i .	+	.5	51	[$Ab.8]	.3	.	.	.	.
i .	+	.25	<	[$Gb.8]	.2	.	.	.	.
i .	+	.	<	[$F.8]	.	.	.	.	.
i . 	+	.75	55	[$F.8]	.5	.	.	.	.
i .	+	.125	58	[$Gb.8]	.05	.	.	.	.
i .	+	.	<	[$F.8]	.	.	.	.	.
i .	+	2	52	[$Eb.8]	.75	1.5	2	.	.
i .	7.75	.25	58	[$Db.8]	.3	.05	1	.	.

$FMPedal(50).

;BAR 5------------------------------------------------------------

b	8

;-----------------------;
;***Square Instrument***;
;-----------------------;
;---------------------------------------------------------------;
;inst	st	dur	db	pitch		atk	rel	del	modpt modfrq;
;--------------------------------------------------------------;
i 1	0	.5	60	[$Eb.8]	.3	.05	1.2	3	5
i .	+	.	>	[$Bb.8]	.	.	.	.	.
i .	+	.25	62	[$Db.9]	.05	.	.	.	.
i .	+	.	<	[$C.9]	.	.	.	.	.
i .	+	.	60	[$Bb.8]	.	.	.	.	.
i .	+	.	>	[$Ab.8]	.	.	.	.	.
i .	+	.75	62	[$Bb.8]	.4	.	.	.	.
i .	+	.25	<	[$Gb.8]	.25	.	.	.	.
i .	+	.5	55	[$Eb.8]	.3	.	.	.	.
i .	+	.25	>	[$Eb.8]	.2	.	.	.	.
i .	+	.	.	[$F.8]	.	.	.	.	.
i . 	+	.5	.	[$Gb.8]	.5	.	.	.	.
i .	+	.5	65	[$Ab.8]	.	.	.	.	.
i .	+	.25	<	[$Gb.8]	.05	.	.	.	.
i .	+	.	.	[$F.8]	.	.	.	.	.
i .	+	.	.	[$Eb.8]	.	.	.	.	.
i .	+	.	50	[$Db.8]	.	2	.	.	.
i 1	+	2	53	[$Eb.8]	.3	2	.	.	.

;---------------------;
;***Bell Instrument***;
;---------------------;
;---------------------------------------------------;
;inst	st	dur	db	pitch		atk	rel	cut	;
;--------------------------------------------------;
i 2	.25	.25	25 	[$Eb.11]	.25	.25	2500
i .	+	.75	.	[$Bb.11]	.	.75	.	
i .	1.25	.25	.	[$F.11]	.	.25	.	
i .	+	.75	.	[$Ab.11]	.	.75	.	
i .	2.25	.25	.	[$F.11]	.	.25	.	
i .	+	.75	.	[$Ab.11]	.	.75	.	
i .	3.25	.25	.	[$Bb.11]	.	.25	.	
i .	+	.75	.	[$Ab.11]	.	.75	.	
i .	4.25	.25	.	[$Gb.11]	.	.25	.	
i .	+	.75	.	[$Eb.11]	.	.75	.	
i .	5.25	.25	.	[$Db.11]	.	.25	.	
i .	+	.75	.	[$Eb.11]	.	.75	.	
i .	6.25	.25	.	[$Gb.11]	.	.25	.	
i .	+	.75	.	[$Eb.11]	.	.75	.	
i .	7.25	.25	.	[$Db.11]	.	.25	.	
i .	+	.75	.	[$Eb.11]	.	.75	.	

$FMPedal(50).

;BAR 9------------------------------------------------------------

b	16

$Drums.
$FMPedal(60).

;BAR 13------------------------------------------------------------

b	24

$Drums.
$FMPedal(65).

;-----------------------;
;***Square Instrument***;
;-----------------------;
;---------------------------------------------------------------;
;inst	st	dur	db	pitch		atk	rel	del	modpt modfrq;
;--------------------------------------------------------------;
i 1	0	1.5	70	[$Eb.8]	.5	.1	2	3	5	
i .	+	.5	>	[$F.8]	.2	.	.	.	.
i .	.	1.5	72	[$Gb.8]	.5	.	.	.	.
i .	.	.5	<	[$F.8]	.2	.	.	.	.
i .	.	1.5	70	[$Db.8]	1	.	.	.	.
i .	.	.5	>	[$Eb.8]	.2	.	.	.	.
i .	.	2	72	[$F.8]	1	.	.	.	.

;BAR 17------------------------------------------------------------

b	32

$Drums.
$FMPedal(65).

;-----------------------;
;***Square Instrument***;
;-----------------------;
;---------------------------------------------------------------;
;inst	st	dur	db	pitch		atk	rel	del	modpt modfrq;
;--------------------------------------------------------------;
i 1	0	1.5	70	[$Eb.8]	.5	.1	2	3	5
i .	+	.5	>	[$F.8]	.2	.	.	.	.	
i .	.	1.5	72	[$Gb.8]	.5	.	.	.	.
i .	.	.5	<	[$F.8]	.2	.	.	.	.
i .	.	1.5	70	[$Ab.8]	1	.	.	.	.
i .	.	.5	>	[$Gb.8]	.2	.	.	.	.
i .	.	2	72	[$F.8]	1	.	.	.	.
;--------------------;
;***Square Harmony***;
;--------------------;
;---------------------------------------------------------------;
;inst	st	dur	db	pitch		atk	rel	del	modpt modfrq;
;--------------------------------------------------------------;
i 1	0	1.5	60	[$Gb.8]	.5	.1	2	4	5
i .	+	.5	>	[$Ab.8]	.2	.	.	.	.
i .	.	1.5	62	[$Bb.8]	.5	.	.	.	.
i .	.	.5	<	[$Bb.8]	.2	.	.	.	.
i .	.	1.5	60	[$Eb.9]	1	.	.	.	.
i .	.	.5	>	[$Eb.9]	.2	.	.	.	.
i .	.	2	62	[$D.9]	1	.	.	.	.

;---------------------;
;***Bell Instrument***;
;---------------------;
;---------------------------------------------------;
;ins	st	dur	db	pitch		atk	rel	cut	;
;--------------------------------------------------;
i 2	.25	1	32 	[$Eb.11]	.25	1	1500
i 2	+	.	.	.		.	.	.	
i 2	.	.	.	[$Gb.11]	.	.	.	
i 2	.	.	.	.		.	.	.	
i 2	.	.	.	[$Ab.11]	.	.	.	
i 2	.	.	.	.		.	.	.		
i 2	.	.	.	[$D.11]	.	.	.	
i 2	.	.	.	.		.	.	.	
;------------------;
;***Bell Harmony***;
;------------------;
;---------------------------------------------------;
;ins	st	dur	db	pitch		atk	rel	cut	;
;--------------------------------------------------;
i 2	4.25	1	30 	[$Eb.11]	.25	1	1500
i 2	+	.	.	.		.	.	.	
i 2	.	.	.	[$F.11]	.	.	.	
i 2	.	.	.	.		.	.	.	


;BAR 13------------------------------------------------------------

b	40

$Drums.
$FMPedal(60).

i 7	0	1	20000

e

</CsScore>
</CsoundSynthesizer>
<MacOptions>
Version: 3
Render: Real
Ask: Yes
Functions: ioObject
Listing: Window
WindowBounds: 910 650 528 140
CurrentView: io
IOViewEdit: On
Options: -b128 -A -s -m167 -R
</MacOptions>
<MacGUI>
ioView background {32125, 41634, 41120}
</MacGUI>


