Samstag, 17. Januar 2026

The bidirectional step sequencer

 I built a bidirectional step sequencer in PureData, based on a 4-step sequencer tutorial I found at GitHub. Basically, you can rebuild it and use it by following the instructions, changing the parameters as you like.

Here is how it works, more or less:

The heart of the machine are the vertical sliders, each representing a MIDI pitch value which is sent to a number box and converted to a corresponding frequency. Whenever a bang is triggered (the number box above the select 0 1 2 3 box gives the select box a number ranging from 0 to 3, and the select box specifies to which position the bang is directed - slider 0, 1, 2 or 3), the float value of the corresponding slider is fed to the number box below, from where it is converted from MIDI to frequency, and being output as a sine wave.

Now, the machine has two step counters, a forward and a backward step counter. While the backward counter counts down from 3 to 0, the forward counter counts up from 0 to 3. At the end of the cycle, the counter is reset to the initial value (the inlet of the respective float). Also, a number is added to the cycle counter of the side which is currently running. After a given number of cycles (here: 4 cycles), the machine switches to the other step counter. The given number of cycles triggers a bang. This bang in turn triggers two bangs. These two bangs trigger two switches, of which one is always turned off and the other always turned on, which means that the running direction of the sequencer is switched. Whenever the bang that switches direction is triggered, the cycle counters are reset to 0.

You can change all of the parameters: speed (specify the ms as the number after metro), number of notes (add sliders and change values (do not forget to change all related arguments!) as needed), frequency range (adjust the settings of the vertical sliders if required), number of forward and backward cycles before the jump (change the sel argument of the cycle counters, try asymmetric setups if you like, for example make one metro slower/faster than the other, have more cycles in one direction than the other).

You could also change the sel arguments, e. g. if you want the sequencer to run only 3 notes when running forwards, but 4 notes when running backwards - then you would change the step counter sel argument to 2. It will now reset the step counter when reaching the argument 2 (after 3 notes instead of 4).

If you want the sequencer to run only in one direction, choose the counter you like better and remove the following: switch bang, tbb box, bang to reset cycle counter, the whole cycle counter plus the whole dismissed side of the machinery. You are left with one counter (either backward or forward) that resets to the initial value at the end of each run, therefore running as long as you like, at the metro tempo specified.

This is an open source machinery. If you use it, do buy me a coffee or beer if we ever bump into each other. Thank you.


Bidirectional 4-step sequencer with automatic direction switch after 4 cycles. You can also switch at any given time by clicking on the direction switch (uppermost bang) manually.

You can also build a setup that allows you to switch directions manually at any given time, see below:

Bidirectional step sequencer with manual direction switch (click at any time)

Additional versions (see pd directory in the link below and open the files that interest you directly in pd. The setups are getting too big to make screenshots...):

Bug fix: Introduced a short break before direction switches, so that the same note can be heard twice as two separate events.

Made a version with two limping metros. At present, the metro is symmetrical, so that the same note lengths are played in either direction. The metros are independent of each other and can be changed accordingly.

The palindromic beat:
Another idea is to make a palindromic beat, e. g. the classical
Prim - Third - Fifth - Third - Prim, 

for example, in the form of C-E-G-E-C.

In a sequencer, this can be reduced to four notes, with e. g. C on the first beat: C-E-G-E
Let's assume that we would like to play the figure
1      2      3     4      1
C     E     G     E     C

Now, a fun thing to do could be to cut the palindromic sequence somewhere in the middle and starting e. g. with the top note, that is

GECE

and let it run for a couple of loops. In this case, GE (3 and 4) would be the intro. After a few loops, the sequencer switches direction to

ECEG

and again, after the first E, you are back to the beat no. 1, and the melody is looping as before.

However, you may want to make each transition (transition 1 and 2: from GECE to ECEG, and from ECEG back to GECE) in such a fashion that it can be done in the same amount of notes as notes in the step sequencer. For simplicity, let's say that we want the change to be done in 4 beats.

The easiest way that I have found to do this is introducing filler notes. As you can see, the first sequence GECE ends on a 2, while the mirror sequence ECEG starts on a 4.

So, by introducing one note after the end of the first sequence, for example D#, you can continue on 4 and are back in the original palindromic beat after that. (Note: Do not forget to adjust Limping Metro delay times to fit the original rhythm pattern, if you wish, i. e.: the delay times have to be mirrored as well.)

Similarly, as ECEG ends on a 3 and GECE starts on a 3, by introducing three filler notes, e. g. A A# A on 4, 1, 2, you can continue on 3 again.

A bidirectional 4-step sequencer with 4 cycles, a palindromic beat, a limping metronome, and filler notes

The setup could be nice for an impro where just like a human percussionist, the sequencer may want to do a little impro before going back to the original rhythm. The metros are also independent of each other, so one side could be sped up compared to the other. It may also be possible to transpose one side (to symbolise key change, as could be useful when switching between verses and a chorus), but the more practical thing might be to use one cycle counter to trigger a sequencer with new notes. I see the most potential of this application for longer verses, intros or jam sessions.

Here are my pd files to download and modify as you like.