Traktor Hotcues on the Lemur

An iOS version of Lemur was made available in the App Store in December 2011. The app runs on iPhone/iPad and you can load your own custom interface for any MIDI or Touch OSC compatible software. Lemur editor (a free download from the LIINE website (liine.net/en/support) can be used to create the interface. One of the cool features of Lemur is its integrated script language (similar to the C programming language). By writing some lines of script code, incoming MIDI messages can be processed and used to change the interface dynamically.

I have been working on a Traktor mapping for Lemur on the iPad for some time. Unfortunately this takes more time than expected and the mapping is not yet in a state to publish it in the mappings section on traktorbible.com: Here is a screenshot from the current state of the main interface:

Example of a Lemur template for Traktor

Next to the main interface, the template contains a page to control the Traktor sample decks and another one I use to beatgrid my tracks.

While I am working on the mapping and the template you will find some tutorials here on traktorbible.com that dig deeper into some selected aspects of mapping for the Lemur.

This advanced tutorial shows how to synchronize the colours of the Lemur hotcue pads (the six buttons for each deck in the lower part of the screenshot above) with the colours that Traktor uses for the different hotcue types. To understand this tutorial you should have some basic knowledge about creating Traktor mappings and using the Lemur editor. It is also helpful to understand the structure of the different MIDI messages as explained in chapter 5 of Traktor 2 Bible.

At the end of this tutorial you will have created a Lemur template and a Traktor mapping for the hotcues of deck A and B where the pads on the Lemur use the colours Traktor assigns for the different hotcue types.

The Lemur template fort his tutorial

You can download the complete Traktor mapping and the Lemur template here.

The Steps in this Tutorial:

Step 1: Creating the basic Lemur interface

In the first step we will use the Lemur Editor to create the interface for the mapping.

  1. Start Lemur Editor.
    Lemur Editor shows an empty project.
  2. Click in the Project Panel on Create Interface.
    Enter a name for the interface and click OK.
  3. Drag a container object from the object palette onto the interface.
    The container object will be used to put a border around the pads object. Pads with no hotcue assigned shall be shown in black. Without the border the different pads of the multi pad object would not be clearly visible.
  4. Make sure that the container object is selected. Go to the Properties panel and enter Deck A in the name field and set the colour to white.
  5. Drag a Pad’s object into the container you just created. Go to the Properties panel and enter Hotcues into the name field. Use the fields Columns and Rows to create a Pads object with eight pads, by using Rows=1 and Columns=8 or Rows=2 and Columns=4 for example.
  6. Activate the Numbers checkbox.
    In Lemur editor the individual pads of a multipad object have index values starting with zero for the first pad. Once you activate Numbers you will see the numbers 0 to 7 seven on the pads. We will use the index of a single pad later to change its colour.
  7. Activate the checkbox Multilabel.
    This is necessary as we wish to display the numbers from 1 to 8 on the individual pads. When Multilabel is not active it is not possible to change the individual labels of the pads.
  8. Activate the checkbox Multicolor.
    You need to activate the Multicolor property if you wish to assign different colours to the individual pads of the Pads object. And that’s exactly what we want to do.
    Properties of the Pads object

  9. Select a bright colour for the Color On property. For multipad objects this will be the colour shown while the pad is pressed.
  10. Go to the Mapping panel and select the MIDI target you are using. The MIDI target you select here needs to match the MIDI target configured in the Lemur app. I use MIDI 0.
  11. Open the list Message and select Control Change. Enter a 0 into the field Controller and press the tab key to move the cursor into the field To. Lemur editor automatically enters the number 7. Now each pad has its own controller value in the range from 0 to 7.
    The project in Lemur Editor should now look as shown in the following figure:
    User Interface of Lemur Editor
  12. Repeat steps 3 to 10 and create a Container object with an embedded Pads object for deck B. When setting the controller values for the Pads object use 8 to 15 (instead of 0 to 7 that were used for deck A).

 

Step 2: Creating the Traktor Mapping

Creating the mapping for the eight hotcues of deck A and deck B is pretty straightforward. To select and set the hotcues you use the command Cue Loops | Select/Set + Store Hotcue eight times for each hotcue and each deck.

When your iPad is connected to your computer and when the correct port is selected in Controller Manager you can use the Learn button to learn the incoming MIDI messages. Once the MIDI message is learnt make sure, that the correct hotcue is selected in the list Set to value and that the correct deck is selected in list Assignment.

The mapping for the eight hotcues of deck A can be seen in the following figure:

Hotcue mapping in Traktor

Let’s add the outgoing MIDI messages for the hotuces where Traktor transmits the type of each hotcues. Each of the eight hotcues has its command, Hotcue1 State to Hotcue8 State. You find this in the submenu Add Out/Output.

When you add one of these commands section LED output looks like shown here:

Default settings in section LED Output for hotcue states

The values in the fields Controller Range/Min and Controller Range/Max correspond to the internal numbers Traktor uses for the different hotcue types. Check the first two columns in the following table:

The values in the two MIDI Range fields are the values Traktor sends in the second data byte of a control change message. (The first data byte contains the controller number. Please check pages 100 and 101 for more information about the structure of the control change messages.)

Enter the number 6 into the field Midi Range/Max. With this change one hotcue type corresponds exactly to one MIDI value sent to the Lemur (see third column in the table above). We will evaluate this MIDI value later in a little Lemur script and use it to assign the correct colour to the corresponding pad.

The rest is simple. You need to add all 16 Hotcue X State commands and then use the same MIDI message (i.e. channel and controller number) that you use for the corresponding In commands.

The mapping for all eight out commands for deck A is shown in the following figure:

HotcueX State commands in Controller Manager

 

Step 3: Preparations for the Lemur script code

Now we come to the exciting part. In steps 3 and 4 we will write the Lemur script code to set the colours of the pads to the colours that Traktor uses for the hotcues. Let’s start with the definition of the colour values.

Lemur templates can contain expressions. With Lemur an expression is a single-line piece of code that can be used to define variables or to do some maths. In our case we will use expressions to store the colour values as variables. (This is done because the complete template has its own track preparation page. This page contain buttons to set hotcues and the buttons will use the same colours.)

  1. Go to the Project panel and click on Create Expression. Lemur editor opens a dialog box with the same name.
  2. Enter HotcueNone and click OK. The new expression is shown below the Project node of the Project panel and its name is selected. Below the interface editor you can enter the code for this expression.
  3. Enter RGB(0,0,0) into the text field of the script editor (i.e. after the equal sign). RGB is one of the integrated Lemur functions. It converts the Red, Green and Blue parameter values into an integer that Lemur can use as a colour value. The expression RGB(0,0,0) results in Black.
  4. Repeat steps 1 to 3 for the other colour values from the following table:
    RGB values for the hotcues

  5. Create another expression and name it HotcuesRGB.
  6. Enter the following code into the text field of the script editor:
    {HotcueNone, HotcueCue, HotcueFade, HotcueFade, HotcueLoad, HotcueGrid, HotcueLoop}

The Project panel should look like this now:

="Project

Please make sure to embed the expression into curly brackets. This expression defines an array that stores the colour values of all Traktor hotcue types. You can access this array by using an index. The first index of the array is zero. By using HotcuesRGB[0] we retrieve the colour value for “no hotcue set” as this is the first element of the array. The index matches to the MIDI value Traktor is sending to our Lemur template for “no hotcue set”. By using HotcuesRGB[4] we get the fifth element of the array, i.e. the colour value of HotcueLoad.

Again, the index matches to the MIDI value Traktor is transmitting in the control change message. In order to get an exact match between MIDI values and index the constant HotcueFade was added twice to the array HotcuesRGB, because Traktor distinguishes between Fade In and Fade Out hotcues. However, our Lemur template will use the same colour for both Fade hotcues.

 

Step 4: Writing the script code to set the colour of the hotcue pads

When all actions from steps 1 to 3 are done the only thing we need is a bit of script code that performs the colour change of the pads. Traktor automatically sends a MIDI message for Hotcue X State when ever the type of a hotcue is changed.

On the Lemur side we therefore need a bit of script code that is executed when one of the 16 MIDI messages we defined in step 2 is sent. This is how to add the script code:

  1. Go to the Project panel of Lemur editor and click on Create Script. Lemur editior opens a dialog box with the same name.
  2. Enter ProcessHotcues into the text field and click OK.
    You can tell Lemur when a script shall be run. The default setting is Manual.
  3. Open the list Execution and select On MIDI.
    Execution menu

  4. Once you set Execution to On MIDI Lemur editor shows more fields next to Execution. You can use these fields to configure, which incoming MIDI messages shall be sent to the script code.
    • Open the list Message Type and select Control Change. This is the message type used in the Traktor mapping build in step 1.
    • Open list MIDI Target and select Midi 0. This is the target we set for the pads in the Lemur template.
    • The next two fields depend on the message type. For Note On/Note Off messages (not used here) enter the notes that shall be processed by the script. For Control Change messages (which we use here) enter the controller numbers. As the Traktor mapping from step 1 uses the controller numbers 0 to 15, you need to enter 0 and 14.
    • The last two fields are used to set the number(s) of the MIDI channel(s) the messages are using. As all messages in the Traktor mapping from step 1 are sent on channel 1, enter 1 into both fields.

Parameters for script execuition on MIDI

Here is the script code you need to enter in to the Script editor:

Complete script code

The script code needs to determine three pieces of information to set the correct pad to the correct colour:

  • Is the incoming MIDI message related to the Pads object DeckA or to the object DeckB?
  • Which pad (=which hotcue) in the determined Pads object needs to get colour changed?
  • Which hotcue type has pad now got?

The first two statements of the script code declare two variables: The variable idxPadNo is used to store the index of the pad in the Pads object that colour needs to be changed. Because both Pads objects contain eight pads, and because the first pad of a Pads object has index 0, the value of the variable will be later in the range between 0 und 7.

As the script shall be executed for the hotcues of deck A and deck B we store the Pads object that needs to be changed in the variable objHCPad.

Both variables are assigned in the following if else block:

if (MIDI_ARGS[0] >= 0 && MIDI_ARGS[0] <= 7)
{
      objHCPad = DeckA.Hotcues;
      idxPadNo = MIDI_ARGS[0];
}
else if (MIDI_ARGS[0] >= 8 && MIDI_ARGS[0] <= 15)
{
      objHCPad = DeckB.Hotcues;
      idxPadNo = MIDI_ARGS[0] - 8;
}

We can use the integrated Lemur variable MIDI_ARGS to access the data bytes in the incoming MIDI message. For Control Change messages the first data byte contains the controller number. To access the first data byte we use MIDI_ARGS[0]. The Traktor mapping use the controller numbers 0 to 7 for deck A and 8 to 15 for deck B. If the first data byte (=MIDI_ARGS[0]) contains a value in the range from 0 to 7 then the MIDI messages is related to deck A and we store the object DeckA Hotcues in the variable objHCPad. If the first data byte contains a value in the range from 8 to 15 then the MIDI message is related to deck B and we store DeckB.Hotcues in objHCPad. (Because the Pads objects are embedded inside a container, we need to use the name of the container and the name of the object; both elements are combined by a dot.)

The second action done in the if else block is determines the index number of the pad. As mentioned above the Traktor mapping uses the controller numbers 0 to 7 for deck A. If the value in MIDI_ARGS[0] is related to deck A then this value can be assigned to idxPadNo.

The Traktor mapping uses the controller numbers 8 to 15 for deck B. Because the index of the pad must be in the range between 0 to 7 we simply subtract 8 from the value in MIDI_ARGS[0] to get the correct index.

Example: Controller number 10 equals to hotcue 3 of deck B in the Traktor mapping; 10 minus 8 equals 2; and index 2 is the third pad in the Pads object.

The last four lines in the script code put the colour attribute of all pads in the Pads object and then change the one pad that needs to be changed. The lines in detail:

decl currentColors = getattribute(objHCPad, 'colors');
This statement uses the Lemur function getattribute(). The first parameter for getattribute must be the object, which attribute shall be retrieved. In our case we use the variable objHCPad that has been assigned in the if else block. The second parameter is the name of the attribute. The attribute colours returns for Pads objects an array; each element of the array contains the current colour value of one pad.

decl idxHCType = MIDI_ARGS[1];
In this statement the hotcue type (which we get in the second data byte of the MIDI message = MIDI_ARGS[1]) is assigned to the variable idxHCType. The value in MIDI_ARGS[1] is in the range from 0 to 6; thus in the range we configured as MIDI range in the Traktor mapping for the Hotcue X State commands.

currentColors[idxPadNo] = HotcuesRGB[idxHCType];
This statement changes the colour of one pad in a Pads object. currentColors contains the colour values of all pads in one Pads object. The index idxPadNo was set inside the if else statement. HotcuesRGB is the array that was defined in step 3. With HotcuesRGB[idxHCType] we access the colour value in the array that corresponds to the hotcue type Traktor has sent in the MIDI message. This statement thus changes only one value in the array currentColors. After the execution of this script line all eight values in currentColors correspond to the current hotcue types of that Traktor deck.

setattribute(objHCPad, 'colors', currentColors);
The last statement uses the Lemur function setattribute() to set the colours of all pads of the Pads object. This step is necessary because changing one attribute, that has values stored in an array, requires thee actions: Determining of all the attribute values of the array (in our example the eight colours of each pad); changing a single value and then assigning all attributes back to the object. And exactly this last action is done by the last line of the script code.

 

Step 5: Initializing the Lemur template

In this last step we will create a script that shall be executed when the Lemur app loads our template. This script ensures that the colour of all pads is set to HotcueNone and that the pads of each Pads object are labelled with the hotcue numbers (1 to 8) and not with the index of the pad.

  1. Go to the Project panel in Lemur editor and click on Create Script. Lemur editor opens the dialog box Create Script.
  2. Enter Initialize into the textbox and click OK.
  3. Open the list Execution and select On Load.
  4. Enter the following code into the script editor:
    Initialization script code

The first two lines use the Lemur function setattribute() to set the attribute color to HotcueNone. Please note that the attribute 'color' sets the colour for all pads of a Pads object and that attribute 'colors' can be used to change the colour of one pad (see step 4).

The last two lines use setattribute() as well. Here the attribute 'labels' is used and the text for the eight pads of both Pads objects is set to the numbers 1 to 8.

Go to the Properties panel of the Lemur editor and deactivate the Numbers checkbox. This disables the automatic numbering of the pads and ensures that only the numbers set with setattribute() are visible.

 

Perspectives

The next tutorial covering the creation of Lemur templates for Traktor will show how to output the current FX parameter values, which Traktor shows in Single FX mode below the knobs/sliders on the Lemur. An example can be seen in the screenshot at the beginning of this tutorial. There you can see that the Rate slider of FX unit 1 shows the current delay rate (1/16).

I am looking forward to your questions, suggestions and comments on what we have covered up to now.

Author: Rainer G. Haselier
Published: February 17, 2012

Share

4 Comments

viper9711
wrote on February 10, 2012 at 6:48 PM
Puh- das sieht ziemlich stressig aus. Aber Klasse beschrieben.
 Rainer G. Haselier (admin) says:
Jo, ist schon die etwas härtere Nummer. Aber die Möglichkeiten sind schon genial. Einfache Mappings, die keinen Scriptcode brauchen, kriegt man mit dem Lemur Editor recht schnell hin.
 
Steffen
wrote on February 24, 2012 at 4:21 PM
http://liine.net/en/support/) ändern in http://liine.net/en/support/

ohne ")" ;)
 Rainer G. Haselier (admin) says:
Danke, ist korrigiert!

 
Chris
wrote on March 25, 2012 at 4:35 PM
any updates on the mapping.. I just got the iPad app and looking to really test it out but sorely the configs out there are not very DJ friendly..
 
xander
wrote on August 8, 2012 at 10:13 PM
Hey... Thanx for a tut. this one helped me a lot.
Any chances you can explain, how to get loop pads like you have on a pic above?
Thanx in advance.
 

 

Leave a comment

  Name

  E-Mail (will not be published)

  Website

Cancel