Posted by & filed under Bitwig Studio, Blog, Tutorials.

In the last article we examined building some objects in order to house custom functionality, and variables for the Transport in Bitwig. In this article we will start building another object that deals with automatic parameter mapping and LED feedback for device parameters in bitwig. You can check out all the scripts at the Github repository.

The Bitwig API has a ton of options for controlling and getting information about the device. You can monitor specific tracks, and devices, or you can create an object that follows the cursor: the selection of the user in the Bitwig interface. Let’s start by creating a view onto the cursor device in our init function:



Now we have an object that references the currently selected device in Bitwig. This will default to the first device on the track when selecting a new track, allowing us to conveniently control and get information about the device whenever a new one is selected.

There are tons of properties and methods associated with devices, but for now we are concerned with setting parameter values from a MIDI controller. If you consult the API you can see that you can access the parameters of a device via the getParameter() method. Once you have a parameter you can call the set() method to set the value with MIDI data.



The first argument in the getParameter() method is the index of the parameter in the current page, the arguments in the set() method, are the value to set and the range of values to expect. So this code sets the first parameter to it’s highest value. Of course this isn’t useful at all, really. We want to take MIDI CC in and, depending on the CC, control a certain parameter. This only takes a little modification.

Let’s start building our parameters{} object by defining it in our functions file and assigning it a control() method:

This bit of code does quite a bit for us. First, we declare a property of the parameters object called offset. This makes it easy to sync up our CCs with the index of the parameters of a device. If the CC entering this function is within the desired range, it gets a parameter at an index and then sets it to the incoming value of the CC. I have chosen CCs 1-8 to send to our script, but you can use any that you like. It helps a great deal if the CCs are sequential. Otherwise you’d have to write functions for each unique CC, which would be a bit verbose. Let’s add the parameters.control() method to the CC section of our MIDI input in the main script. If you’ve done everything correctly and are sending the proper CCs, you should now be able to load up a device and have control over the first 8 parameters of the device.

If a device has more than 8 parameters (like one of the built in Synths), the parameters are divided into pages. The devices have factory pages, but you can also define your own by right clicking on the device title bar and selecting ‘Edit Panel Mappings’. The API allows you to navigate the pages with methods of the CursorDevice. It would be nice to be able to scroll through these pages with a MIDI controller. Let’s add a pageScroll() method to our parameters{} object:



This code looks for a MIDI note of 17 or 18 with a velocity greater than 0 and will go to the previous or next parameter page, respectively. Add the parameters.pageScroll() method to the MIDI note section of our MIDI input. Now you can modify ANY parameter of ANY device in Bitwig all from the controller of your choice. Pretty rad.

One more thing to add to this to increase usability, is enabling on screen indications that will show the user which parameters are currently under remote control. It’s a simple matter of creating a function that you will call once in your init() routine. It will look like this:



This is a simple for loop that sets our parameters to show their indications. Call parameters.update() at the end of init(), or anywhere after you’ve created your cursor device, and there will be colored indications that follow your parameter page selection in Bitwig.

So now we have transport control, note input, user mappings, and automatic parameter control. This script is slowly gaining features! In the next article, we will look at setting up observers for our parameters that send LED feedback to our controllers.

As always, direct any questions, comments or concerns to