0dbfs = 100
nchnls = 2
sr = 44100

; p2 when
; p3 dur
; p4 vol
; p5 freq

givol ftgen 1, 0, 10000, 25, \
	500, 60, \
	1000, 20, \
	7000, 3, \
	10000, 5
gipian ftgen 2, 0, 10000, 10, \
	1, 0.5, 0.3, 0.25, 0.2, 0.167, 0.14, 0.125, .111

instr sine
	tigoto skipinit
	kt init 0
	al init 1.0
	ifreq = p5
	ichime = p6

	ivol = 30 * p4 * table(ifreq, givol)

	aw oscils ivol, ifreq, 0
	af oscils ivol, ifreq * ichime, 0
	skipinit:
	kt = kt + (1/kr)
	kv bpf kt, 0,0, 0.5,0.8, .1,1, 1,.6
	at linseg 0, p3, 1

	if p3 >= 0 then
		aw = aw * (1 - at)
		aw = aw + (af * at)
		aw = aw * (1-at)
	endif

	out aw*al
endin

instr string
	tigoto skipinit
	; initialize
	ivol = 30*p4
	ifreq = p5

	aw pluck ivol, ifreq, ifreq, 0, 3, p6
	skipinit:
	at linseg 1, p3, 0

	if p3 >= 0 then
		aw = aw * at
	endif
	out aw
endin


instr warbulator
	tigoto skipinit
	irange = p6
	ifreq = p5
	ivol = p4 * 40 * table(ifreq, givol)

	ata poscil 1.0, 100
	atf poscil 1.0, bpf(ata, 0,1, 1,100) 
	atq poscil 1.0, bpf(atf, 0,ifreq, 1,ifreq*irange) 
	skipinit:

	aw = atq
	
	if p3 >= 0 then
		at linseg 1, p3, 0
		aw = aw * at
	endif
	out ivol * aw
endin

instr bell
	tigoto skipinit
	ifreq = p5
	ivol = p4 * 40 * table(ifreq, givol)
	at poscil 1.0, ifreq*2
	af poscil 1.0, bpfcos(at, 0,ifreq, 1,ifreq*2.5)

	skipinit:
	aw = af
	if p3 >= 0 then
		at linseg 1, p3, 0
		aw = aw * at
	endif
	out ivol * aw
endin
