<CsoundSynthesizer>

<CsOptions>
-odevaudio -b400
</CsOptions>

<CsInstruments>

sr 		= 	44100	;SAMPLE RATE
kr 		= 	4410	;CONTROL RATE
ksmps 		= 	10	;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
nchnls 		= 	2	;NUMBER OF CHANNELS (2=STEREO)
0dbfs	=	1	;MAXIMUM SOUND INTENSITY LEVEL REGARDLESS OF BIT DEPTH

;FLTK INTERFACE CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FLcolor	255, 255, 255, 0, 0, 0
;				LABEL                       | WIDTH | HEIGHT | X | Y
			FLpanel	"White Noise / Pink Noise",    500,    255,    0,  0

;BORDERS				TYPE | FONT | SIZE | WIDTH | HEIGHT | X | Y
ihwhitebox		 	FLbox  	" ", 	6,      9,     15,    490,    145,    5,  5
ihpinkbox		 	FLbox  	" ", 	6,      9,     15,    490,     95,    5,155
FLsetColor	255, 255, 255, ihwhitebox	;SET PRIMARY COLOUR TO WHITE
FLsetColor	255, 200, 200, ihpinkbox	;SET PRIMARY COLOUR TO PINK

;SWITCHES  	                                  		ON | OFF | TYPE | WIDTH | HEIGHT | X | Y | OPCODE | INS | STARTTIM | DUR
gkwhite, ihwhite		FLbutton	"White Noise",	1,    0,    22,     150,     25,  10, 10,    0,     1,      0,       -1
gkpink, ihpink			FLbutton	"Pink Noise",	1,    0,    22,     150,     25,  10,160,    0,     2,      0,       -1
FLsetColor2	255, 255, 50, ihwhite	;SET SECONDARY COLOUR TO YELLOW
FLsetColor2	255, 255, 50, ihpink	;SET SECONDARY COLOUR TO YELLOW

;VALUE DISPLAY BOXES		LABEL  | WIDTH | HEIGHT | X | Y
idwhiteamp		FLvalue	" ",      100,     20,   10,  70
idbeta			FLvalue	" ",      100,     20,   10, 120
idpinkamp		FLvalue	" ",      100,     20,   10, 220

;SLIDERS				            		MIN | MAX | EXP | TYPE |    DISP   | WIDTH | HEIGHT | X  | Y
gkwhiteamp, ihwhiteamp		FLslider 	"Amplitude",	0,     1,    0,   23,   idwhiteamp,   480,     25,   10,   45
gkbeta, ihbeta			FLslider 	"Beta",		0,     1,    0,   23,       idbeta,   480,     25,   10,   95
gkpinkamp, ihpinkamp		FLslider 	"Amplitude",	0,     1,    0,   23,    idpinkamp,   480,     25,   10,  195

;SET INITIAL VALUES FOR SLIDERS 	|VALUE | HANDLE
			FLsetVal_i	0, 	ihbeta
			FLsetVal_i	0.3, 	ihwhiteamp
			FLsetVal_i	0.3, 	ihpinkamp

				FLpanel_end

;INSTRUCTIONS AND INFO PANEL                 WIDTH | HEIGHT | X | Y
				FLpanel	" ", 500,     120,   512, 0
;TEXT BOXES												TYPE | FONT | SIZE | WIDTH | HEIGHT | X | Y
ih		 	FLbox  	"                white noise / pink noise                     ", 	1,      5,     14,    490,    15,     5,  0
ih		 	FLbox  	"-------------------------------------------------------------", 	1,      5,     14,    490,    15,     5,  20
ih		 	FLbox  	"This example demonstrates the opcodes 'noise' and 'pinkish'  ", 	1,      5,     14,    490,    15,     5,  40
ih		 	FLbox  	"which might form useful sources sounds for subtractive       ", 	1,      5,     14,    490,    15,     5,  60
ih		 	FLbox  	"synthesis.                                                   ", 	1,      5,     14,    490,    15,     5,  80
ih		 	FLbox  	"Noise produces white noise and pinkish produces pink noise.  ", 	1,      5,     14,    490,    15,     5, 100

				FLpanel_end

				FLrun	;RUN THE FLTK WIDGET THREAD
;END OF FLTK INTERFACE CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

instr	1	;WHITE NOISE
	if	gkwhite!=0	goto	CONTINUE	;SENSE FLTK ON/OFF SWITCH FOR 'WHITE NOISE' - IF 'ON' JUMP TO LABEL 'CONTINUE'
				turnoff			;TURN THIS INSTRUMENT OFF IMMEDIATELY
	CONTINUE:					;LABEL 'CONTINUE'
	asig 	noise 	gkwhiteamp, gkbeta	;GENERATE WHITE NOISE
		outs	asig, asig		;SEND AUDIO SIGNAL TO OUTPUTS
endin

instr	2	;PINK NOISE
	if	gkpink!=0	goto	CONTINUE	;SENSE FLTK ON/OFF SWITCH FOR 'PINK NOISE' - IF 'ON' JUMP TO LABEL 'CONTINUE'
				turnoff			;TURN THIS INSTRUMENT OFF IMMEDIATELY
	CONTINUE:					;LABEL 'CONTINUE'
	asig	pinkish	gkpinkamp     	;GENERATE PINK NOISE
		outs	asig, asig	;SEND AUDIO SIGNAL TO OUTPUTS
endin

</CsInstruments>

<CsScore>
f 0 3600	;DUMMY SCORE EVENT - ALLOWS REALTIME PERFORMANCE FOR 1 HOUR
</CsScore>

</CsoundSynthesizer>
