;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,    50,    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,     160,   512, 0
;TEXT BOXES												TYPE | FONT | SIZE | WIDTH | HEIGHT | X | Y
ih		 	FLbox  	"              pchbend - Diskin Playback Speed 2              ", 	1,      5,     14,    490,    20,     5,  0
ih		 	FLbox  	"-------------------------------------------------------------", 	1,      5,     14,    490,    20,     5,  20
ih		 	FLbox  	"This example is similar to the previous one except that how  ", 	1,      5,     14,    490,    20,     5,  40
ih		 	FLbox  	"the pchbend output is mapped to diskin playback speed is     ", 	1,      5,     14,    490,    20,     5,  60
ih		 	FLbox  	"different. At the pitch bend wheel's equilibrium position    ", 	1,      5,     14,    490,    20,     5,  80
ih		 	FLbox  	"playback speed is normal, at its maximum position playback   ", 	1,      5,     14,    490,    20,     5, 100
ih		 	FLbox  	"speed doubled and at its minimum position playback speed is  ", 	1,      5,     14,    490,    20,     5, 120
ih		 	FLbox  	"halved.                                                      ", 	1,      5,     14,    490,    20,     5, 140
			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, 1
	kratio	=	cpsoct(8+kbend)/cpsoct(8)
	kratio	portk	kratio, kporttime
	
	if	gksource!=0	kgoto	SKIP1
	asig	diskin2	"808loopMono.wav", kratio, 0, 1
	SKIP1:
	
	if	gksource!=1	kgoto	SKIP2
	asig	diskin2	"AndItsAll.wav", kratio, 0, 1
	SKIP2:
		outs	asig, asig
endin

</CsInstruments>

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

</CsoundSynthesizer>