Euclidean Rhythms

Some information about Euclidean rhythms!

2 Likes

As somebody told me some day, a line of code is worth a thousand videos :wink:

std::string bjorklund(int beats, int steps, int offset)
{
	//We can only have as many beats as we have steps (0 <= beats <= steps)
	if (beats > steps)
		beats = steps;

	//Each iteration is a process of pairing strings X and Y and the remainder from the pairings
	//X will hold the "dominant" pair (the pair that there are more of)
	std::string x = "1";
	int x_amount = beats;

	std::string y = "0";
	int y_amount = steps - beats;

	do
	{
		//Placeholder variables
		int x_temp = x_amount;
		int y_temp = y_amount;
		std::string y_copy = y;

		//Check which is the dominant pair 
		if (x_temp >= y_temp)
		{
			//Set the new number of pairs for X and Y
			x_amount = y_temp;
			y_amount = x_temp - y_temp;

			//The previous dominant pair becomes the new non dominant pair
			y = x;
		}
		else
		{
			x_amount = x_temp;
			y_amount = y_temp - x_temp;
		}

		//Create the new dominant pair by combining the previous pairs
		x = x + y_copy;
	} while (x_amount > 1 && y_amount > 1);//iterate as long as the non dominant pair can be paired (if there is 1 Y left, all we can do is pair it with however many Xs are left, so we're done)

	//By this point, we have strings X and Y formed through a series of pairings of the initial strings "1" and "0"
	//X is the final dominant pair and Y is the second to last dominant pair
	std::string rhythm;
	for (int i = 0; i < x_amount; i++)
		rhythm += x;
	for (int i = 0; i < y_amount; i++)
		rhythm += y;

	for (int i = 0; i < offset; i++) {
    	std::rotate(rhythm.begin(), rhythm.begin() + 1, rhythm.end());
    }

	return rhythm;
}

You could generate the typical afrocuban 12/8 key like this:

std::cout << bjorklund(5, 12, 3) << std::endl;
101001010100

Perhaps our beloved @riban could integrate, some day, this into the pattern editor / stepseq :innocent:

@riban, could we use the stepseq infrastructure for creating a dedicated APP/UI for this?
Something really simple, like this one:

Enjoy!

4 Likes

thats a great idea!!! :wink:

2 Likes

OOooooh this could be fun!!!

I envision a set of zynseq patterns reserved for this. They would be managed from a simple interface, with the rotary wheel and controls of a “typical” euclidean generator. Ohhh yessss! I will implement this after releasing the stable. @riban , you already had enough fun while implementing the SooperLooper. I also deserve some fun!! :grin:

Cheers!

3 Likes

It’s funny because I had mentioned the same idea a couple of zynthclubs ago, and @wyleu and @ronsum are also intrigued. @riban was less than impressed at the idea though, because he couldn’t see the point of it. Don’t worry though, because I have heard that people can be dead against some ideas until someone ignores them and implements the idea anyway :wink:

Good luck @jofemodo …

My bell ringing persona treats the whole concept with faintly disguised contempt, but my playing drums in a field banshee is fascinated.
It would seem efficient to build on the sequencer infrastructure as this would revisit an existing component that integrates into our file format and simply expands the grammar.

Pluck those children from their mothers arms!!!

I was thinking along the same lines - some controls that add / remove / move notes in a pattern but couldn’t see the best way to implement the UI. You could have a quantity of streams, each of which you can choose:

  • MIDI note (0…127)
  • Quantity of steps (1…16)
  • Quantity of pulses (1…16)
  • Offset/rotation (0…100%)

With a purely flat table that would be 4 controls x quantity of streams, e.g. 4x4=16. That actually fits nicely on a 4 knob per page layout but not within the sequencer - maybe have a controller page access for Euclidean control of patterns. Maybe not even reserve patterns, just allow them to be created / modified by this controller.

Seriously? I never hear about something like this … :thinking:

2 Likes

Perhaps we could put the keyboard in the correct place whilst we are at it…?

Could such an interface exist via a browser or perhaps the second GUI output…?

Exactly. I’m talking of using the zynseq underlaying infrastructure, not the zynseq’s UI (pattern editor, etc). I would create a custom UI for managing the euclidean patterns, similar to what you describe, probably with a fixed number of patterns (8, 16?), layered as controller pages, so we use short select + rotate to change selected pattern, etc.

Regards,

Euclidian Rythms seem to be easy to understand and easy to use. I think Zynthian is a perfekt device to implement and give fun to the users to produce some generic sounds/Rythms. I really look forward to the first version of the circling magic and other Zynthianiacs will do too. Thanks!

The video demonstrates that it could be as simple as a pattern with notes added, removed and moved depending on an algorithm driven by the controllers. In theory the step sequencer is perfect for this. In practice I may need to fix a bug that has been haunting me. During playback, modification to a pattern cause notes to be missed. I can look at it whilst you twiddle with UI to drive the algorithm. But not today!

Really exciting feature. I remember having a lot of fun with this

And here is hardware with euclidean rhythms T-1 - Torso Electronics

1 Like