// This is my utterly fantastic Super Collider Patch. Bow before me in owe of my programming genius.

// Bellow is the synth

(
SynthDef("sam", { arg freq;
	var f, g, osc;
	f = LFSaw.kr(freq, 0, 34, LFSaw.kr([8,7.29], 0, 6, 45)).midicps; // glissando function
	osc = CombN.ar(SinOsc.ar(f, 0, 0.08), 0.1, 0.4, 3); // echoing sine wave
	Out.ar(0, osc);
}).writeDefFile;
s.sendSynthDef("sam");
)

//This is the GUI.

(		
var w, b3, slider1, numbox1, textstring1;
w = SCWindow("sams bubbly randomness.", Rect(100, 800, 500, 500));
w.front;

b3 = SCButton(w, Rect(300, 50, 100, 40));        // This one starts and stops the synth
b3.states = [
                ["samstart", Color.blue, Color.red],
                ["samstop", Color.blue, Color.yellow],
                        ];
b3.action = { arg view;
                if (b3.value == 1, {
                                
                                s.sendMsg("/s_new", "sam", 1001, 0, 0, "z", 80);

                },{
                                
                                s.sendMsg("/n_free", 1001);
                });
};

slider1 = SCSlider(w, Rect(25, 100, 50, 300));	// this is the slider that affects the frequency of the synth
slider1.action = {
                var val;
//              val = ((800*slider1.value)+80);
                val = ((100*slider1.value));
                s.sendMsg("/n_set", 1001, "freq", val);
                numbox1.value = val;               // This will set the value of number box 1 = value of slider 1
};

numbox1 = SCNumberBox(w, Rect(25, 75, 50, 20));

textstring1 = SCStaticText(w, Rect(200, 25, 125, 370));
textstring1.string = "To the left is a slider that affects the frequency of the sound. Above the slider is a number box that informs you of the frequency value!!";
textstring1.font = Font("Futura-Medium", 14);

)