# Pdef and Scales

#1

I was busy working on some patterns and decided to try the Pdef/pbind solution. However, I’m suprised to hear that when I change between patterns, the defined scale defaults back to major. I’m rather surprised to see/hear this, am I missing something?

Here’s my simple test example (the real SynthDef is more complicated, but with the same - scale - results):

``````Pdef(\m);
Pdef(\m).play;
Pdef(\m).fadeTime = 4;

(
a = Scale.dorian;
Pdef(\m,
Pbind(
\instrument, \default,
\scale, Pfunc({a},inf),
\degree, Pseq([0, 1, 2, 3, 4, 5], 4),
\dur, 0.5,
\amp, 0.2,
\out, 0,
);
);
)

Pdef(\m, Pbind(\instrument, \default, \dur, 1, \degree, Pseq([0, 1, 2, 3, 4, 5],8)));
``````

Lastly, I should add I tried a few versions (with local or global variables), such as define the scale with `~a` inside and outside the Pdef, and tried defining plain `\scale, ~a,`, but the results seem the same - unless I missed something out.

Any suggestions or remarks most grateful.

Since posting this I also notice another thing that doesn’t transfer across, `\amp`. Do we have to ‘literally’ redefine each variable? I thought that once the original `Pdef` is defined then everything stays the same, unless you change it with the `\key`

#2

I think it’s because you’re redefining the Pbind inside the Pdef without expliciting the scale, which defaults to major. Try using Pbindef instead.

``````Pdef(\m);
Pdef(\m).play;
Pdef(\m).fadeTime = 4;

(
a = Scale.dorian;
Pbindef(\m,
\instrument, \default,
\scale, Pfunc({a},inf),
\degree, Pseq([0, 1, 2, 3, 4, 5], 4),
\dur, 0.5,
\amp, 0.2,
\out, 0,
);
)

Pbindef(\m, \instrument, \default, \dur, 1, \degree, Pseq([0, 1, 2, 3, 4, 5],8));
``````

#3

Yes, thanks loopier. In fact I just went out to do some shopping and realised whilst walking that I was indeed ‘redefining’ the original `Pdef` and so as you also say reseting the whole thing back to the default `SynthDef`.

I’ve been using `Pbindef`, but was looking into the Pdef for the fadeTime possibilities. Anyhow, back to the drawing board as they say.

Thanks again for leaving a suggestion.