[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-users] Pause a Routine (AppClock)
hello
Does anyone know what I am missing here?
I am trying the pause a Routine. It uses AppClock because of the Slider
set...
when I just use ~f1.stop = it works, but can not restart it later:(
thank in advance :
Krisztian
code:
(
//m = TabFileReader.read("/Users/krisztianhofstadter/Desktop/EEG/SC\
read/_exported_data/sustainarrays.txt").postcs;
//m[1];
//m[2];
//m[3];
//m[4];
m = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8, 0.9, 1.0];
SynthDef("ch1", { |freq = 400, amp = 0.05, sustain = 1, pan = 0|
var sound, out, envgen;
envgen = amp * EnvGen.kr(Env.perc(0.01, sustain), doneAction: 2 );
sound = { SinOsc.ar(freq)};
Out.ar( 0, Pan2.ar(sound * envgen,pan))
}).play(s);
)
(
var window = SCWindow.new("0610279_EEG16",Rect(165, 200, 350, 530)).front;
var synthL1, nBL1Synth, sustainSpecL1;
var fs1, fading1;
var randomButton;
var currentSustain = m[1];
var currentSlide = ~slideSynthL1;
~slideSynthL1;
~abc = 0.1;
sustainSpecL1 = [0.1, 5.0, \lin].asSpec;
//BOXES AND SLIDERS
nBL1Synth = SCNumberBox.new(window,Rect(50, 230, 30, 20));
~slideSynthL1 =
SCSlider.new(window,Rect(80, 230, 40, 20))
.valueAction_(~abc)
.action_({
synthL1.set(\sustain, ~slideSynthL1.value);
nBL1Synth.value_(~slideSynthL1.value);
nBL1Synth.value.postln;
})
.focusColor_(Color.red(alpha:0.2));
nBL1Synth.value_(~slideSynthL1.value);
//_____________________BUTTON____________________
randomButton = Button(window, Rect(50, 20, 70, 20))
.states_([
["start", Color.black, Color.red],
["pause", Color.white, Color.black],
])
.action_({ arg butt;
if(butt.value==1, {AppClock.play(~f1)}, {AppClock.stop(~f1)});
});
//---------------------------------------------
//Store arrays into streams
fading1 = Pseq.new((m), 6).asStream.postln;
~f1 = Routine ({
var myfading1;
(m[1].size)*40.do({
~abc = fading1.next.asFloat;
[~abc, ~abc.class].postln;
~slideSynthL1.valueAction_(~abc);
1.wait; //change time does rrand work?
});
});
~r1 = Task ({
40.do({
synthL1 =
Synth(\ch1, [freq: 500, amp: 0.5, sustain:
sustainSpecL1.map(~abc), pan: -1]);
1.wait;
});
});
~r1.start;
)
AppClock.play(~f1); //Have to use AppClock because of Slider
AppClock.stop(~f1);
~f1.stop; //works but also clears everything
--
View this message in context: http://www.nabble.com/Pause-a-Routine-%28AppClock%29-tp22295676p22295676.html
Sent from the Supercollider - User mailing list archive at Nabble.com.
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/