;Written by Iain McCurdy, 2006

<CsoundSynthesizer>

<CsOptions>
-odevaudio -b400
</CsOptions>

<CsInstruments>

;USING THE OPCODE FLvalue TO DISPLAY THE OUTPUT OF A SLIDER 

sr		=	44100
kr		=	441
ksmps		=	100
nchnls		=	2
0dbfs		=	1	;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH

		FLpanel	"Value Display Box", 900, 200, 50, 50
		
iwidth		=	80	;WIDTH OF THE VALUE DISPLAY BOX IN PIXELS                                            
iheight		=	20	;HEIGHT OF THE VALUE DISPLAY BOX IN PIXELS                                           
ix		=	35	;DISTANCE OF THE LEFT EDGE OF THE VALUE DISPLAY BOX FROM THE LEFT EDGE OF THE PANEL  
iy		=	55	;DISTANCE OF THE TOP EDGE OF THE VALUE DISPLAY BOX FROM THE TOP EDGE OF THE PANEL    
idisp		FLvalue	"Hertz", iwidth, iheight, ix, iy

gkfreq, ihandle	FLslider	"Frequency", 50, 5000, -1, 5, idisp, 750, 30, 125, 50
		FLsetVal_i	500, ihandle

FLcolor	200, 200, 255, 0, 0, 50	;SET INTERFACE COLOURS
ih	 FLbox  "                                                                  FLvalue                                                      ", 		1,    5,   12, 900, 20,0,120
ih	 FLbox  "-------------------------------------------------------------------------------------------------------------------------------", 		1,    5,   12, 900, 20,0,140
ih	 FLbox  "FLvalue creates a box which outputs, in numerical form, the current value of a valuator widget. It communicates with the       ", 		1,    5,   12, 900, 20,0,160
ih	 FLbox  "valuator via its display handle.                                                                                               ", 		1,    5,   12, 900, 20,0,180


		FLpanel_end	;END OF PANEL CONTENTS
		FLrun		;RUN THE WIDGET THREAD!

gisine	ftgen 0, 0, 65536, 10, 1		;FUNCTION TABLE THAT DEFINES A SINGLE CYCLE OF A SINE WAVE

instr 1
	kporttime	linseg	0,0.001,0.005,1,0.005	;CREATE A VARIABLE FUNCTION THAT RAPIDLY RAMPS UP TO A SET VALUE
	kfreq		portk	gkfreq, kporttime	;SMOOTH SLIDER VARIABLE
	afreq		interp	kfreq		;INTERPOLATE AND CREATE AN AUDIO RATE VERSION OF K-RATE VARIABLE
	ifn		=	1
	asig		oscili	0.1, afreq, gisine
			outs	asig, asig
endin	

</CsInstruments>

<CsScore>
i 1 0 3600		;INSTRUMENT 1 WILL PLAY A NOTE FOR 1 HOUR
</CsScore>

</CsoundSynthesizer>