Different note durations not in sync

I noticed that when I’m using Pseq and I sequence note durations it extends the pattern and doesn’t really sound good with my other sequences unless the note durations are all the same like 0.25 for example. What I want in my Pseq is to have some 1/4, 1/8, 32nd, 64th, and 128th notes but once I do that it sounds off. It’s kind of hard for me to explain so I attached a picture of how I would like to sequence note durations within Pseq. In the picture it shows a 1 bar loop but the notes have different lengths but it’s still a 1 bar pattern and there is no change in the speed of the sequence. In the code example the seq2 variable has a Pxrand that plays different Pseq’s but it sounds just like some play fast and others slow. How can I write my Pseq’s to behave more like the sequence in the image?

(
var seq = Pxrand([0.25, 1, 0.25, 0.50, 0.25, 3, 0.25, 0.50, 1, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25 ], inf);
var seq2 = Pxrand(
		[ Pseq([0.50], 4), Pseq( [0.25, 0.25, 0.25, 0.25], 8),
		Pseq( [0.50, 0.50, 1, 1 ], 2 ), Pseq( [0.0625 ], 8 ) ],
		inf );
~acid = PmonoArtic(
    \acid,
	\legato, seq,
	\degree, Pxrand(
		[ Pxrand([5, 8, 12, 3, 4, -7, 3, 4]-12, 2),
			Pseq([-5, -8, -12, -6, -4, -14, -6, -4]/2, 1)
		], inf),
	\ffreq, Pxrand(
		[ Pxrand([100,500, 800, 1200, 2000, 1200, 2400], 1),
			Pseq([200,800, 900, 1500, 1800, 1200, 1900], 1)
		], inf),
	\dur, seq2,
	\amp, Pxrand([3, 2, 2, 2, 1, 1, 3, 3, 3, 3, 3], inf),
).play(t);
)

Psync will constrain an event pattern to barlines.

But I suspect you want metrical organization within bars too. That’s trickier. I’ve sometimes found it easier to think in terms of time points within the bar – I’m afraid I don’t have an example now, though.

hjh

This may be a dumb question, but if you want something deterministic, why are you using PxRand ?

Im not sure if i understand the problem correctly, but the individual Pseqs inside seq2
dont have the same size and they individually dont line up with a 4/4 time signature (repeat after 1 bar of 4 quarter notes like in your Ableton screenshot), if thats what you want.
Have you actually tried to convert the Ableton example to SC it looks really different to me?

When doing so im not sure how you would like to interpret the specific durations of the Screenshot.
Is the first note of the Ableton Screenshot a 1/16th note followed by a 16th note Rest or a 8th note with adusted legato?
Actually i havent found a comfortable way to work with either of them. inserting rests is not ideal for creating abstractions of the initial rhythmic idea by using operators / methods and having parallel Pseqs of defined values for legato and dur makes it pretty laborious to compose a deterministic gesture. maybe someone else has an idea on that.
I think, if you start writing several long sequences of pre-defined values for each parameter which should all line up correctly, its much more easy to do that in Ableton. but maybe thats just me.

in general when writing rhythm i would take the smallest rhythmic value as a base and define it as 1 and the other values as relative multiples of that. this makes it imo more easy to see the overall rhythmic structure of a phrase (and lines up with rhythmic analysis) and to do ornamentations or alterations by for example using math operators or array methods.

The picture was just an example of the type of divisions of notes I would like to use in a sequence. I did some more research into my issue and it seems the type of rhythmic sequencing I want to do in SC is a bit tricky. I found the following article which describes my issue a lot better:

Conceptualising rhythm in live coding with SuperCollider

I think I will have to try some of the techniques that guide mentions to get close to the type of rhythms I want to do. It just seems a little odd that there is no easy way to do that in SC. I’d love to do note re-triggers like a lot of hardware grooveboxes do these days but alas, I might have to embrace the way SC does things.

1 Like

I think beside the algorithmic possibilities its great to have a general understanding of rhythm and the possibilies you can alter a specific rhythmic idea for example by augmentation or diminution or concepts like ametricality. The first chapters of this book are explaining some concepts of that https://monoskop.org/images/5/50/Messiaen_Olivier_The_Technique_of_My_Musical_Language.pdf there is also a great video series about it Decomposing Messiaen. Techniques of musical language. Episode 3 - "Augmentation" - YouTube

speaking of algorithms there is a thread on some ideas: Rhythmic algorithms

1 Like

Perhaps to shift perspective on the question –

I think the tricky thing here is not (primarily) the programming.

What is an algorithm doing, if it’s using random number generators to produce musical data?

The field of possible results is very large, and most of it sounds like nonsense (because “sense” in music is about recognizing culturally-coded patterns).

So, algorithmic composition is about constraining the randomness to exclude nonsense parts of this field, and steer the results toward “sensible” territories.

var seq2 = Pxrand([
	Pseq([0.50], 4),  // = 2
	Pseq([0.25, 0.25, 0.25, 0.25], 8), // = 8
	Pseq([0.50, 0.50, 1, 1], 2 ),  // = 6
	Pseq([0.0625], 8 )  // = 0.5
], inf);

