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

Re: [sc-users] Using GUI.button




Am 24.10.2007 um 23:27 schrieb Björn Kessler:

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:



Yes, I think. It's the semicolon in the action function definition, in the conditional, between the true and false functions. It works okay with a comma there.




(
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.
_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users