ModScript: Using scripts for a better and richer integration with MIDI controllers (beta soon!)

I think that it might be an evolutionary step in the right direction.

This is awesome. Another vote for OSC.

Awesome. Perfect timing. I own quite a few rather old MIDI controllers and like you said, experience a hard time integrating more advanced control functionalities beyond one to one mappings. Often I end up with a bunch of cross wired logic modules, Schmitt triggers, flip flops and what-nots that become really tedious to debug or modify. So I’m really looking forward to experiment with ModScript.

AirMin32 has a button that toggles between 4 modes, in first mode all controls send messages to MIDI, in other 3 modes messages going to HyperControl. I think needed ability to get messages from multiple devices within script.

Screenshot 2022-09-06 at 10.10.01

I am absolutely humbled by the replies here! Thanks to everyone for the support, all these messages really mean something to me! I have delayed presenting this module for too long but I’m at a point in the process where I need to get feedback to keep going in a useful direction, again big thanks everyone!

OSC: (cc @trevormeier @Jens.Peter.Nielsen @auxmux) It’s absolutely a thing I have considered already – it might actually already be possible to load an OSC pack/unpack lib in the scripts and use a socket to send and receive messages, I’ll try that and report! The actual plan is to add this feature in the module’s code directly as it would be much better (and faster!).
About OSC in general: I have been convinced for a long time that Rack would greatly benefit from a complete OSC interface, report about the current patch and to be able to reach any parameter just like with the scripts!

NI hardware: (cc @trevormeier ) Thanks for bringing this up! I love the hardware from NI in general but sadly all the advanced features are of no use in VCV Rack because they are not implemented using MIDI but through another mean called HID, simply put their controllers are like complex joysticks or keyboards with lots of buttons, leds and even screens. I have myself started working on that, thanks to existing open source work. A version of ModScript designed for NI/HID interaction instead of MIDI will happen some way or another!

I will consider working on this once the module has reached a beta state. I was busy the past 2 days banging my head against a wall trying to fix a damn bug causing a nasty crash!

And I too have a question for you: what operating systems are you on? I have developed exclusively on Linux so far and I’m working on ensuring Windows compatibility.

1 Like

I have both an APC40 and APC Mini, and neither is of much use except in Ableton Live, and even in Live, I can’t use both controllers at once. I’ve also found that they’re both pretty useless in VCVRack because of the way the MIDI works.

You can’t - for example - map the channel faders on an APC40 to the channel faders on a Mindmeld Mixmaster. Each of the channels uses the same CC/Note values in different MIDI channels.

EDIT: The APC40 is even screwier than that. The 8 channel faders are the standard VOLUME CC on channels 1-8 but the master volume is Controller 14 on channel 1.

I’ve just spent a little while looking at HyperControl, sadly as opposed to some other “smart” MIDI protocols it hasn’t been documented much nor was it reverse engineered. The Python scripts from Ableton Live do tell us how to engage it using SysEX though! My guess is that it’s like most other similar proprietary protocols, it’s just some undocumented SysEX to/from the host software. Given the Air Mini32 doesn’t have infinite/relative-mode knobs I don’t think there’s much to get from it except what the normal MIDI mode will allow.

Multiple MIDI devices is still relevant though, thanks for the suggestion!

Edit:

I would have picked Python if it was easier but there are currently known bugs notably with multiple interpreters running in parallel. More details here, I worked on embedding pypy (a faster Python interpreter) and got good results but sadly all of that was lost when my computer was stolen last year.

In the end, I don’t regret going for Lua mostly because it is really fast and efficient. I wanted to guarantee the best performance even with the most complex scripts, ie. ModScript isn’t made for prototyping, I want it to be trusted by musicians performing live using several controllers.
The engine used is called LuaJIT and although I do not understand the details, it is generally regarded as one of the fastest and often considered the fastest scripting engine.

1 Like

I’m on macOS 12.5 on an M1 Max here.

HID support would be incredible. That would be a massive leap forward in usability for VCV rack. In the meantime, I’m often using my Maschine mk3 and Maschine Jam in MIDI mode alongside a LaunchControl XL and TouchOSC. It’s not as powerful or flexible, but it’s still great to have the hands-on control.

Very happy to see this come to light!

Quick question: does the Maschine Jam allow any leds or the value of the 8 touchstrips-fader to be set using MIDI messages from the computer in MIDI Mode? If it’s possible to control the feedback on the controller, then it’s worth experimenting! The LaunchControl XL could be very capable too!

It makes me happy to see development in this direction. About 15 years ago I was a developer for a commercial 3D modelling and animation tool company. I “embedded” and “extended” Python into the runtime and the API. The results were amaizing, IMHO :wink: But, it was an absolutely challenging endeavor, and would not have been possible without being a company developer.

I’m looking forward to seeing how you progress and wish you the best.

2 Likes