This rhythm algorithm constrains rhythmic values to duple divisions. But you also said “In the picture it shows a 1 bar loop but the notes have different lengths but it’s still a 1 bar pattern” – so metrical structure is part of your goal, but the sub-sequences all have different lengths that are not multiples of the bar’s duration. In particular, this pattern allows a half-beat offset (last entry).

So the tricky thing is to understand the rhythmic territory you want to allow, and figure out how to constrain the randomness to that.

This should not be expected to be a simple problem! This is the core of algorithmic composition. Your solution is what will distinguish your algorithmic music from other people’s – that is, this is exactly where the creative struggle is.

The key question, I think, is, what are the metrical structures within the bar that are important to you?

I won’t try to answer that for you, but I’ll add a couple of other notes:

SC patterns are oriented toward time deltas (or “inter-onset intervals” = IOIs). It’s difficult to express “positions within the bar” in terms of deltas – so, if the idea of placing events at specific beats to the bar is important to you, then it’s better to have something to convert time points into deltas. The ddwPatterns quark has PTimePoints, but you could find your own way. Assuming 4 beats to the bar, this pattern will play an E always on beats 2 and 4, with some extra 8ths. If you try to do this only with deltas, it will drive you nuts.

(
p = Ppar([
	// metronome
	Pbind(
		\midinote, Pseq([72, 60, 60, 60], inf),
		\dur, 1,
		\legato, 0.1
	),
	// backbeats
	PTimePoints(
		Pbind(
			\midinote, 76,
			\timept, Pn(Plazy {
				var pts = [1.0, 3.0] ++ Array.fill(rrand(1, 4), { 8.rand * 0.5 });
				// remove duplicates
				pts = pts.as(IdentitySet).as(Array).quickSort { |a, b| a < b };
				Pseq(pts, 1)
			}, inf),
			\sustain, 0.5
		)
	)
]).play(quant: -1);
)

And…

1 – Of course SC can do this… the difference is that it’s a built-in feature of a groovebox. 2 – Much of what I’m saying in this post is about creating a translation layer between the way you want to do things, and the way the underlying SC mechanisms work. Don’t give up just because SC doesn’t already have exactly the translation layer you wanted.

I’d suggest a pattern that will repeat and subdivide events. The Pbind would be responsible for generating the rhythmic structure; this filter pattern, wrapping around the Pbind, would handle retriggering.

If you update my ddwPatterns quark, it could be done a bit clumsily like this. Or you could create a new pattern class that does it more conveniently.

(
p = Psmartdup(
	Pkey(\structuralDur) / Pkey(\dur),
	Pbind(
		\degree, Pn(Pseries(0, 1, 8), inf),
		\structuralDur, Pwhite(1, 3, inf) * 0.5,
		\dur, Pwrand([
			Pfin(1, Pkey(\structuralDur)),
			0.125
		], [0.9, 0.1], inf),
		\legato, Pif(Pkey(\dur) |!=| Pkey(\structuralDur), 0.05, 0.9)
	)
).play;
)

hjh

3 Likes

A lot of homework for me to do! I’ve used probability in hardware sequencers before but having this much freedom in SC is just mind boggling for me at the moment. I’m a bit excited…Looking forward to hacking away through the suggestions. :slight_smile:

Grooveboxes tend to be on a fixed grid, where you compose by muting/unmuting/tweaking individual steps in that grid. You an do this with SC - easily! - but it’s a somewhat under-documented workflow. Here’s an example of more of a step sequencer pattern. It’s using Pmono, which means it keeps one synth around and re-triggers the envelope with \trig rather than creating new synths each time, which lets you have an inline delay. Event are muted using r, which is just a Rest. Maybe this will give you some ideas…

(
SynthDef(\click, {
	var sig, env;
	
	env = Env.perc(0.001, \release.kr(0.5), 1, \curve.kr(-4)).kr(
		gate:		\trig.tr(1)
	);

	sig = \amp.kr(1) * env * BPF.ar(WhiteNoise.ar(), \bpf.kr(3000));
	sig = sig + Pluck.ar(
		sig, sig,
		2,
		3.03/4 / \tempo.kr(1),
		4, 
		0.4
	);
	
	Out.ar(\out.kr(0), sig ! 2)
}).add;

r = Rest(1);

Pdef(\stepSeq).clear;
Pdef(\stepSeq, Pmono(
	\click,

	// Fixed
	\tempo, 1.5,
	\dur, 1/4,
	\trig, 1,
	
	// Continuously changing
	\release, 		Pseg([0.2, 0.5, 0.2], [4, 4], 0, inf),
	\release, 		Pkey(\release) + Pseq([0, 0, 0, 1], inf),
	\bpf, 			Pseg([400, 9000, 4000, 1000], [2, 1, 2, 3], \exp, inf),
	\timingOffset, 	Pseq([0, 0, 0, 1/4, 0, 1/8], inf),
	\curve, 		Pseq([-8, -4, -2], inf) - 4,
	
	// Step sequencer style...
	\amp, Pseq([
		1.0,  r,  r,  0.5,   	1.0, 0.7,  r, 0.4,
		0.6,  r,  1,  0.5,		r,   1.0,  r, 0.3 
	], inf).trace,
	
)
).play

)
2 Likes