Increasing randomness of sequence

Hey guys,
I just got my hands on Pseq and Prand.
I also used a bit of MouseX and MouseY.

I'm wondering if there is a clever way to transition from a sequencial composition to complete randomness depending on Mouse movement.

Basically I want the Prand to perform as Pseq when I have the mouse in one area and as Prand when in another, with varying degrees of randomness along the way.

(
~duration = 1;
Pbind(
	\note, Prand([0, 2, 3, 5, 7, 8, 11, 12], inf),
	\dur, Prand([~duration, ~duration*2], inf),
	\legato, 1,
	\amp, Prand([1,0.5],inf)
).play;
Pbind(
	\note, Prand([3, 5, 7, 8, 11, 12, 14, 15], inf),
	\dur, Prand([~duration, ~duration*(1/3)], inf),
	\legato, 1,
	\amp, Prand([1,0.5],inf)
).play;
Pbind(
	\note, Prand([-12, -13, -17, -19, -21, -22, -24, -22, -21, -19, -17, -15, -13], inf),
	\dur, Prand([~duration, ~duration*(3)], inf),
	\legato, 1,
	\amp, Prand([1,0.5],inf)
).play;
Pbind(
	\note, Prand([-24, -22, -21, -25, -25, -24, -28, -29], inf),
	\dur, Prand([~duration*2, ~duration*4], inf),
	\legato, 1,
	\amp, Prand([1,0.5],inf)
).play;
)

´´´

Please put your code inside of three backticks ```, so it will be formatted correctly :slight_smile:

What you’re describing is definitely do-able - but if you for example want 0 to be “not random” and 1 to be “full random”, what would you expect from a control value of 0.5? What’s “half random”?

1 Like

If it’s helpful, my Pxfade class will cross-fade between two (or more) streams of values. The default fade mode is \random, which will do a weighted random choice between the two streams you’re fading between. So, if you have something like this:

(
Pdef(\fade).set(\fade, 0);
Pdef(\fade, 
	Pbind(
		\scale, Scale.chromatic,
		\dur, 1/6,
		\legato, 2,
		\octave, 3,		
		\degree, Pxfade([
			Pseq([0, 2, 7, 9, 4], inf), // non random...
			Pxrand([0, 2, 7, 9], inf), // random....
		], Pkey(\fade))
	)
).play;
)

then you can do:

Pdef(\fade).set(\fade, 0.5) // 50% from the non-random stream, 50% from the random stream
Pdef(\fade).set(\fade, 1) // 100% from the random stream
3 Likes

Oh yes thank you :).
lets say we have levels [0,1,2,3,…10] levels of randomness for a sequence of notes [0, 2, 3, 5, 7, 8, 11, 12].
If we are at the very beginning of the playback and the level is 0, I want the probability to play the note 0 to be 100%. If the level is 1 I want the probability to play a random note of the sequence in this position to be 1/10, if the level is 2, the probability should be 2/10 and so on.

Oh yes, the Pxfade pretty much does this. But if you want a simpler implementation, you can try:

Pif(
   Pfunc({ |value| value > 0.5 }) <> Pwhite(),
   Pseq([0, 2, 7, 9, 4], inf),
   Pxrand([0, 2, 7, 9, 4], inf),
)

(where the 0.5 is your probability of one or the other)

2 Likes

I am pretty sure you solved my issue. I am so new here to the point that it will take me a little bit to understand what you told me and use your wisdom adequately in the composition. Thank you so much! :slight_smile:

I am working on something similar, but I don’t seem to be able to use Pxfade. There is a file “Pxfade.sc” in the JITLib folder of my installation (3.12.1, macOs), but it doesn’t seem to actually define the class. Is it available somewhere else?

Hmm, have you recompiled or restarted sclang? You can also place Pxfade.sc and extScale.sc in a folder on their own, and then run Quarks.install("/path/to/pxfadefiles") to install them. You’ll have to recompile in this case as well.

Is it supposed to be this file?

/Applications/SuperCollider.app/Contents/Resources/SCClassLibrary/JITLib/Patterns/Pxfade.sc

Or is these two, overwriting the defaults for Pxfade.sc?
Sorry if I come of as confused, had very little sleep past few days…

1 Like

Sorry, this IS confusing. There is a file in the core library called Pxfade.sc, which contains some unrelated fading classes, none of which are called Pxfade :). I didn’t know this file existed until now.

Don’t install external classes or quarks by modifying or overwriting things in SCClassLibrary, just add the path containing your extension files using Quarks.install or via the Preferences dialog → Interpreter → Include.

1 Like

Had another look at this (wow 6 months later…) and got it working! But:

The class definition in Pxfade uses the method .isSymbol, which I throws an error. I can’t find that method in the documentation. wslib has a .isSymbolWS method – I installed that and replaced .isSymbol in Pxfade.sc with that, and it seems to work.

I also put extScale.sc in a “SystemOverwrites” folder, because the interpreter told me to do so on class library compilation.

Hey! Glad to hear it’s working, sorry it was a bit of a pain. I’ll fix the things you mentioned for the next person. :slight_smile:

1 Like

Pure pain for six straight months! No I am joking, it’s just that I lack focus – thanks for writing the extension!

(Just out of curiosity, form where did you get the .isSymbol method?)

1 Like

Good question - I probably have it defined somewhere in personal class extensions. It’s probably the same as isSymbolWS, which is I’m guessing just .isKindOf(Symbol)