Midi-IO sample
Using the midi-io sample bundle
The midi-io example bundle in samples/midi-io demonstrates the ability to send/receive data to/from a midi device.
Prerequisites
- Working NodeCG & nodecg-io installation
- A midi device that can be connected to your computer
Configure the midi-io sample bundle
-
Start nodecg with nodecg-io installed. The midi-io bundle is currently part of it so it should also be loaded.
-
Go to the
nodecg-iotab in the nodecg dashboard. -
Login using your password. If this is your first run, then enter the password with which you want to encrypt your configurations and credentials.
-
Create a new midi-input service instance using the left upper menu.
-
Enter your device information
The created instance should be automatically selected, if not select it in the upper left menu. Enter the name of your device in monaco (the text-editor on the right) in this format:
{ "device": "name" }After entering it, click save. Note: A script is provided to list all inputs and outputs. It can be run from the sample directory
samples/midi-iousing the commandnpm run list. The devices should be listed with their device names and some other stuff. under linux this looks for example like this:nanoKONTROL2:nanoKONTROL2 MIDI 1 28:0Note: If you don't see monaco on the right, try reloading the page.
-
Create a new midi-output service instance using the left upper menu.
-
Repeat step 5 for your midi-output service. In most cases you want to use the same device for input and output.
-
Set the created midi-output service instance to the service dependency of the midi-io sample bundle.
Select the midi-io bundle and the midi-output service in the left bottom menu and then select the service instance that should be used by the midi-io bundle (in this case the name of the previously created midi-output instance).
-
Set the created midi-input service instance to the service dependency of the midi-io sample bundle.
Select the midi-io bundle and the midi-input service in the left bottom menu and then select the service instance that should be used by the midi-io bundle (in this case the name of the previously created midi-input instance).
-
Check the nodecg logs
You should see an error or a success message and midi messages that are received and echoed back to the device that is configured. The messages are only modified, if the received Message is a noteon with a velocity of greater than zero or a control change message with a value of at least 64. Noteoff messages are always echoed unmodified.
Note
A noteon message with a velocity of 0 should be handled like a noteoff message, so they are echoed unmodified. Otherwise, this would get annoying very fast.
If a control change is assigned to a push-butten values of 64 and up are interpreted as on and values lower than that are interpreted as off. Most somewhat modern Midi devices send 127 as on and 0 as off, but 63 and 64 should also be sufficient.