class:: Pmono
summary:: monophonic event stream
related:: Classes/Pbind, Classes/PmonoArtic
categories:: Streams-Patterns-Events>Patterns>Event

description::

Plays one instance of a link::Classes/Synth::. The pattern pairs define changes in that one synth's controls. This node is created when entering a Pmono, and released when the Pmono terminates. There is just one node for the duration of the entire pattern, and it will sustain through each event. If a monophonic phrase requires staccato notes or re-articulation between some notes, see link::Classes/PmonoArtic::.

If event[\id] is not nil, Pmono simply directs its pattern changes to that node and does not create an extra synth.

Examples::

code::
p = Pmono(\default, \dur, 0.2, \freq, Pwhite(1,8) * 100 ).play

p.stop

// multi channel expansion is supported:
p = Pmono(\default, \dur, 0.2, \freq, Pwhite(1,8) * 100, \detune, [0,2,5,1]).play

p.stop


// the following example will end after 5 seconds
// or you can stop it sooner with a stop message
(
p = Pfindur(5,
	Pset(\detune,Pwhite(0,1.0) * [0,1,3,7],
		Ppar([
			Pmono(\default, \dur, 0.2, \freq, Pwhite(1,8) * 100 ),
			Pmono(\default, \dur, 0.1, \freq, Pwhite(1,8) * 300)
		])
	)
).play;
)
p.stop;
::

subsection::A related approach

A related approach is to instantiate a Synth yourself and then set its values by using an link::Classes/Event:: whose "type" is code::\set::, as illustrated here. The user is responsible for ensuring proper synchronization between between link::Classes/Synth:: creation and pattern execution.

code::
// First we create something to control
x = {|freq=440, amp=0.6| MoogFF.ar(PinkNoise.ar(amp), freq).dup}.play;

// In the following pattern, the first two keys are the ones that create the monophonic behaviour:
(
p = Pbind(
	\type, \set,	// This tells it we'll be setting parameters of an existing node...
	\id, x.nodeID,	// ...this tells it whose parameters we'll be setting
	\args, #[\freq, \amp],  // and this tells it which parameters to set
	\freq, Pwhite(100, 1000),
	\dur, 0.2,
	\amp, Pseq((1,0.99 .. 0.1), inf)
).play;
)

p.stop
x.free
::

For more details on the code::\set:: event type, see its description in Chapter 8, link::Tutorials/A-Practical-Guide/PG_08_Event_Types_and_Parameters##Event Types and Parameters:: of the Practical Guide To Patterns.

subsection::SynthDef variant support

SynthDefs allow alternate sets of default values to be defined (see "Variants" in link::Classes/SynthDef:: help). Most event patterns, such as Pbind, specify the variant using the variant key in the output events. (Note that variants are always optional.) In Pmono, the mechanism is different because the SynthDef name, including variant suffix, must be known before evaluating the first event. So, the variant suffix is provided in the first Pmono argument:

code::
Pmono('synthDefName.variant', pairs...)
::
