[sc-users] Using GUI.button
Björn Kessler
kebjoern at yahoo.de
Thu Oct 25 00:27:38 PDT 2007
Hi there,
can somebody explain that to me: I can use the button to make the synth run, but it doesn`t work if I want it to pause. Here is the code:
(
SynthDef( \wellen, {
arg freqPulse=10, freqModulation=1, phase=1, out=0;
var freqGrund, mul, klang, amp;
freqGrund=SinOsc.kr( freqModulation, 0, 50, 400 );
amp=SinOsc.kr( freqModulation, phase, 0.5, 0.5);
mul=(SinOsc.kr( freqPulse, 0, 0.5, 0.5 ) * amp);
klang=SinOsc.ar( freqGrund, 0, mul );
Out.ar( out, klang );
}).load( s );
)
(
var win, sli1, synth, butAnAus;
synth = Synth.newPaused( \wellen );
win = GUI.window.new( \window, Rect( 40, 0, 470, 300));
win.onClose = {synth.free;};
butAnAus = GUI.button.new( win, Rect( 10, 10, 40, 20));
butAnAus.states = [["Stop", Color.white, Color.red ],
[ "Play", Color.black, Color.green ]];
butAnAus.action = {
if( butAnAus.value == 1, {
synth.run( false );
}; {
synth.run( true );
});
};
sli1 = GUI.slider.new( win, Rect( 50, 10, 20, 240));
sli1.action = { synth.set( \freqModulation,
sli1.value.linexp( 0, 1, 0.2, 100 ));
};
win.front;
)
Help is highly appreciated.
Sincerely,
Björn
---------------------------------
Ihr erstes Baby? Holen Sie sich Tipps von anderen Eltern.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.create.ucsb.edu/pipermail/sc-users/attachments/20071024/c615bf29/attachment.htm
More information about the sc-users
mailing list