Monday, October 08, 2012

Max for Live Basics Tutorial 2: MIDI Transposition Effect

Overview
The aim of this tutorial is to cover the basics of creating a MIDI transposition effect in Max for Live. This tutorial should be seen as a starting point that can be expanded upon. This tutorial assumes that you have read Max for Live Basics 1.

Max for Live is an extension for Ableton Live. This allows users to load patches made in Cycling 74's Max inside of Ableton as Live devices. Max is a graphical programming language whereby patches are created by connecting various objects together. Each object performs a specific function, and multiple objects - interconnected in specific ways - can perform complex operations.

In Max for Live, three categories of devices can be created:
• Audio effects
• MIDI effects
• Instruments

An audio effect takes an audio signal as an input and outputs an audio signal.

A MIDI effect takes MIDI data as an input and outputs MIDI data.

An instrument takes MIDI data as an input and outputs an audio signal.

This tutorial will cover how to create a MIDI transposition effect.


video











Basics: MIDI Transposition



Create a blank Live Set. Create a blank MIDI track. Onto this MIDI track, put a blank Max for Live MIDI effect, which can be found in Live Devices > MIDI Effects > Max MIDI Effect. 


Note that the MIDI effect has one input and one output, representing MIDI data going into and coming out of the device. 


Open the device in Max by clicking on the edit icon. Max should open up with the device patch. 


Save your MIDI effect in the Max MIDI Effect folder. I have named mine Seb.ExampleTransposition. 


Delete the unnecessary comments and also delete the patch cable in between the midiin and midiout objects. These two objects represent the input and output of the device. To quickly select and delete multiple patch cables, simply click and drag the mouse cursor whilst holding down the option key.


Expand the size of the Max patching window. Add a midiparse object and connect the outlet of the midiin object to the midiparse object.


Just like in the previous example, we need to access the pitch of a note separately from the velocity. To do this, we once again need an unpack i i object connected to the first outlet of the midiin object.  Additionally, connect a midiformat object to the midiout object.

The midiformat object is basically the inverse of the midiparse object, and can transform simple numbers and lists into MIDI-formatted serial data that we can send on to whatever device is next in our Ableton Live effects chain.


Add a + object, and connect the first outlet of the pack i i object to it. The first outlet of the pack i i object represents the MIDI pitch of an incoming note.  The second outlet represents velocity.


Create a pack i i object. Connect the outlet of the + object to the first inlet of the pack i i. Connect the second outlet of the unpack i i object to the second inlet of the pack i i object. Thus, the velocity is passed straight through the plugin, leaving only the pitch to be affected. 

The midiformat object takes a list of two numbers (pitch and velocity) in its first inlet. We can create such a list after our transposition by packing our new MIDI pitch value along with our velocity into a message. 



Create a live.dial object. This is similar to the live.numbox, but looks a little different...


Like the live.numbox, the live.dial is used as part of the GUI. It can be automated just like any other Live parameter. 


Open up the object inspector for the live.dial object (command (apple) i). Change the Long Name and Short Name to "Transposition. This will mean that the dial will have the name Transposition on screen in the GUI, and also on screen when it is automated in the Arrangement Window. 


Change the type to "float". Change the Range / Enum to -48. 48. This is our transposition range in semitones.


You will see that the dial changes to reflect the new data range. You may need to make the object longer by resizing it with the mouse so that the whole word "transposition" can be seen.



Connect the left outlet of the Transposition dial to the right outlet of the + object.


Connect the output of the pack i i object to the midiformat object. 


Re-arrange your objects so that you can see them when you are in Live!


Try out the device in Live. 


You will see that in the Live Devices browser, the transposition device that you have created appears in a location relative to where you saved it. This way you can re-use it in other projects and sessions. 


You can even use it in conjunction with the sine synth made previously! 










Extension: Passing Through Original Notes As Well As Transposed Ones


At the moment, our MIDI effect only transposes the original pitch, but does not allow the original pitch through.  Let's add an option to allow the use to do exactly that! A simple on / off toggle, which - when switch to on - allows the original notes to pass through.

Create a live.toggle object. This is just an on / off button. When the button is switched from on to off, it sends out a 0. When the button is switched from off to on, it sends a 1.

 
Add a comment to describe the action of the button.


Create a new gate object. Connect the left outlet of the midiparse object to the right inlet of the gate. The gate allows message to go through when it is switched to on, and stops messages from going through when it is switched to off.

The left inlet of the gate controls this action. When the gate receives a 0 in its left inlet, nothing passes from the right inlet to the outlet. When the gate receives a 1 in its left inlet, any data that goes into its right inlet is automatically passed to the outlet.


Connect the outlet of the gate to the first inlet of the midiformat object. 


Connect the live.toggle object to the left inlet of the gate object. This way - whenever the gate is open by way of the toggle - any incoming notes are automatically sent to the output via the midiformat object.










Extension: Velocity Scaling

At the moment, our transposition object only changes the pitch. But what about the velocity? A useful addition might be a control that scales the velocity in terms of percentage.


Create a live.dial object.  Change the Long Name and Short Name to "Velocity". Change the Range / Enum to 0. 100.. Change the type to Float. Change the unit style to %.


Place the dial in an appropriate location. 


Delete the connection from the second outlet of the unpack i i object to the second inlet of the pack i i object. 


Add a * 1.0 object (not *~ 1.0!). Connect the outlet of the second outlet of the unpack i i object (our velocity) to the left inlet of the * 1.0 object.

The * 1.0 object is a simple multiplication object, and multiplies any numbers it receives in its left inlet by whichever number was last received in its right inlet. 


Connect the outlet of the * 1.0 object to the inlet of the pack i i object. This is our scaled velocity going to the output via the midiformat. 


Add a / 100. object. This object will simple divide the output range from the dial (which is from 0. - 100.) by 100., yielding a range of 0. 1.. Connect the left outlet of the live.dial object to the left inlet of the / 100. object.


Connect the outlet of the / 100. object to the  * 1. object. Thus, each velocity value is multiplied by a percentage between 0% and 100% as determined by the Velocity parameter.


Save your device, and try it out!









Exercises
• Edit your patch so that the MIDI transposed notes are in fact delayed in time (hint objects: pipe)
• Edit your patch so that there are multiple notes of transposition available simultaneously, each with its own transposition and velocity parameters.

1 comments:

Anonymous said...

Great but when you transpose all the notes hang/stick. This cannot be used musically or 'live'