// Pitchshift of input
(
SynthDef("pitchshifter", { arg pitch=1, pitchDisp=1, timeDisp=0.5, amp=0.8;
			var input, shift;
			input = AudioIn.ar([1,2]);
			shift = PitchShift.ar(input, 0.5, pitch, pitchDisp, timeDisp, amp);
			Out.ar(0, shift);
}).writeDefFile;
)

(
var w, s, b1, b2, b3, sl1, sl2, sl3, sl4;
s = Server.local;

w = SCWindow("PitchShifter", Rect(100, 800, 300, 450));
w.front;

b1 = SCButton(w, Rect(5, 0, 150, 24));
b1.states = [
		["Start Server", Color.black, Color.green],
		["Stop Server", Color.white, Color.red],
			];
b1.action = {
		if (b1.value == 1, {
				s.boot;
		},{
				s.quit;
		});
};

b2 = SCButton(w, Rect(5, 30, 150, 24));
b2.states = [
		["Load SynthDef", Color.black, Color.green]
			];
b2.action = {
	s.sendSynthDef("pitchshifter");
};

b3 = SCButton(w, Rect(5, 60, 150, 24));
b3.states = [
		["Play", Color.black, Color.green],
		["Stop", Color.white, Color.red],
			];
b3.action = { arg view;
		if (b3.value == 1, {
				s.sendMsg("/s_new", "pitchshifter", 1000, 1, 0);
		},{
				s.sendMsg("/n_free", 1000);
		});
};

sl1 = SCSlider(w, Rect(5, 100, 25, 300));
sl1.action = {
		var val;
		val = (4*sl1.value);
		val.postln;
		s.sendMsg("/n_set", 1000, "pitch", val);
};

sl2 = SCSlider(w, Rect(35, 100, 25, 300));
sl2.action = {
		var val;
		val = (5*sl2.value);
		val.postln;
		s.sendMsg("/n_set", 1000, "pitchDisp", val);
};

sl3 = SCSlider(w, Rect(65, 100, 25, 300));
sl3.action = {
		var val;
		val = ((sl3.value)/2);
		val.postln;
		s.sendMsg("/n_set", 1000, "timeDisp", val);
};

sl4 = SCSlider(w, Rect(95, 100, 25, 300));
sl4.action = {
		var val;
		val = sl4.value;
		val.postln;
		s.sendMsg("/n_set", 1000, "amp", val);
};
)