Tuesday, 13 November 2012

Launchpad Sequencer - Step Indicators

Just a quick update on the progress of the sequencer I'm building in Max for my final year project. I wanted the Automap lights along the top of the Launchpad to show which step was currently playing, so I used the counter object in Max to trigger a chain of objects that turn each light on and off in sequence.

Here is an overview of the patch itself:


Download the patch here.


The data flow is explained in the comments, so I'll skip to how I put it together (and what went wrong along the way).

The main problem is that the launchpad needs two messages to control the LEDs; one to turn them on, and one to turn them off; so sending a control message each time the counter iterates isn't sufficient. To make things more difficult there's no way for the counter object to indicate that it has reset back to the minimum defined value, so I needed a way of executing one set of actions when the counter was at zero, and another when the counter was above zero.

I thought this would be a simple case of sending a light on message to the light corresponding to the counter number and a light off message to the one corresponding to one below the counter number; for example "2 on, 1 off", but implementing it was tricker than I imagined.

The way I did it was to use a routepass object to detect a message of zero coming out of the counter, and send it to a message containing the number of the maximum counter value (initially fixed at 7). All other messages come out of the second outlet, and subsequently go through a subtract object which takes 1 away from the value. This took some time to get right, because I forgot to subtract 1, so each light would come on and stay on, with a brief flicker indicating which step the counter had reached.

When I tried changing the number of steps using the number object connected to the counter I encountered even more problems: When changing the number of steps some lights would get stuck on until the counter reached that step, and the final LED of the sequence would always get stuck on unless there were 7 steps in the sequence. This second problem was easy to fix; all I had to do was connect the  number of steps number object to the right inlet of the message that is triggered on the final step. This changed the contents of the message whenever a change is made to the number of steps. 

The big headache came in trying to fix the other sticking LEDs. A flat out Launchpad reset wasn't an option, as this would erase all of the LED data relating to the actual sequencer. I first connected up a message that turned off all of the Automap LEDs, but because such a long message was being triggered each time the number object changed this created a great deal of lag when changing the number of steps by more than 2 or 3. After reading the Max reference guide I discovered the Uzi object. Uzi normally sends out a specified number of bang messages when it is triggered, but out of the third outlet comes the index number of each bang as an integer. Put simply, it will count from 1 to whatever you tell it to very quickly. I connected this to the middle inlet of my note off pack object (via a + object to reference the LEDs) and it provided me with a convenient way of resetting the LEDs each time.

Here's a video of the final result in action:



A couple of quick notes on the patch above:

The Automap LEDs on the launchpad are controlled by CC messages 104 to 111 on channel 1. This means that all messages to them should begin with 176. The actual data byte controls the colour and brightness of the LED. In this case a value of 3 results in a bright red LED and 0 turns it off.

The message box containing "176 0 0" connected to midiout causes the launchpad to reset; clearing both buffers and turning all LEDs off. This is a useful message to send when closing the patch using the closebang object - otherwise the LEDs will stay on until they are next referenced.
Your Ad Here

No comments:

Post a Comment