;Written by Iain McCurdy, 2006

<CsoundSynthesizer>

<CsOptions>
-odevaudio -M0 -b400
</CsOptions>

<CsInstruments>
sr 		= 	44100	;SAMPLE RATE
ksmps 		= 	10	;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls 		= 	2	;NUMBER OF CHANNELS (2=STEREO)

;FLTK INTERFACE CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FLcolor	255, 255, 255, 0, 0, 0
;			LABEL		    WIDTH | HEIGHT | X | Y
	FLpanel		"pchbend - diskin",  500,    200,    0,  0
;COUNTERS						MIN | MAX | STEP1 | STEP2 | TYPE | WIDTH | HEIGHT | X |  Y  | OPCODE
gksource, ihsource	FLcount  "0=Drums 1=Voice", 	0,     1,     1,      1,      2,    200,     30,   150,  0,    -1

;SET INITIAL VALUES FOR SLIDERS 	|VALUE | HANDLE
			FLsetVal_i	0,	ihsource

			FLpanel_end

;INSTRUCTIONS AND INFO PANEL                 WIDTH | HEIGHT | X | Y
				FLpanel	" ", 515,     200,   512, 0
;TEXT BOXES												TYPE | FONT | SIZE | WIDTH | HEIGHT | X | Y
ih		 	FLbox  	"              pchbend - Diskin Playback Speed 1              ", 	1,      5,     14,    490,    20,     5,  0
ih		 	FLbox  	"-------------------------------------------------------------", 	1,      5,     14,    490,    20,     5,  20
ih		 	FLbox  	"In this example the pitch bend wheel is used to control the  ", 	1,      5,     14,    490,    20,     5,  40
ih		 	FLbox  	"playback speed of a diskin file player.                      ", 	1,      5,     14,    490,    20,     5,  60
ih		 	FLbox  	"The range for playback speed is -2 to 2. Therefore at its    ", 	1,      5,     14,    490,    20,     5,  80
ih		 	FLbox  	"maximum position the playback speed will be double normal    ", 	1,      5,     14,    490,    20,     5, 100
ih		 	FLbox  	"speed and forwards (2) and at its minimum position the       ", 	1,      5,     14,    490,    20,     5, 120
ih		 	FLbox  	"playback speed is double normal speed and backwards (-2). At ", 	1,      5,     14,    490,    20,     5, 140
ih		 	FLbox  	"the equilibrium position playback speed will be zero,        ", 	1,      5,     14,    490,    20,     5, 160
ih		 	FLbox  	"therefore silence.                                           ", 	1,      5,     14,    490,    20,     5, 180
			FLpanel_end
			FLrun	;RUN THE FLTK WIDGET THREAD
;END OF FLTK INTERFACE CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

instr	1
	iporttime	=	.01
	kporttime	linseg	0, .001, iporttime, 1, iporttime
	
	kbend	pchbend	0, 2	;PITCH BEND VARIABLE (IN oct FORMAT)
	kbend	portk	kbend, kporttime
	
	if	gksource!=0	kgoto	SKIP1
	asig	diskin2	"808loopMono.wav", kbend, 0, 1
	SKIP1:
	
	if	gksource!=1	kgoto	SKIP2
	asig	diskin	"AndItsAll.wav", kbend, 0, 1
	SKIP2:
		outs	asig, asig
endin

</CsInstruments>

<CsScore>
f 0 86400	; ALLOWS REALTIME MIDI PLAYING FOR 1 DAY
</CsScore>

</CsoundSynthesizer>