borfo

pyBLM - Headless Python-based Novation Launchpad BLM implementation [BETA]

14 posts in this topic

pyBLM allows you to use up to four novation launchpads as a BLM for the MIDIbox Seq V4.  In this respect, pyBLM basically does exactly what the Juce Scalar Emulation app do, but it leaves out all the extra features and GUI elements.  It currently works well with 4 launchpads (16x16 BLM).  It should more or less work with 2 (8x16 BLM), although I get an error on a callback that I haven't figured out yet.

It doesn't seem to work with one launchpad yet - does the SEQ support a one launchpad 8x8 BLM?  If so, I may fix pyBLM to support that sometime, or if you want to do it, feel free.

It will never work with 3 launchpads.

NEW FEATURES (not in the Juce version):

Autodetects launchpads: when the script starts, you'll see a green line displayed on each of the launchpads detected by pyBLM.  The line will have a length (measured in LP buttons) equal to the number of launchpads detected by pyBLM.

Autoconfigures launchpad layout and rotation based on button presses: when you see the green line, press one of the square buttons on each of your launchpads to tell pyBLM which of the detected launchpads you want to use, and how they are laid out.  Start with the launchpad in the upper left corner of your layout, and move clockwise.  Each pad should show a scrolling number between 1 and 4, indicating the order in which you selected the launchpads.  Top left corner should be "1", top right should be "2".  If you have 4 LPs, bottom right will be "3" and bottom left will be "4".  The script automatically configures the launchpad rotation, a feature that I will particularly appreciate when trying to use the SEQ while drunk.

Autodetects the SEQ device ID and port (or you can set the port manually):  After the scrolling number appears in the step above, the configured LPs will light some of their round side buttons.  Press button 1 to 4 to select the SEQ USB port.  Or press the green buttons (button 7 or 8) to cause pyBLM to automatically determine the SEQ BLM USB port and connect to your SEQ.  Pressing a round button stops the layout configuration step above - you can choose not to use all of the detected launchpads if you wanted to for some reason. eg: if you have four LPs, you could press a round button after configuring only two of them and pyBLM would set up an 8x16 BLM.

Once you press a round button, a scrolling number will indicate the detected SEQ BLM USB port.  After that, the BLM is set up and should work exactly as it does when connected via the Juce app.

 

Dependencies:  Python3, Mido (http://mido.readthedocs.io/en/latest/installing.html), python-rtmidi
 

pip install mido

pip install python-rtmidi

mark the script executable, and run.

 

Tested only on Linux so far, although it should also work on inferior operating systems.  Let me know if you find bugs.

 

________________________________________________

License:  I'm giving this code to TK, it's his to distribute and license as he chooses.  Unless and until you hear something different from TK, assume personal, noncommercial use only.

________________________________________________

Code: https://github.com/borfo/pyBLM

Edited by borfo

Share this post


Link to post
Share on other sites

Wow excellent news, thanks for taking the time to do this and contribute it. I was contemplating whether to go the Launchpad route or not and this encourages me to go shopping soon :)

I was wondering if it would be possible to use the extra row of buttons to send some MIDI messages, and if so I would suggest something like Program Change messages, which could then be used to control the phrase/song, assuming the MBSeq is configured to respond to them in the Ext. Ctrl page. This is the one thing I find myself missing from using the Lemur BLM extensively. Just a suggestion.... 

Cheers!

Edited by monokinetic
suggested use of extra row

Share this post


Link to post
Share on other sites

Wow, thank you! Great work!

Does it work with all kind of Launchpads?

Is it correct that the code will run on a raspberry pi? Any raspberry pi?

It would be really nice if you could write a little beginner guidance, how to set up the raspberry pi, sometime in the future.

Share this post


Link to post
Share on other sites
20 hours ago, monokinetic said:

I was wondering if it would be possible to use the extra row of buttons to send some MIDI messages, and if so I would suggest something like ..

I was planning on setting up something like this - what you describe would be pretty easy to implement.  The client side of the BLM (eg: this app or the Juce app) is really just a dumb translator at heart - it just translates midi messages incoming from the SEQ into LP led-illumination messages, and MIDI-encodes button presses on the LPs in a way that the SEQ can understand.  All of the important processing is happening in the SEQ.

The BLM does make provision for up to 6 "extra buttons", but I'm not sure how these work.  It would be easier and probably better to just configure the extra row on the client-side to send arbitrary MIDI messages on the Ext. Ctrl channel, and not try to use the BLM protocol for these messages.  You could do this yourself pretty easily if you know any python.  Look at the callback for the Pad object, and the Pad[#].buttonmap object.

...I had also thought that I might want to use the extra row of buttons to add some "smart" functionality to the currently "dumb translator" BLM client - add extra modes that I personally would like to have but that TK may not find useful enough to add to the main SEQ program on the server side, or functionality that would be too cumbersome for the Midibox Core.

It would also be very easy to add support for other midi devices to pyBLM - eg: maybe you have a korg NanoKontrol or two that you would like to use to control your SEQ in some way - a user with some knowledge of python could add support for one or more other devices that they own by adding a translator class and callback to the script separate from the BLM protocol stuff.  I have a couple of controllers I may add to my own setup...  I have some midi implementation questions for TK before I start with that though. 

In theory, it would be pretty easy to write a python script that communicates with a bare stm32f4 or lpc17 core to allow full external MIDI controller operation of a SEQ V4 with a minimal frontpanel, or even without building a frontpanel at all.  But I don't think all the required parameters are available via midi right now.

Edited by borfo

Share this post


Link to post
Share on other sites
28 minutes ago, CJ55 said:

