Sidewinder
Euclidean sequencer for Max for Live that creates polyrhythms.
Install / Use
/learn @robenkleene/SidewinderREADME
Sidewinder
Sidewinder is a Euclidean sequencer for Max for Live that creates polyrhythms. Sidewinder takes a number of pulses (notes) and positions them as equidistant as possible into a number of steps. Equidistant distribution is a key to creating rhythms that are inherently musical. Many traditional rhythms can be generated through this simple process, see the example rhythms section.

The Euclidean algorithm computes greatest common divisor of two numbers. Godfried Toussaint discovered its musical applications and published them in "The Euclidean Algorithm Generates Traditional Musical Rhythms". Applied to music, the algorithm takes k pulses (notes) and distributes them as equidistant as possible in n steps.
Installation
Freezing the .amxd
Before the device is added to the User Library in Ableton Live or Ableton Push, the device should be frozen.
The latest version of the frozen device can be downloaded from the Sidewinder page on the Max for Live site.
The device can be frozen manually by following these steps:
- Open Ableton Live and drag
Sidewinder/Sidewinder.amxdto the Device area (where it saysDrop an instrument or Sample here). - Click the disclosure icon in the upper right of the device and choose
Edit in Max. - In the Max window, click the
Freeze Deviceicon in the bottom bar that looks like a snow flake, then chooseFile > Save As...to save the frozen device to a temporary location.
Note that this file can be deleted after the device has been added to the User Library.
Installing in Ableton Live
Drag the frozen Sidewinder.amxd to the User Library (e.g., under User Library/Presets/MIDI Effects/Max MIDI Effect/).
Installing in Ableton Push standalone mode
- Launch Push in standalone mode
- In Live's sidebar, select
Places > Push - Drag the frozen
Sidewinder.amxdtoPlaces > Push > User Library(e.g., underUser Library/Presets/MIDI Effects/Max MIDI Effect/[note that in the Push Use Library this folder is not create by default like it is in the Live User Library]).
Using the Device on Push
After Sidewinder has been installed in the Push User Library, the device can be added by choosing it under Device > User Library.
Opening in Max Directly
To open in Max directly without Live, open Sidewinder/Sidewinder.maxpat.
Interface
Global
- Play: Toggle playback
- Solo: If toggled on, selecting a track tab will toggle off the other tracks.
- 1-4 Tabs: Select which track to display
- R Tab: Display the randomize pan
- R: Trigger randomize
Presets
- R: Read presets from a file
- W: Write the presets to a file
- OW: When toggled on, W will automatically write again to the same file
- To recall a preset, click a box
- To save a preset, shift-click a box
- To delete a preset, shift-option-click a box
Tracks
Above the piano roll.
- Track: Toggle playback for this track
- Set: Set the steps based on the current settings
- Auto: Toggle whether moving a control automatically updates the steps
- Type Tabs: Select between showing All, Pitch, Velocity, or Duration in the step sequencer
- Ch: The MIDI channel that the track outputs to Note: Ableton Live merges all MIDI to channel one, limiting the usefulness of this in Live
- Division: Sets the value between each step (this is different than Duration, which can for example overlap steps). There's limitation with the
live.stepsequencer that each step in the sequencer represents1/16note, this means the display of the sequencer will actually be different from the MIDI output, if this value is set to anything other than1/16.
Auto
When Auto is on, making a change automatically updates the steps. When Auto is off, use Set to update the steps. When Auto is disabled the U, R, D, L directional controls appear that allow moving the sequence in the corresponding direction (up, right, down, left). If Pitch or Velocity only those values will be moved.
Note: Due to a technical limitation, if Auto is on, changing any parameter that affects the steps (e.g., pulses, steps, rotate, pitch, velocity, or duration) will overwrite any manual changes made in the step sequencer to pitch, velocity, or duration. For this reason, generating a random notes sequence automatically disables Auto, so that the sequence doesn't accidentally get overwritten.
Pulses
To the left of the piano roll.
- Pulses: Set the number of pulses (notes)
- Steps: Set the total number of steps
- Rotate: Set the offset for the pulses
Notes
To the right of the piano roll.
- Pitch: Set the pitch of the notes
- Velocity: Set the velocity of the notes
- Duration: Set the duration of the notes. The note duration can only be set to
1/1281/64,1/32,1/16,1/8,1/4, or1/2notes (there appears to be an undocumented limitation of thelive.stepsequencer that limits the minimum duration to7.5ticks and the maximum duration to960ticks).
Randomize

