Josh,
I was going to write exactly a little utility class with the
proposed mechanism, so I used yours (thanks!).
Now, I have to pass the constructor a server, I was thinking I
could refer to Server.default inside the class (i.e. without
passing a server), but doesn't work in this way.
What am I missing?
Best
-a-
// Utility class for a simple general volume
// andrea after Josh
/*
// a sound
{SinOsc.ar(mul:0.1)}.play
v = Volume.new(s) ;
v.gui ;
v.volume_(0.5) ;
v.volume ;
*/
Volume {
var server, amp, <>window, <volume ;
var slider, box ;
*new { arg server ;
^super.new.initVolume(server) ;
}
initVolume { arg aServer ;
server = aServer ;
if ( server.serverRunning.not, { server.boot }) ;
//server = Server.default.boot ;
server.doWhenBooted({
this.sendDef ;
}) ;
volume = 1 ;
}
sendDef {
SynthDef(\amp, { arg inbus, amp = 1;
ReplaceOut.ar( inbus, In.ar(inbus, 2) * amp );
}).send(server);
amp = Synth(\amp, target: 0, addAction: \addToTail) ;
}
// cleaner with MVC
volume_ { arg aVolume ;
volume = aVolume ;
amp.set([\amp, volume]) ;
box.value_(aVolume) ;
slider.value_(aVolume) ;
}
gui {
window = GUI.window.new("Volume", Rect(100, 100, 60, 320)).front;
box = GUI.numberBox.new(window, Rect(10, 10, 60, 30))
.value_(volume) ;
slider = GUI.slider.new(window, Rect(10, 40, 60, 280))
.value_(volume) ;
slider.action_({ arg item ;
volume = item.value ;
amp.set([\amp, volume]) ;
box.value_(volume) ;
}) ;
box.action_({ arg item ;
volume = item.value ;
amp.set([\amp, volume]) ;
slider.value_(volume)
}) ;
}
}
--------------------------------------------------
Andrea Valle
--------------------------------------------------
CIRMA - DAMS
Università degli Studi di Torino
--> http://www.cirma.unito.it/andrea/
--> andrea.valle@xxxxxxxx
--------------------------------------------------
I did this interview where I just mentioned that I read Foucault.
Who doesn't in university, right? I was in this strip club giving
this guy a lap dance and all he wanted to do was to discuss
Foucault with me. Well, I can stand naked and do my little dance,
or I can discuss Foucault, but not at the same time; too much
information.
(Annabel Chong)
_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users