Does it work with all kind of Launchpads?

Not sure.  I have 4 launchpad minis - they show on my computer with the USB device name - eg "Launchpad Mini 2:Launchpad Mini 2 MIDI 1 32:0".  Right now, pyBLM autodetects any attached USB device with the word "launchpad" in its device name.  I am not sure what the device names for launchpad models other than the Mini would be.  If they don't have launchpad in their name the script would have to be adapted slightly.

Other than USB name issues, the script may not work on first generation launchpads - not sure.  I don't have one to test with.  Should work with the "s" versions as well as the more recent ones.  Hopefully users will let me know what launchpads work.  If only the Mini works right now, it should be trivial to fix the script so that at least non-1st-gen Lpads work.

Launchpad Pros **could** work, but I think it would require some tweaking to my script, or an altered firmware for the pro that would put it into the same "XY Mode" that I'm using for the launchpads in my script  I have a pro, but I have better uses for it, so don't plan on doing much extra work to support it in this script.  Someone else is welcome to do this if it's a desired feature.

Quote

Is it correct that the code will run on a raspberry pi? Any raspberry pi?

That's what I was planning to do in my setup.  I haven't tested on a pi yet, but the script should work on any properly configured Pi model.

FYI - I've compiled the Juce BLM scalar implementation for a first model Pi in the past - the compiled version binary, and instructions on compiling your own for Pi are posted in this forum somewhere.  A search for "raspberry pi" should find it.

Quote

It would be really nice if you could write a little beginner guidance, how to set up the raspberry pi, sometime in the future.

I would start it headless (ie: don't start X), and autorun this script on boot.  Python3 would have to be installed - I think it is by default these days - as would Mido (pip install mido) and python-rtmidi (pip install python-rtmidi).

Edited by borfo

Share this post


Link to post
Share on other sites

Great work. Any chance of a proper license? Saying "Licensed for personal, non-commercial use" isn't a license. Same goes with MIOS32. It's not clearly licensed.

Share this post


Link to post
Share on other sites
Just now, mongrol said:

Great work. Any chance of a proper license? Saying "Licensed for personal, non-commercial use" isn't a license. Same goes with MIOS32. It's not clearly licensed.

I realize that it's not a particularly detailed license - I'm actually an intellectual property lawyer.  But TK's general awesomeness more than makes up for any failings he may have in the intellectual property license drafting department.  Haha.  "Personal noncommercial" is a license though, it's just a bit vague.

Seriously though, I love TK's attitude to IP in the work he's done, think he's built an amazing system here, and think he should own all the midibox related code so that if he ever decides to move to a different licensing scheme, he won't have ownership issues.  So this code is his to do with as he likes.  Do you want to do anything with this code that "personal, noncommercial" wouldn't work for?  I probably wouldn't have issues with that, but I already assigned copyright to TK, so he's the one who'd have to grant any licenses.

Maybe he'd grant you a Death and Repudiation License if you asked nicely...  Haha.

Edited by borfo

Share this post


Link to post
Share on other sites
On 5/9/2017 at 6:21 PM, borfo said:

I was planning on setting up something like this - what you describe would be pretty easy to implement. 

Thanks for all the info on how to adapt pyBLM, that pretty much seals it for me!

 

Share this post


Link to post
Share on other sites
5 minutes ago, monokinetic said:

Thanks for all the info on how to adapt pyBLM, that pretty much seals it for me!

Have you been following that "Let's invent a new frontpanel thread?  I'm liking the fact that the rows will all have 16 buttons - makes a lot more sense...

20170510_235324.thumb.jpg.09dc6cc71f4cb4

 

And given how well the launchpad minis line up with the LCD columns, I'm tempted to make a tiny SEQ frontpanel that only has the encoder row, the datawheel, and maybe a handful of other convenience buttons.  If you could put MIDI assignments in the SEQHW_V4 file, instead of just shift register numbers, or if every parameter that could be controlled by a frontpanel button or encoder was coded to a MIDI CC/SYSEX/NRPN/etc. address (OSC would work too...) then the launchpads could be both the BLM and 16 rows of 16 SEQ buttons.  The launchpad buttons and LEDs are way nicer than tact switches, too.

It would be easy to tie all the parameters to MIDI, but if I'm remembering right, the reason they're not is because of low memory on the LPC17 Cores.  Once he makes the move to the STM32 V4+, this should be easy to do. 

Even if they're not all accessible by midi yet, there are quite a few MIDI controls.  Certainly enough to make SOME fun new BLM modes anyway, even if all the frontpanel functionality can't be duplicated yet.

 

Share this post


Link to post
Share on other sites

You said something awesome.

if every parameter that could be controlled by a frontpanel button or encoder was coded to a MIDI CC/SYSEX/NRPN/etc. address (OSC would work too...)

Massive possibilities open up if all functions were remotely controllable. Would love an OSC micropython wireless control surface doohicky.

Share this post


Link to post
Share on other sites

Actually, after looking through the source, it looks like most things are remotely controllable. However, they are on note data, not CC's. I always wondered why my SEQ done random things when I was playing my piano (A-90 controller). I was unwittingly sending control codes when I hit C-8.

Share this post


Link to post
Share on other sites

Yeah, I think many things are remote-controllable, but as far as I remember, the multifunction GP buttons aren't, and there's no easy LED feedback - you could script something, but it would be complex and would need a lot of sysex traffic.

It would be ideal to just add a new mode to the core BLM implementation that would cause the top couple of rows of the BLM to behave like the standard control surface, with LED feedback - this would require no modifications on the BLM client side...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now