Randomize generates a random sequence. The Notes setting is significant, with that setting turned off, a sequence that plays a single note will be generated. If it's turned on, a sequence playing different notes from a scale will be generated.
- 1-4 Buttons: Which tracks to randomize
- Pulses, Steps, Rotate: Whether to randomize those parameters. When randomizing pulses and steps, the randomized steps value overrides the maximum for pulses (unless the randomize pulses maximum is already less than the randomized steps value). This is because the pulses value can never go above steps value, so if we didn't override the maximum for pulses, then all randomized pulses values above the randomized steps value would be forced to be the steps value (i.e., steps and pulses values would be equal, which doesn't make for interesting patterns).
- Min: Minimum random amount
- Max: Maximum random amount
- Notes: Whether to randomize individual notes. If the notes is off, then randomize for Velocity, Pitch, and Duration will randomize changing those values on the individual track settings. If notes is on, then randomize for those values will create randomize the individual notes (and the track settings will be used for default values, e.g., for off notes with a velocity of 0).
- For Duration, the top number and bottom numbers are the minimum and maximum duration in ticks
- For Pitch, the top number and bottom pitches are the minimum and maximum pitches
- Note Trigger: If the incoming MIDI note matches this note, than randomize is triggered (i.e., this is a way to trigger randomize via MIDI)
- Set Note Trigger: The next incoming note will set the note trigger value without triggering randomize
- Auto Beats: Automatically trigger a randomize after every number of beats (this is based on the current transport status, e.g., if it's set to
4and you're currently on beat2, it'll trigger the randomize in2more beats)
Pitch Note Controls
With the Notes is off, only the minimum and maximum pitches are used. If Notes is on, Sidewinder generates a note sequence and provides additional parameters to randomize the sequence. If all the additional randomization parameters are off, the sequence generated will simply generate notes in the selected scale in order.
- Vel: Whether to randomize velocity
- Pitch: Whether to randomize pitch
- Dur: Whether to randomize duration
- Scale: The scale the sequence will be generated in
- Rand: Randomize the scale
- Rev: Reverse the order of the generated sequence (from ascending to descending)
- Repeat, Order, Rests: The percentage chance that each note will be affected when generating the note sequence. Repeat is the percentage chance each note will be repeated, Order is the percentage change each note will be have it's position in the sequence randomized, and Rests is the percentage chance the note will be replaced by a rest. Note: Rests use a velocity of
0, so rests will result in0velocity notes, even though theVelMinminimum is0, which can be surprising if you aren't expecting it.
Installation
Drag max-for-live/Sidewinder.amxd to Ableton > User Library/Presets/MIDI Effects/Max MIDI Effect/.
Source Files
To open any of the maxpat files, the Sidewinder folder should be in your Project Search Paths, ~/Documents/Max 8/Projects by default, so that referenced files can be found.
JavaScript Implementation
Two JavaScript implementations of the algorithm are included (annotated as Literate CoffeeScript):
Bjorklund.js: This follows the description of the algorithm verbatim from "Structural properties of Euclidean rhythms", but it also gets slightly different results than the examples listed in Toussaint's other paper.Toussaint.js: This version is slightly more elegant, and it's corrected to get identical results to the examples listed in "The Euclidean Algorithm Generates Traditional Musical Rhythms".
The sequencer uses the toussaint version by default.
Presets
Four of the nine preset slots have default stored presets:
- Init: T
