Beam Beats tangible rhythm sequencer: work is in progress!

Beam Beats is an interactive and tangible rhythm sequencer that translates the geometry of beacons on the ground into rhythms and polyrhythms thanks to a rotating laser beam. This experimental MIDI instrument is about investigating self-similarities in polyrhythms, as described in this post.

Update: Here’s the video of a demo at Dorkbot at La Gaité Lyrique in Paris

BeamBeats demo at Dorkbot at la Gaité Lyrique from cyrille martraire on Vimeo.

Before I report more on this project with demos and videos, here are some pictures to illustrate the work currently in progress, thanks to lasercutting techniques in particular:

The brand new laser-cut acrylic structure
The prototype laser head and retro-reflection light sensor
The Arduino to detect the light variations and convert them into MIDI notes
Very early design of beacons each with their own light sensor

This prototype works, here’s a picture of the laser beam rotating:

The revolving laser beam reflected on the wall

And here’s a very short early video (no sound)

Beam Beats – revolving laser beam to detect beacons from cyrille martraire on Vimeo.

I’ve been working on the Arduino source code to add the ability to send MIDI clock in order to sync Beam Beats to other MIDI devices.

Now I mostly need to conclude on the design for the active  beacons(sensors stands) and the passive (retroreflective adhesive stands) beacons, and find out what to play with this sequencer…

Every post on this project:

Read More

Knobs pagination in Arduino

Here is an example of how to use the same knobs (e-g. 6 knobs easy to connect to the 6 Arduino analog inputs) several times to adjust several parameters spread over several “pages”.

This enables to “multiplex” the same knobs many times, in a safely fashion thanks to the protection mecanism:  after changing the active page, every knob is in protected mode (turning the knob does not change the value of the parameter) not to force a sudden jump of value. On turning a knob, the LED lights on when the knob’s value matches the stored value, and then the knob becomes fully active (at least till the next page switch).

This mecanism is inspired and similar to that of the microKorg synth edit knobs. As they say about it in Wikipedia:

“In the Edit mode, however, every knob makes the LED panel display the current value associated with the knob position. To change the current value of a given parameter, the user must pass through the original value before being able to modify anything. When one that original value, the Original Value LED will light on, and the value displayed on the LED panel will stop flashing. This avoids the user from passing from a small to a high value immediately, so there’s no big margin in the change of the parameters (a useful function for live performances).”
The microKorg Edit panel, with 5 knobs and 22 pages = 120 parameters to control
The microKorg Edit panel, with 5 knobs and 22 pages = 120 parameters to control

In Arduino

Console output printing the 4 pages of 6 parameters and the currently active page
Console output printing the 4 pages of 6 parameters and the currently active page

To do this in Arduino is not very difficult.We first need a 2-dimension array to store the value of each parameter:

// the permanent storage of every value for every page, used by the actual application code
int pageValues[PAGE_NB][KNOB_NB];

We also need an array to store the state of each knob: whether it is PROTECTED or ACTIVE, and yet another array to keep track of the value of each knob in the previous loop, in order to detect when a knob is being turned:

// last read knob values
int knobsValues[KNOB_NB];
// knobs state (protected, enable...)
int knobsStates[KNOB_NB];

Then we begin to read the digital switches to select the current active page. In case the selected page has changed, every knob has its state set to PROTECTED. We then read the analog value for each knob, detect changes, find out when the knob value is in sync with the stored value for the parameter to light the LED and set its state to ACTIVE.

Only when the state is set to ACTIVE we copy the current value of the knob to the actual parameter stored for the current page.

In my experiment I have 4 digital buttons connected to digital inputs 8 to 11, and 6 knobs (pots) connected to the 6 analog inputs:

The Arduino board, the 4 page buttons and the 5 + 1 knobs and fader
The Arduino board, the 4 page buttons, the 5 + 1 knobs and fader and the LED

