Jump to content

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


borfo
 Share

Recommended Posts

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
Link to comment
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
Link to comment
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.

Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
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.

 

Link to comment
Share on other sites

  • 3 weeks later...

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.

Link to comment
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.

Link to comment
Share on other sites

  • 3 weeks later...

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...

Link to comment
Share on other sites

  • 2 years later...

So, finaly took the time and a PI3 I had laying around and installed the software.... The problem is that pyBLM can't find the Seq4:

pi@pyblm:~ $ ./pyblm/pyBLM.py
pyBLM launched.
pyBLM init
ERROR: Couldn't find the seq

When checking for available midi-ports I get:

pi@pyblm:~ $ amidi -l
Dir Device    Name
IO  hw:0,0,0  Launchpad Mini MIDI 1
IO  hw:1,0,0  MIDIbox SEQ V4+ MIDI 1
IO  hw:1,0,1  MIDIbox SEQ V4+ MIDI 2
IO  hw:1,0,2  MIDIbox SEQ V4+ MIDI 3
IO  hw:1,0,3  MIDIbox SEQ V4+ MIDI 4
IO  hw:2,0,0  Launchpad Mini MIDI 1

Output of mido.get_input_names() gives:

MIDIbox SEQ V4+:MIDIbox SEQ V4+ MIDI 1 20:0
MIDIbox SEQ V4+:MIDIbox SEQ V4+ MIDI 2 20:1
MIDIbox SEQ V4+:MIDIbox SEQ V4+ MIDI 3 20:2
MIDIbox SEQ V4+:MIDIbox SEQ V4+ MIDI 4 20:3

Looks like the naming of the Seq4 ports has changed (I use firmware version 4.096). I tried to alter the seqregex function, but no luck :pout: .Since I don't understand a *** of regex and re.compile is used for finding the Seq4 I am a bit stuck. When I revert to an older version of the Seq4 firmware pyBLM starts to work. Can you give me a clue how to stay on the latest firmware and get the pyBLM to work as should? Thanks in advance :wink:

Cheers, Kees

Link to comment
Share on other sites

Darn, I was hoping to do the same. Shame to hear it's not working with the updated firmware. I don't have any Launchpads, yet. But as a matter of interest I had a quick look at the code.

At a guess, this line here:

seqregex = re.compile("MIDIbox SEQ V4:MIDIbox SEQ V4 MIDI ([1-4]) [0-9]")

Needs to be updated for the new v4+ firmware. Have you tried editing it to:

seqregex = re.compile("MIDIbox SEQ V4+:MIDIbox SEQ V4+ MIDI ([1-4]) [0-9]")

i.e. just add the + symbol two times to match the updated name you posted in the output of mido.get_input_names().

Not sure how you tried to modify the regex, but that would be my first thing to try!

Oh and you might find that the + character confuses the regex, so if that doesn't work, try using a \ before each + which you add. So it looks like this:

seqregex = re.compile("MIDIbox SEQ V4\+:MIDIbox SEQ V4\+ MIDI ([1-4]) [0-9]")

Hope you get it up and running....

Edited by monokinetic
one more detail
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...