Thank you very much, your support is very encouraging! It must have been a very different time for Python, for programming and even more so for embedding an interpreter for a dynamic language! This reminds me 15 years ago was about the same time that I started programming, and my first language was… Python! It was like, version 2.5 or 2.4 even?

re: OSC
I’ve just made some tests and although it will be rather easy to do directly in the scripts, there is a bug with the network library used. This issue is related to a broader milestone that I wish to work on soon™ so I will postpone OSC support until then, sorry about that! I opened an issue to keep track of it: luasocket broken · Issue #3 · Simon-L/ModScript · GitHub

In the meantime, I tracked down the bug that prevented multiple Lune/Pleine Lune modules to be instantiated. 2 scripts driving 2 controllers means more lovely modules from our favorite developers in the same shot :heart: :

2 Likes

I just now looked at my source code from 2008 and I was using Python 2.5 at the time. Probably the most useful thing I did at that time was to expose the entire SDK and API so that external “dot notation” object oriented languages could do just about anything that the application runtime could do… This enabled me to do applications and web browser plugins via Python, Javascript, etc. It was as powerful but not necessarily so useful for the main 3D application to be able to load, interpret and run Python files, which themselves might call back into the application DLL that I created.

By the way, I used UDP for inter-application and inter-user communications. I did a worldwide metaverse system for shared realities. All of this was realtime 3D, so quite the challenge. Along the way I did some MIDI communications such that I could control real-time 3D modelling and animation via a hardware MIDI controller, the Evolution U-Control UC-33 .

Within the last 4 years, I did a VR/AR app where I could talk to hardware via MIDI or OSC.

I believe in you but I respect the magnitude of the challenge.

Actually, looking at source code, my 2019 VR/AR effort utilized OSC over UDP.

1 Like

Good evening! I’m happy to announce some progress: I’ve fixed a few minor issues and ModScript is now compatible with Windows! Thanks to @Steve_Russell for reporting the issue

While doing so I went ahead and prepared plugin packages for Linux and Windows, I’m offering these in an almost beta stage for curious users and developers to test it! The following explains why I’m cautious about that.

:warning: Please read: By offering to run scripts from unknown and/or unverified sources, this plugin has a few security implications, much like VCV-Prototype had too. I give you my word that I will do my best to protect against that and that I won’t attempt to run cryptocurrency stuff remotely on your computer or anything harmful. The best security is still your understanding and alterness about this!

Download links, the file are hosted on my website (links and files updated to latest post) :

The source code of these builds is up-to-date, find it here.

Because it is such an early release, I don’t recommend at all to start serious work using ModScript although most of the API shouldn’t change too much. I also do not recommend trying to run complex Lua scripts including existing libraries etc., as I have found out myself that this is a bug/limitation in the build system currently. That being said, I would be very happy to know that is does work for the basic stuff demonstrated below! And if it doesn’t… well, sorry!

Instructions

Once you have installed the plugin, click File > New to get the default Rack patch, add Pleine Lune, select keyboard.lua in the right-click menu, select the Keyboard input as MIDI driver, check the script and see what happens! That script has a lot of comments to help writing your own, don’t hesitate to ask here and suggest additional help! Thanks.

During the development of scripts I find myself heavily relying on the display() function to print info and debug things. On Linux you can view it by running: tail -f ~/.Rack2/log.txt. The equivalent for Windows is to run this in Powershell: Get-Content log.txt -Wait (you have to cd to Documents/Rack2 first, this is where this log file is located)

Future

Things that are expected to change:

  • Module size and layout, 4 in/out isn’t enough, I’d like to make it a little wider and maybe a little screen. Also leds for midi device and script status.
  • Script files locations: for now they are in the plugins folder (Documents/Rack2/plugins/ModScript/scripts on Windows), I would like to have them directly in the Rack2 folder in a ModScript folder.
1 Like

Too bad your build is not glibc 2.31 compatible (Debian Stable).

The Maschine hardware (mk3 and Jam) will send and receive on the same MIDI channel & CC/note for each button or fader assignment. So you can have bidirectional communication of state for the faders and buttons, yes.

Thanks for the report!

I’ve worked on the build system so that it’s fully compatible with the official toolchain, it was a little harder than for usual plugins because of the dependency on Lua but it’s all good now!
ModScript now uses a more recent version of Lua though it doesn’t bring anything noticeable so far, I hope I can benefit from that improved and better maintained version for upcoming features!

For the sake of better compatibility, here are new builds that should be more compatible:

I have researched possible solutions for quickly bringing OSC support, some work is still needed but it should happen within the next week or so!

2 Likes

I wonder if that Is why VCV-Prototype has not been ported to V2? Sorry - I know this is off topic. Is there a topic that discusses Prototype vulnerabilities?

Well the modules load!

Now to have any clue how to use them :wink:

How’s it going on ModScript? Anybody out there able to make a macOS build for me to test?