;WRITTEN BY IAIN MCCURDY, 2010

<CsoundSynthesizer>

<CsOptions>
-odac4 -b2048 -B4096 --displays
</CsOptions>

<CsInstruments>

sr	= 	44100
ksmps	= 	100
nchnls	= 	2
0dbfs	=	1

;				LABEL          | WIDTH | HEIGHT | X | Y
FLcolor	255, 255, 255, 0, 0, 0
;INSTRUCTIONS AND INFO PANEL
				FLpanel	" ", 500, 220, 30, 550
;TEXT BOXES												TYPE | FONT | SIZE | WIDTH | HEIGHT | X | Y
ih		FLbox  	"                            xyin                             ", 	1,      5,     14,    490,    15,     5,  0
ih		FLbox  	"-------------------------------------------------------------", 	1,      5,     14,    490,    15,     5,  20
ih		FLbox  	"xyin creates a mouse position sensitive window.              ", 	1,      5,     14,    490,    15,     5,  40
ih		FLbox  	"In this example x-position controls frequency of an          ", 	1,      5,     14,    490,    15,     5,  60
ih		FLbox  	"oscillator and y-position controls its amplitude.            ", 	1,      5,     14,    490,    15,     5,  80
ih		FLbox  	"It my be required to include the '--displays' command line   ", 	1,      5,     14,    490,    15,     5, 100
ih		FLbox  	"flag for it to function.                                     ", 	1,      5,     14,    490,    15,     5, 120

				FLpanel_end

FLrun

gisine	ftgen	0,0,1024,10,1

instr		1		;READ CONTROLLERS, SCAN FOR THRESHOLD CROSSING, OUTPUT CONTROLLER VALUES TO DISPLAY
	iporttime	=	0.05				;PORTAMENTO TIME VARIABLE
	kporttime	linseg	0,0.001,iporttime,1,iporttime	;CREATE A RAMPING UP VARIABLE THAT WILL BE USED FOR PORTAMENTO TIME

	iprd	=	0.1	;PERIOD OF TIME TO RE-SENSE
	ixmin	=	0	;X MINIMUM
	ixmax	=	1	;X MAXIMUM
	iymin	=	0	;Y MINIMUM
	iymax	=	1	;Y MAXIMUM
	ixinit	=	0.1	;X INITIAL VALUE
	iyinit	=	0.1	;Y INITIAL VALUE
	kx, ky xyin iprd, ixmin, ixmax, iymin, iymax, ixinit, iyinit	;CREATE AN xyin PANEL
	
	koct	=	(kx*2)+9		;RESCALE x VARIABLE FOR USE AS AN OCT FORMAT PITCH VALUE
	kcps	=	cpsoct(koct)		;CONVERT OCT-FORMAT PITCH VALUE TO CPS-FORMAT
	kcps	portk	kcps,kporttime		;APPLY PORTAMENTO TO VARIABLE
	kamp	portk	ky, kporttime           ;APPLY PORTAMENTO TO VARIABLE
	a1	oscili	kamp, kcps, gisine	;CREATE AN OSCILLATOR
	outs	a1,a1				;SEND AUDIO TO OUTPUTS
endin

</CsInstruments>

<CsScore>
i 1 0 3600	;INSTRUMENT 1 PLAYS A NOTE FOR 1 HOUR (AND KEEPS REAL-TIME PERFORMANCE GOING)
</CsScore>

</CsoundSynthesizer>