PHSparPlayer (PHelpSynthParPlayer) PHSpar player object
Part of: miSCellaneous
Inherits from: PHSusePlayer (PHelpSynthUsePlayer)
Implicitely instantiated when PHSpar's play method is called, allows stopping and resuming with options also concerning the help synth.
See also: Working with HS and HSpar, HSpar, PHSpar, PHSparUse, PHSusePlayer
Some Important Issues
Creation / Class Methods
*new (pHelpSynthPar)
Creates a new PHSparPlayer object.
phelpSynthPar - A PHSpar object.
Status control
play(clock, quant, hsPlay, switchPlay, pbindPlay, quantBufferTime)
clock - A TempoClock object. If not assigned, takes the default TempoClock.
quant - A Quant object. Makes the player start at the next grid that gives enough time for latency.
hsPlay - Boolean. Determines if help synth should start. Defaults to true.
switchPlay - Boolean. Determines if switch pattern should play. Defaults to true.
pbindPlay - Boolean. Determines if Pbind(s) should play. Defaults to true.
quantBufferTime - Number (seconds). Calculated time to include latency for "stepping in"
is lengthened by this value. Defaults to 0.2.
stop(hsStop, switchStop, pbindStop, addAction)
hsStop - Boolean. Determines if help synth should pause. Defaults to false.
switchStop - Boolean. Determines if switch pattern player should pause. Defaults to false.
pbindStop - Boolean. Determines if Pbind player(s) should pause. Defaults to true.
addAction - Function to be evaluated at receive time.
free
Stop the PHSparPlayer and all PHSusePlayers that are using the same HSpar, also free the HSpar.
Note: stop (pause) allows resuming the player - free resets, player can be started again.
Examples
(
s = Server.local;
s.boot;
)
// define PHSpar and several users
(
h = HSpar(s, [ { |freq = 2, dev = 7, center = 60|
LFDNoise3.kr(freq, dev, center) },
{ |freq = 5, dev = 10, center = 80|
LFDNoise3.kr(freq, dev, center) }
]);
~p1 = PHSpar(h, pbindArgs: [0.1, [\midinote, Pkey(\thisVal) , \legato, 0.2, \amp, 0.06 ] ],
hsIndices: [0] );
~p2 = PHSparUse(h, pbindArgs: [0.2, [\midinote, Pkey(\thisVal) - 3 ,\legato, 0.2, \amp, 0.06 ]],
hsIndices: [1] );
~p3 = PHSparUse(h, pbindArgs: [Pn(Pshuf([0.2, 0.1, 0.1], 1), inf), [\midinote, Pkey(\theseVals) + 5, \legato, 0.2, \amp, 0.06 ]],
hsIndices: [[0, 1]] );
~p4 = PHSparUse(h, pbindArgs: [Pn(Pshuf([0.2, 0.1, 0.1], 1), inf), [\midinote, Pkey(\theseVals) + 8, \legato, 0.2, \amp, 0.06 ]],
hsIndices: [[0, 1]] );
c = TempoClock.new;
q = Quant(0.8, 0);
)
// start PHSparPlayer with help synth #0
~x1 = ~p1.play(c,q);
// add a PHSusePlayer using help synth #1
~x2 = ~p2.play(c,q);
// add a PHSusePlayer using both help synths
~x3 = ~p3.play(c,q);
// and another one
~x4 = ~p4.play(c,q);
// stop PHSparPlayer, help synths keep playing
~x1.stop;
// stop a PHSusePlayer
~x2.stop;
// and another one, only player ~x4 left
~x3.stop;
// resume ~x1
~x1.play(c,q);
// stop only help synth #1
~x1.stop(hsStop: 1, pbindStop: false);
// stop also help synth #0 and player ~x1
~x1.stop(hsStop: 0);
// now only one pbind engaged via PHSusePlayer ~x4, but help synths may be controlled via PHSparPlayer ~x1 !
// resume both help synths
~x1.play(hsPlay: [0,1], pbindPlay: false);
// stop them again, using keyword
~x1.stop(hsStop: \all, pbindStop: false);
// stop last remaining PHSusePlayer via the "leading" PHSparPlayer and free HSpar
~x1.free;
////////////////////////////////////////////////////
(
// define HSpar: two sine waves with opposite phases
h = HSpar(s, [ { |freq = 0.25, dev = 5, center = 70|
SinOsc.kr(freq, 3pi/2, dev, center) },
{ |freq = 0.25, dev = 5, center = 70|
SinOsc.kr(freq, pi/2, dev, center) }]);
// one stream shared by both switch indices
// goal: repetition of sine wave segment, alternate register, small random add for pitch
~pitchBaseStream = (Pseq([60,80],inf) + Pwhite(0.0,5.0)).asStream;
p = PHSpar(h, 2, // switchDur = half phase of sine wave
Pseq([0,1], inf), // switchIndex
[\center, ~pitchBaseStream] ! 2,
[0.25, [\midinote, Pkey(\val) + [-5.25, 0, 4, 7.25] , \legato, 0.2, \amp, 0.06 ]]);
)
// stopping and resuming with options
// if stopped together, help synths, pbinds and switchIndex player are kept in sync for resuming
// therefore methods stop and play are blocking the player for some moments, but freeing is always possible
// switchStop = true is blocking for the whole current switch duration - this could be reduced
x = p.play;
// stop everything, keep sync: try stopping and resuming several times, leave some moments between
x.stop(switchStop: true, hsStop: true, pbindStop: true);
x.play;
// free everything
x.free;
//////////////////
x = p.play;
// stop only the pbind
// try stopping and resuming several times - always ascending segments of the sine wave, pbind is "stepping in"
// as points of stepping in may differ, low slope in ascending sequences may occur at the beginning or at the end
x.stop; // equivalent to x.stop(switchStop: false, hsStop: false, pbindStop: true)
x.play;
//
x.free;
//////////////////
x = p.play;
// stop everything BUT the pbind
// try stopping and resuming several times - again always ascending segments of the sine wave as
// switchIndex player and help synths are stopped and started together
x.stop(switchStop: true, hsStop: true, pbindStop: false);
x.play;
//
x.free;
//////////////////
x = p.play;
// let only help synths run
// try stopping and resuming several times
// switchIndex player and help synths are relinked, other sine wave segments establish
x.stop(switchStop: true, hsStop: false, pbindStop: true);
x.play;
//
x.free;