AddMIDI

AddMIDI is now replaced by AddRoutes for Blender 2.8

Introduction

This Add-on let you send or receive MIDI informations in real-time in the Blender viewport. The MIDI events can be routed to any properties of your choice. 

Usage

Setting the Devices

  • Start/Stop: Theses buttons control the engine of AddMIDI, you will of course need to have it running in order to send/receive MIDI events.
  • Status: The state of the modal timer.
  • Midi In / Midi Out: The MIDI devices, can be set to None if you want to disable receiving or sending.
  • Refresh the MIDI Devices List: This button will check again the devices available, there is no automatic refresh currently.
  • Update rate(ms): This is the rate of MIDI engine actualization, 0.1 millisecond is the lowest possible value. Lower values give better granularity but may cause higher CPU usage. 
  • Start at launch: The MIDI engine will start as soon as the Blender project is opened. 

All theses settings are stored in the Blend file and are not scene dependent. Note that the update rate parameter needs a Stop/Start cycle to be taken in account.

Basic Principles

AddMIDI relies on Keying Sets as a way to easily select and import properties that will be bridged toward the external wold, but you can use directly the text editor to create more complete lists of MIDI items, with their respective settings (see below). 

  • Import Keying Set: Once you have gathered enough properties, this button will import them as MIDI items. This button will currently replace an existing list of items and unfortunately (for now) all of their settings.
  • Save list as text: This will create the file "AddMIDI_items_list", this time with all the items settings. You can see this file with the Blender Text Editor and edit it freely.
  • Import keys from text: The inverse operation. It will parse the file "AddMIDI_items_list" if it exists. Some items are 5 lines long (Notes related) other 6 (because of the extra controller number).  

This is an example of a list containing 3 items. 

  • Key: Its the property you want to bind to a MIDI event.
  • Channel: MIDI channel.
  • Event type: There are few to choose from. As you see with the third item, when you select a MIDI controller, you can choose a controller number.
  • Min/Max: Theses are the parameters to map to raw MIDI value to a more useful range for Blender. If you set Min to -5 and Max: to 200, the 7 bit controller (0-127) will be remapped so that 0 equals -5 and 127 equals 200. If it is a 14bit controller (0-16383), it's of course 16383 that will equals 200 (but with better granularity).

Installation 

Choose one of the two methods:

1) Easy install

NEWS : Ready-to-go zip files are ready for Linux, MacOS and Windows. Pick one and install it without decompression like any other Blender Add-on. That's, it, you should be ready after that. 

2) System wide install 

If you want to work on the developpment of the Addon or prefer to have a system wide installation of this Add-on, you need:

  • A full install of python 3.x (depending of Blender)
  • The python-rtmidi module (author: Christopher Arndt) 

a) Getting a full install of Python

Read this page that explains all.

b) Installing python-rtmidi

Python-Rtmidi has reached version 1.1 and you can grab the sources or binary modules from this page.

For the sources version: unpack the archive somewhere and read carefully the instructions. You will have to install Cython with pip (which in turn may require a compiler to be installed on the system) if not done already.

Depending of your OS you might as well find some binary modules for python-rtmidi in the download section. They are in whl format.

When you invoke Python to install this module, use of course "python3.x" located in the bin dir of your full Python installation mentionned in my page above and the module will be installed right in the good place (you can check that with 'pip list' even though it was not installed with it). 

c) Installing the AddMIDI Add-on

You should be ready now to install it. This is the most easiest part actually.

Grab the Add-on from my Github page (Download ZIP on the right), then install and enable it through the Blender User Preferences screen... 

Misc

License 

GPL v3

Planned

  • A merge feature for importing a Keying Set in a way which preserves the exisiting MIDI settings. 
  • MIDI synchronization ?

Synchronization

Right now AddMIDI doesn't provide by itself any form of MIDI synchronization with a sequencer for instance. Fortunately on Linux (and OSX and may be even Windows) Blender can use the JACK protocol. Set Blender to use JACK in the user preferences and choose 'AV-Sync' in the Timeline Screen, that will work perfectly if of course you use a JACK aware sequencer like Ardour or Muse2, or any other. Start, stop, and moving the playhead will reflect on both softwares.

Shortcomings

  • There is currently a de facto MIDI Thru behavior, beware of loops ! 
  • A MIDI event is sent only when a Blender property change. Consequently when you rewind the sequencer, there is no message sent if there is no change since the last time.

Example

Download: here.


Controlling properties is nice but what if you want to control Blender directly (i.e, accessing bpy.ops) ? AddMIDI doesn't allow this directly but there is a trick used in this example to bypass this limitation. 

When you create a property using Python in a script you can set an update function. Each time your property will change this function will be called. It is then very easy to write whatever you want in this update function. 

The example here is no less than a real-time polyphonic synthesizer based on this principle.

Note: when you load this file, the python script needs to be executed at least once. I enabled the "Register" option as you can see on the screenshot. But Blender won't nonetheless execute it without your consent, to protect user from untrusted scripts. You will have either to click "Reload Trusted" in the top bar or click "Run Script" manually. If not the 2 properties (with their update function) won't be created.    

Links

 There is a thread about this Add-on on the BlenderArtists.org forum.