Monday, May 28, 2012

Bidule Basics 3: MIDI Control of Audio Effects

This post assumes that you have read the previous Bidule Basics posts. The Bidule file and Live session and samples used in this example can be found here.

Take Control!
The aim of this post is to provide a simple example of using MIDI note data from an Ableton Live MIDI track to control parameters of audio effects inside of Bidule.

This example represents just one possible data mapping, and a very simple method of control. The setup presented here can be expanded upon extensively.

Nonetheless, we can break the process down into several easy steps:
• Set up MIDI routing
• Create a MIDI track and sequence relevant MIDI data
• Add routing and setup the Bidule patch

Let's assume a starting point from the end of the previous Bidule Basics post about parameter modulation

Here, the frequency of the Biquad Filter objects was controlled by an LFO, and the Q was controlled by a standard Variable object slider.

Every MIDI note has two data components - pitch and velocity, both of which have a data range of 0 - 127. Velocity can be thought of as a representation of volume / note strength.

The aim for this post is to use MIDI notes to control these two parameters of the Biquad Filters - mapping the note pitches to the frequency and mapping the velocity to the Q.

Setting Up The MIDI
The first thing we need to do is actually let Ableton Live know that we want to use the virtual MIDI inputs that are created when we add an instance of Bidule to our session.

First, go to Ableton Live > Preferences and navigate to the MIDI Sync tab. Make sure that the input and output ports for the Bidule AU 1, 2, 3 and 4 devices are set to ON for the Track column, as shown below.

The next stage is to create a MIDI track and route the output of the track to the Bidule plugin. In Ableton Live, go to Create > Insert MIDI Track. Go to the Session view by pressing tab and route the output of the MIDI track to Bidule AU 1 - Channel 1, as shown below.

On the MIDI track, create a new MIDI region and sequence some MIDI notes, as shown below.

Create the Connection
Within the Bidule patch, delete the LFO and associated variables. Create a Bidule MIDI Input device by dragging and dropping an object from MIDI Devices > Input > Bidule AU 1.

This object represents data coming in that is routed to the Bidule AU 1 virtual MIDI port (such as the MIDI track that we just set up).

This one, single outlet can contain all sorts of data - from MIDI notes and velocities, to MIDI continuous controllers, pitch bend data and more. 

Note that the outlet of the Bidule AU 1 object is white - this means that it carries MIDI data. Many Bidule connections are blue in colour - this means that they carry sample-based audio.

You cannot connect MIDI data directly to the blue connections - we need to convert the MIDI data into a format that we can use with the majority of Bidule objects (such as the input for our filter frequency, which is blue). 

Extracting Note Data
We now need to actually extract just the data that we are interested in - in other words, we need just the note data (i.e. pitches and velocities) and we don't need any other types of data (CC, pitch bend etc). 

The perfect object for this is the MIDI Note Extractor object, which listens to a stream of MIDI data and then extracts only note data. Once the note data has been extracted, pitches and velocities are converted to more useful data types and ranges. 

The pitches (that are normally numbered notes from 0 to 127) are converted to actually frequency number values. The velocities (that are normally numbered in the range of 0 to 127) are converted and scaled to an amplitude range from 0 to 1. Connect the output of the Bidule AU 1 object to the inlet of the MIDI Note Extractor object.

The Note Extractor object has four outlets. These are: 
• Frequency
• Amplitude
• Gate
• Trigger

Of interest to us are just the first two outlets - frequency and amplitude. Connect the frequency outlet directly to the filter frequency inlets of the Biquad Filter objects. 

Thus, any notes that are sent to the Bidule AU 1 MIDI port will be routed to the Note Extractor and then pitches are converted to frequencies, eventually controlling the frequency of the Biquad Filter objects.

Controlling the Bandwidth / Q
The next stage of the process is to make a connection between the velocity of the notes and the Bandwidth / Q of the Biquad Filter objects. Delete the simple Variable object that is currently connected to the Biquad Filter object and controlling its Q parameter. 

 The Bandwidth / Q inlet of the Biquad Filter expects a data range of 0 - 10 or so.

However, the output of the MIDI note extractor converts the velocity to an amplitude value from 0 - 1. Beyond this issue, the Q / Bandwidth and velocity have an inverted relationship. 

A low Q / Bandwidth represents a steeper / more obvious filter, whereas a low velocity represents a quieter / more subtle note. 

So, we need to transform our amplitude values to: 
• Become within the range of 0 - 10
• Become inverted with respect to their original value range

We can use the Function object, and easily scale and invert our velocity amplitude values. Add a Function object and type in a suitable expression with respect to X, such as: 10 - (x * 10). 

Connect the output of the amplitude values from the MIDI Note Extractor outlet to the X input of the function object. Connect the output of the function object to the Q / Bandwidth of the Biquad Filter objects

Thus, the velocity of any note that is sent to the Bidule AU 1 MIDI port is converted to a value of 0 - 1, then scaled and inverted to a value of 0 - 10, then eventually routed to the Q / Bandwidth of the Biquad Filter objects.

The most important thing to take away from this is the fact that MIDI data - whether notes or other types of data - can be mapped easily and quickly to parameters within a Bidule audio effect plugin, allowing for musical control of the patch. 

Some things to consider: 
• MIDI CC can be used alongside pitchbends and note data
• Explore using the trigger and gate outlets of the Note Extractor
• Any MIDI effects found within live can be added to the MIDI track in question for added control / interest.