Discussion:
Wait for pattern to stop playing
Ali Rustamov
2014-09-05 18:41:16 UTC
Permalink
I want Routine to wait until Pattern stops playing, and then free some
Synths. Here is what I have for now. What is more elegant solution?

r = Routine({

~f[\chords1Res] = Synth.new(\Res);

~f[\chordsRes] = Synth.new(\Res1);

a = Pfindur(24, ~f[\chords]).play;

while({a.isPlaying}, {
1.wait;
});

~f[\chords1Res].free;
~f[\chordsRes].free;
});

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Daniel Mayer
2014-09-05 19:17:19 UTC
Permalink
Post by Ali Rustamov
I want Routine to wait until Pattern stops playing, and then free some
Synths.
Hi,

effort depends on how exact you need it.
If you use Pfindur and are ok
if Synth ends with duration passed to Pfindur you
can write something like that (with or without Routine)

x = (type: \on).play;


(
Pfindur(3,
Pbind(
\dur, 0.2,
\midinote, Pwhite(56, 59)
)
).play;

thisThread.clock.sched(3, { x.release });
)


If you don't know how long the pattern will play consider SimpleController

x = (type: \on).play;

(
p = Pbind(
\dur, Pwhite(0.01, 0.3, 20),
\midinote, Pwhite(56, 59)
).play;

SimpleController(p).put(\stopped, { x.release })
)


I don't remember if and where keywords, which are changing state
of the EventStreamPlayer are documented, at least you can look at
the file Stream.sc


Greetings

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Ali Rustamov
2014-09-05 19:20:16 UTC
Permalink
Thanks a lot. Will look at it
Post by Daniel Mayer
Post by Ali Rustamov
I want Routine to wait until Pattern stops playing, and then free some
Synths.
Hi,
effort depends on how exact you need it.
If you use Pfindur and are ok
if Synth ends with duration passed to Pfindur you
can write something like that (with or without Routine)
x = (type: \on).play;
(
Pfindur(3,
Pbind(
\dur, 0.2,
\midinote, Pwhite(56, 59)
)
).play;
thisThread.clock.sched(3, { x.release });
)
If you don't know how long the pattern will play consider SimpleController
x = (type: \on).play;
(
p = Pbind(
\dur, Pwhite(0.01, 0.3, 20),
\midinote, Pwhite(56, 59)
).play;
SimpleController(p).put(\stopped, { x.release })
)
I don't remember if and where keywords, which are changing state
of the EventStreamPlayer are documented, at least you can look at
the file Stream.sc
Greetings
Daniel
-----------------------------
www.daniel-mayer.at
-----------------------------
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Julian Rohrhuber
2014-09-05 19:35:02 UTC
Permalink
Post by Ali Rustamov
I want Routine to wait until Pattern stops playing, and then free some
Synths. Here is what I have for now. What is more elegant solution?
If you want to wait in a Routine for something to happen, "Condition" is useful. You can continue by calling a function from your pattern:

r = Routine({
var c = Condition.new;

~f[\chords1Res] = Synth.new(\Res);

~f[\chordsRes] = Synth.new(\Res1);

a = Pfindur(24, ~f[\chords]);
Pseq([a, (play: { c.unhang })]).play;
c.hang;

~f[\chords1Res].free;
~f[\chordsRes].free;
});
_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Ali Rustamov
2014-09-06 13:35:19 UTC
Permalink
I did not quite understood the Condition syntax in this example, but I
found that Pseq itself does it
(
r = Prout({

~f[\chords1Res] = Synth.new(\Res1);

~f[\chordsRes] = Synth.new(\Res);

Pseq([
Pfindur(24, ~f[\chords]),

Prout({
1.wait;
~f[\chords1Res].free;
~f[\chordsRes].free;
});
]).play;
})
)

On Fri, Sep 5, 2014 at 11:35 PM, Julian Rohrhuber
Post by Ali Rustamov
Post by Ali Rustamov
I want Routine to wait until Pattern stops playing, and then free some
Synths. Here is what I have for now. What is more elegant solution?
r = Routine({
var c = Condition.new;
~f[\chords1Res] = Synth.new(\Res);
~f[\chordsRes] = Synth.new(\Res1);
a = Pfindur(24, ~f[\chords]);
Pseq([a, (play: { c.unhang })]).play;
c.hang;
~f[\chords1Res].free;
~f[\chordsRes].free;
});
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Loading...