[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] SuperCollider Volume Control?



Ah, thanks Sciss,

i see at least three mistakes:

So, how many others? :)

-a-

// Utility class for a simple general volume
// andrea after Josh, with comments by Sciss

/*
// 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 ?? (Server.default) ;
if ( server.serverRunning.not, { server.boot }) ;
server.doWhenBooted({
this.sendDef ;
}) ;
volume = 1 ;
}

sendDef {
amp = Synth.basicNew(\amp, server) ;
SynthDef(\amp, { arg inbus, amp = 1;
ReplaceOut.ar( inbus, In.ar(inbus, 2) * amp );
}).send(server, amp.newMsg( 0, [ \amp, volume ], \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
--------------------------------------------------


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)