[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-users] Using GUI.button
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.>
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.