This repo focuses on the approach, not the driver so much. Because every MIDI Controller is different and every person has different workflow you should implement your own driver that works for you.
https://www.youtube.com/watch?v=5M-RpgTE8zw
- In REAPER navigate to
Options->Preferences->Control/OSC/web
- Click
Add
- Choose
Web browser interface
- Click
User pages...
(orBuilt-in pages
, doesn't matter) - A window will popup. Clone the repo or download a zip and extract it there
- Choose the driver from the list that says
Default interfaces
- Copy-paste the Access URL in a browser
Make sure that your controller is configured to send control messages and also its output mode is enabled. Note that this is not specific to this implementation, that's always required.
REAPER has that feature that you can control it remotely from any device in the local network. Please check this video out.
Internally REAPER runs a web server that listens for HTTP requests from a web app that you run in the browser. In the video above you can see that Kenny runs a GUI app and controls REAPER in realtime. He also receives feedback from the DAW like time, metronome, track mute/solo/arm/pan/vol params etc. I thought that I can exploit this by only removing the GUI and reading the incoming MIDI messages. And it worked.
In principle, the app intercepts incomming MIDI messages, interprets them based on some logic and send commands to REAPER in form of HTTP requests, where the URL contains the command(s). REAPER can respond and return messages to the app too. This is useful if you want to implement a feedback (e.g. you have some buttons that you want to light up and keep in sync with the DAW).
Note: Just to make it clear, you don't actually need internet access to use this driver, it's an app on localhost.
MIDI CC Layout
Most of the explanations of the APIs are in the main.js
file inside Built-in pages...
. Also, there are a lot of comments in the driver's code, please check them out.
Since this is a normal web app it can be debugged directly in the browser, it will hit breakpoints and console log messages accordingly. If you use Visual Studio Code and Chrome you can benefit from this extension. Install the extension, put a breakpoint and hit F5.
NOTE: Make sure that you are not running multiple instances of the web app! If you do, then REAPER will receive multiple messages and will not work as you wish.
- Portable. It's just html and javascript, so it runs on every machine that has browser
- Supports two-way communication between REAPER and the Controller. Useful for feedback scenarios and keeping in sync with the DAW
- Debuggable. It's a web app and you can actually debug it in contrast to EEL and Lua solutions
- No prerequisites. You don't need to install anything on your machine (no extensions, plugins, third-party software etc.)
-
In the ideal case, setting up a DAW controller driver should be 1 step process e.g. paste it somewhere. This solution is a 2 step process. One - paste the driver. Two - run web app in browser
-
Since this is a web app you have no way to guarantee that it runs or it doesn't run multiple times in multiple tabs/browsers. This can bring confusion if you are not careful.
Overall the benefits are greater than the drawbacks, but this is the further we can get until REAPER team doesn't invent something else.
To make things more convenient you can create a custom action that starts the web app on http://localhost:8080
with a click of a button.
- Go to
Actions
menu and clickShow action list...
- Click
New...
ReaScript action - A window will popup
- Create a file (e.g.
run_midi_driver.lua
) and paste the following code
-- Change the port if you need
url = "http://localhost:8080"
function open_url(url)
local OS = reaper.GetOS()
if OS == "OSX32" or OS == "OSX64" then
os.execute('open "" "' .. url .. '"')
else
os.execute('start "" "' .. url .. '"')
end
end
open_url(url)
- Now you can add a custom button in your toolbar that will execute the script
REAPER allows you to run scripts on startup. This is done by creating a new file in (Windows) %appdata%\reaper\Scripts
called __startup.lua
. Then paste the script from above in this file and you are good to go.
NOTE 1: Closing REAPER doesn't close the browser tabs that this script opens
NOTE 2: It's best practice to actually create a separate file for the script and then import (require) it from __startup.lua
. This makes things cleaner if you have more startup scripts
Please open an issue if you like to discuss something or create a PR. You are very welcome to do so.