Here is the full code below:

 * Handles a pagination mecanism, each page can use the same knobs;
 * Digital switches select the current active page.
 * This enables to "multiplex" the same knobs many times, safely thanks to the protection mecanism.
 * After changing the active page, every knob is protected, not to force a jump in value.
 * On turning a knob the LED lights up when the knob's value matches the stored value, and then
 * the knob becomes active till next page switch.
 * This mecanism is inspired and similar to that of the microKorg synth edit knobs.
 * Copyleft cyrille martraire

//---------- USER INPUT AND PAGINATION -----------
#define PAGE_NB 4
#define KNOB_NB 6

#define PROTECTED -1
#define ACTIVE 1

#define SYNC_LED 12

// the permanent storage of every value for every page, used by the actual music code
int pageValues[PAGE_NB][KNOB_NB];

// last read knob values
int knobsValues[KNOB_NB];
// knobs state (protected, enable...)
int knobsStates[KNOB_NB];
// current (temp) value just read
int value = 0;
// the current page id of values being edited
int currentPage = 0;
// signals the page change
boolean pageChange = false;
//temp variable to detect when the knob's value matches the stored value
boolean inSync = false;

void setup() {
  pinMode(13, OUTPUT);



void setupPagination(){
  pinMode(SYNC_LED, OUTPUT);
  for(int i=0; i < KNOB_NB; i++){
    knobsValues[i] = analogRead(i);
    knobsStates[i] = ACTIVE;

// read knobs and digital switches and handle pagination
void poolInputWithPagination(){
  // read page selection buttons
     value = digitalRead(i);
     if(value == LOW){
         pageChange = true;
         currentPage = i - FIRST_PAGE_BUTTON;
  // if page has changed then protect knobs (unfrequent)
    pageChange = false;
    digitalWrite(SYNC_LED, LOW);
    for(int i=0; i < KNOB_NB; i++){
      knobsStates[i] = PROTECTED;
  // read knobs values, show sync with the LED, enable knob when it matches the stored value
  for(int i = 0;i < KNOB_NB; i++){
     value = analogRead(i);
     inSync = abs(value - pageValues[currentPage][i]) < 20;

     // enable knob when it matches the stored value
        knobsStates[i] = ACTIVE;

     // if knob is moving, show if it's active or not
     if(abs(value - knobsValues[i]) > 5){
          // if knob is active, blink LED
          if(knobsStates[i] == ACTIVE){
            digitalWrite(SYNC_LED, HIGH);
          } else {
            digitalWrite(SYNC_LED, LOW);
     knobsValues[i] = value;

     // if enabled then miror the real time knob value
     if(knobsStates[i] == ACTIVE){
        pageValues[currentPage][i] = value;

void loop() {

void printAll(){
     Serial.print("page ");

     //printArray(knobsValues, 6);
     //printArray(knobsStates, 6);

     for(int i = 0; i < 4; i++){
       printArray(pageValues[i], 6);

void printArray(int *array, int len){
  for(int i = 0;i< len;i++){
       Serial.print(" ");

Read More

Geometric Rhythm Machine

In the post Playing with laser beams to create very simple rhythms” I explained a theoretical approach that I want to materialize into an instrument. The idea is to create complex rhythms by combining several times the same rhythmic patterns, but each time with some variation compared to the original pattern.

Several possible variations (or transforms, since a variation is generated by applying a transform to the original pattern) were proposed, starting from an hypothetical rhythmic pattern “x.x.xx..”. Three linear transforms: Reverse (”..xx.x.x”), Roll (”x.x.xx..”) and Scale 2:1 (”x…x…x.x…..”) or 1:2 (”xxx.”), and some non-linear transforms: Truncate (”xx..”) etc.

Geometry + Light = Tangible transforms

The very idea behind the various experiments made using laser light beams and LDR sensors is to build an instrument that proposes all the previous transforms in a tangible fashion: when you move physical object, you also change the rhythm accordingly.

Let’s consider a very narrow light beam turning just like the hands of a clock. Let’s suppose that our clock has no number written around, but we can position marks (mirrors) wherever on the clock surface. Still in the context of creating rhythms, now assume that every time a hand crosses a mark (mirror) we trigger a sound. So far we have a rhythmic clock, which is a funny instrument already. But we can do better…

Going back to our rhythmic pattern “x.x.xx..”, we can represent it with 4 mirrors that we position on a same circle. On the illustration below this original pattern is displayed in orange, each mirror shown by an X letter.. If we now link these 4 mirrors together with some adhesive tape, we have built a physical object that represents a rhythmic pattern. The rotating red line represents the laser beam turning like the clock hands.

Illustration of how the geometry of the rhythmic clock physically represents the transforms
Illustration of how the geometry of the rhythmic clock physically represents the transforms

Now we have a physical pattern (the original one), we can of course create copies of it (need more mirrors and more adhesive tape). We can then position the copies elsewhere on the clock. The point is that where you put a copy defines the transform that applies to it compared with the original pattern:

  • If we just shift a pattern left or right while remaining on the same circle, then we are actually doing the Roll transform (change the phase of the pattern) (example in blue on the picture)
  • If we reverse the adhesive tape with its mirrors glued on, then of course we also apply the Reverse transform to the pattern (example in grey on the picture)
  • If we move the pattern to another (concentric) circle, then we are actually applying the Scale transform, where the scaling coefficient is the fraction of the radius of the circle over the radius of the circle of the original pattern (example in green on the picture)

Therefore, simple polar geometry is enough to provide a complete set of physical operations that fully mimic the desired operations on rhythmic pattern. And since this geometry is in deep relationship with how the rhythm is being made, the musician can understand what’s happening and how to place the mirrors to get any the desired result. The system is controllable.

To apply the Truncate transform (that is not a linear transform) we can just stick a piece of black paper to hide the mirror(s) we want to mute.

If we layer the clock we just described, with one layer for each timbre to play, then again changing the timbre (yet another non-linear transform) can then be done by physically moving the pattern (mirrors on adhesive tape) across the layers.

From theory to practice

Second prototype, with big accuracy issues
Second prototype, with big accuracy issues

Though appealing in principle, this geometric approach is hard to implement into a physical installation, mostly because accuracy issues:

  1. The rotating mirror must rotate perfectly, with no axis deviation; any angular deviation is multiplied by two and then leads to important position deviation in the light spot in the distance: delta = distance . tan(2 deviation angle)
  2. Each laser module is already not very accurate: the light beam is not always perfectly aligned with the body. To fix that would require careful tilt and pan adjustment on the laser module support
  3. Positioning the retroreflectors in a way that is accurate and easy to add, move or remove at the same time is not that easy; furthermore, even if in theory the retroreflectors reflect all the incoming light back to where it comes from, in practice maximum reflectance happens when the light hits the reflector orthogonally, which is useful to prevent missed hits

Don’t hesitate to check these pages for progress, and any feedback much appreciated.

Read More

Musical instruments for musicians and non-musicians: Put into practice

Other posts in the series Musical instruments for musicians and non-musicians:

  1. Part One: Controls: Analysing how continuous or discrete controls on the sound affect playability to great extent
  2. Part Two: Constraints: How embedding musical theory as constraints makes the instrument easier and more rewarding
  3. Part Three: Exotic examples: Examples of exotic instruments and how they achieve good or not so good results
  4. Part Four: Put into practice: Let’s put theory into practice to build an easy and musically-sounding Theremin

Now we want to put that into practice to build a musical instrument. Let’s consider we want to do something inspired by the Theremin, but simpler to play and more funny to look at while easier to build as well.


Here is now a case study: We want to build an instrument that must be:

  1. Playable by friends that know very little in music: in other words really easy to play
  2. Attractive for friends that enjoy the fun of playing and jamming together: must be expressive
  3. Suitable for groovy electronic music (house, hip-hop, electro, acid-jazz, trip-hop and a bit of techno)
  4. Able to participate within a small band among other instruments, mostly electronic machines
  5. With a funky look and visually attractive when performing

Design and justification

The finished instrument
The finished instrument

Based on these requirements, and after some trials and error we go for the following:

  1. Finger physical guidance, because it is too hard to keep hands in the air at the same position (req. 1)
  2. Bright leds plus light sensor as a primary way of playing, for the funky look and visually attractive performance (req. 5)
  3. Discrete pitch as primary way of playing, with pitch quantization against a pentatonic scale, easy, good sounding (but coupled to one fixed tonality unless putting configuration buttons) (req. 1)
  4. Expression on the pitch when a note is pressed send pitch bend events to modulate the pitch as on a guitar  or real theremin; this only happen after a note is pressed, not to conflict with the primary pentatonic scale (req. 2)
  5. Allows for additional expression using a distinct light sensor mapped to a Midi Continuous Controller (controller 1: modulation wheel) (req. 2)
  6. Continuous rhythm control to start the project simply, plan to quantize it on 16th notes according to a midi clock later (tradeoff to keep simple right now, should be even simpler due to req. 1)
  7. MIDI controller rather than integrated synthesizer to allow for very good sounds generated from external professional synthesizers (req. 3)
  8. Internal scale setup within the range between C3 and C5, to dedicate the instrument to play solo on top of an electronic rhythm (req. 4)
  9. Arduino implementation (easy to implement pitch quantization logic and expression controls)


The very simple circuit
The very simple circuit
The Arduino board
The Arduino board
  • An aluminium rail (from a DIY shop) is fixed to an empty salt box as the body (hence the name “Salty Solo”)
  • A LED (from Booxt) slides on the rail
  • The main sensor and the expression sensor are two simple LDRs connected through a voltage divider to two Arduino analog inputs
  • Two buttons are simply connected to two Arduino digital inputs.
  • The MIDI out DIN plug is connected to the Arduino Tx pin.
  • The rest is in the Arduino software!

I have decorated the salt box with adhesive stuff…

Playability and fixes

At first try, playing the Salty Solo is not that easy! A few problems happen:

  1. Reaction time (or “latency”) is not good
  2. Moving the light with the left hand is not very fast, hence impedes playing a melody that sounds like one.
  3. Also there is a kind of conflict between the note quantization that does a rounding to the closest accurate note, and the expression control that allows to “bend” notes.

The first problem has been solved by increasing the Arduino loop frequency down to 100Hz (wait period = 10ms); to prevent sending MIDI continuous controller and MIDI pitch bend too often we therefore needed to send them (when needed) once out of a few loops.

For the second problem a workaround has been done by using the second button to trigger the next note in the scale, and pressing both buttons together triggers the second next note in the scale. Basically, in the (almost) pentatonic scale we use this usually means jumping to the third or to the fifth. This kind of jump is very common when playing guitar or bass guitar thanks to their multiple strings, and it does help play faster while moving the left hand much less. With two buttons like this it is much easier to play melodic fragments.

The last problem has been solved a bit randomly: because of a bug in the code, the pitch bend only happen when on the highest note: this saves the most useful case of playing the guitar hero on a very high note while bending it a lot. On the other notes, sliding the left hand descend or ascend the scale instead. Further playing and external opinions will probably help tweak this behaviour over time.

Here is the Arduino source code for Salty Solo

Here is a video to illustrate how it works…

Experimental instrument for musicians and non-musicians from cyrille martraire on Vimeo.


Other CC that could be used (however the modulation wheel can also control the same parameters, on a program by program basis on a synth):

  • 1 Modulation Wheel or Joystick (positive polarity) (MSB)  Can be effectively remapped to other controllers on some synth
  • 7 Volume (MSB)  If you re-route to Controller 7, your software mixer will mess up
  • 71 Resonance (aka  Timbre)
  • 74 Frequency Cutoff (aka  Brightness )

And the panic button: 123 All Notes Off

Read More