Specifying pitch and duration in Pbind

What are the options to specify both \dur and pitch, say via \degree?
By default one has to specify those params “in parallel”. While of course this can produce nice and interesting patterns, if I want to make more carefully tuned pattern it feels quite challenging to mentally sync pitch and note duration.

There are many options for builing dependencies in Pattern, see James’ Pattern Guide.

Just a few mentions: You can establish dependencies from other keys via Pkey and Pif, similarily also with Pfunc, her you can define any functional relation with

\dur, Pfunc { |e| ... e[\degree] ... }

You can also link with array keys:

Pbind([\dur, \degree], Prand([[0.1, 5], [0.2, 4], [0.5, 2]], inf)).trace.play

You can also define a master pattern and control both params with data sharing.

1 Like

Thanks will read through it again (for the 20th time probably ;))

As far as I know this only works for single notes, if you change degree to a chord, like [[1/2, [0, 3, 5]] it doesn’t work.

Well, try it out, it works

Pbind([\dur, \degree], Prand([[0.1, 5], [0.2, 4], [0.5, [0, -2, -5]]], inf)).trace.play

I’m getting warning and silence:

WARNING: the pattern is not providing enough values to assign to the key set: [ dur, degree ]

Oh, what system and SC version are you running ?

Version : 3.11.0-4
Arch Linux

This is strange, it works here on OSX 10.13.6 / SC 3.11.0

Do you have quarks installed ?
If yes, try to uninstall all and check again. If it works then you can reinstall incrementally. I’d be very surprised if it’s an system specific issue.

1 Like

Thanks it helped! The issue was caused by MusicalNotation

Filed as a bug. It’s an unfortunate typo.

hjh

1 Like

Fixed. Thank you both.
You can find the new release (v0.2.4) below:

1 Like

Here’s example where nested pattern is being ignored (?).

(
Ndef(\q, Pbind(
    \mtranspose, -1,
    \octave, 5,
    [\dur, \degree], Pseq([
        Pn(Pseq([
            [1/5, 1],
            [1/5, Prand([2, 5])],
            [1/5, 7],
            [1/5, \r],
            [1/5, 5],
        ]), 1),
    ], inf),
)).quant_(1).play(fadeTime: 1);
);

Regular version works just fine:

(
Ndef(\q, Pbind(
    \mtranspose, -1,
    \octave, 5,
    \dur, 1/5,
    \degree, Pseq([
        Pn(Pseq([
            1,
            Prand([2, 5]),
            7,
            \r,
            5,
        ]), 2),
    ], inf),
)).quant_(1).play(fadeTime: 1);
);

I think this is not expected to work, the value pattern should return pairs of values. So you get what you want by

(
Pbind(
    \mtranspose, -1,
    \octave, 5,
    [\dur, \degree], Ptuple([
		Pseq(1/5!5, inf),
		Pseq([1, Prand([2, 5]), 7, \r, 5], inf)
	])
).play
)

Though I see that you probably want to define couples with Patterns, this can be done by feeding the flopped couples into a Ptuple:

x = [
	[1/5, 1],
	[1/5, Prand([2, 5])],
	[1/5, 7],
	[1/5, \r],
	[1/5, 5]
];

y = x.flop;

(
Pbind(
    \mtranspose, -1,
    \octave, 5,
    [\dur, \degree], Ptuple([
		Pseq(y[0], inf),
		Pseq(y[1], inf)
	])
).play
)

Or shorter:

(
Pbind(
    \mtranspose, -1,
    \octave, 5,
    [\dur, \degree], Ptuple(y.collect(Pseq(_, inf)))
).play
)
2 Likes