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

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

