edit: Github link: https://github.com/outterback/bitwig-python-bridge
Cutting to the chase, video demo
I've been interested in automatic music generation for a while, and I had the idea of trying to do it with Bitwig Studio. I've put together a demo that makes the BWS Java API accessible from Python. You might wonder why, but I'm more in the camp of why not. I thought it was a shame that the API is only accessible via MIDI controllers, and wanted to actually use it for programming, without creating a virtual MIDI interface, or doing it in a needlessly complicated way (you may argue that this is still needlessly complicated :p).
The code for this project pretty short, and uses the library Py4j, that opens a gateway between Java and Python. The Py4j library is bundled inside the controller extension, which makes it accessible to Bitwig at runtime.
Some things this enables:
* Python REPL access to the Bitwig Studio API. Tinker, automate, explore, and play with BWS API functions from your python console
* Automation. I'm demonstrating some automated functions in the video below, namely adding a major scale, minor scale, and a MIDI panic function. I've added access to cursors for Track, Clip, Remote Controls, and Device, so they are all controllable from the Python interpreter.
* Global hotkeys extending the default Bitwig ones. This uses the python package keyboard. This package unfortunately requires sudo on linux, but doesn't seem to need it on Windows. This is kind of a red flag for me, and I don't want to condone using it before I've checked it out fully, but it works as a proof of concept.
* I'd like to say that anything you can do in the API, you can do from Python, but I don't want to make that promise. It sure seems like it though.
Some things that are kind of iffy:
* Code runs too fast - Bitwig might not have time to respond to everything being sent, so I'm experimenting a bit with sleep timers. Need to work more on this.
* Method introspection - running
Code: Select all
Code: Select all
Python displaying information about the track object:
I'll publish the code later tonight