RowdyVoyeur / midi-tools

A set of MIDI tools to use with M8C running on a Raspberry Pi.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MIDI Tools for M8C

Introduction

This is a set of MIDI tools to use with M8C running on a Raspberry Pi with Patchbox OS. These tools have been customised to programmatically perform the following tasks:

  • Capture specific MIDI Control Change (CC) messages sent by the transport buttons of the Korg nanoKONTROL and convert them into MIDI Notes to control the M8;

  • Capture specific MIDI Note messages sent by the Korg nanoKONTROL and convert them into commands to change the audio routing between USB Card Microphone, M8, MC-101 and System Audio Out;

  • Capture specific MIDI Control Change (CC) messages sent by the Korg nanoKONTROL and use them to control the main output and main input volume levels of Alsamixer.

While the second and third tasks can be useful for any setup, the first task is only useful if you have the original version of Korg nanoKONTROL. As far as I know, the following versions of this device can send MIDI Note messages from the transport buttons. Therefore, it is not necessary to convert MIDI CC to MIDI Notes.

CC To Note

The CC To Note tool uses python-rtmidi to capture MIDI Control Change (CC) messages sent on a specific MIDI Channel and convert them to MIDI Notes, which will then be pushed to another MIDI Channel.

This tool is basically a customised version of sherbocopter's script midi-cc-to-note, whith some minor changes to fit my needs. Therefore, I would like to thank sherbocopter for the phenomenal work.

MIDI To Command

The MIDI To Command tool also uses python-rtmidi to capture MIDI Note messages sent on a specific MIDI Channel and convert them into actions or commands that can perform whatever you wish.

The original version of this tool can be found in the examples of the python-rtmidi. I simply configured it and created the scripts to perform the required commands. Thank you very much SpotlightKid for the amazing repository.

Control Amixer

The Control Amixer tool uses aseqdumpto capture MIDI Control Change (CC) messages and use the data to adjust two amixer simple mixer controls, namely Speakerand Mic, which are responsible for controlling the main output and main input volume levels of Alsamixer.

This tool assumes you are using this audio configuration, but it can be easily modified for other setups.

Installation

  1. To install these tools simply clone using:
cd
git clone https://github.com/RowdyVoyeur/midi-tools.git
  1. The MIDI To Command uses custom shell scripts. Therefore, you need to get into the midi-to-command directory and make all scripts executable by everyone:
cd
cd midi-tools/midi-to-command
sudo chmod a+x *.sh
  1. It shouldn't be necessary to install rtmidi because it's already part of Blokas Patchbox OS. However, you will need to install pyyaml. Start by installing pip:
sudo apt install python3-pip
  1. And then, install pyyaml:
sudo pip3 install pyyaml
  1. The Control Amixer also uses a custom bash script. Therefore, you need to get into the control-amixer directory and make the script executable by everyone:
cd
cd midi-tools/control-amixer
sudo chmod a+x *.sh
  1. Once the steps above are done, you should test the scripts before automatically start them on boot. Connect the MIDI device(s), reboot and run the following to test midi-to-command:
cd
sudo python midi-tools/midi-to-command/midi2command.py midi-tools/midi-to-command/config.cfg -p nanoKONTROL
  1. Run the following to test cc-to-note:
cd
sudo python midi-tools/cc-to-note/main.py --config midi-tools/cc-to-note/config.json
  1. And run the following to test control-amixer:
cd
cd midi-tools/control-amixer
./control-amixer.sh
  1. If you did not find any errors, you can configure how you would like these tools to automatically start on boot. You can use several methods such as systemd or crontab to automatically start these tools on boot. However, if you are using the M8C Module for Patchbox OS you can simply customise the m8c.sh script and uncomment the relevant lines.

  2. You need to configure the MIDI Control Channels on each device to receive data and prevent conflicts. If you're using the exact same exact setup comprised of M8, USB Card, MC-101 and Korg nanoKONTROL, then you need to make sure the M8's Control Map Chan is set to 16, the MC-101's Control Channel is set to anything different than 8, 15 or 16 (to prevent MIDI conflicts), and Korg nanoKONTROL is using this set file. If you are using a different setup, then just remember the following default configurations: CC To Note and Korg nanoKONTROL's scenes 1 and 2 are sending MIDI data to the M8 on channel 16; MIDI To Command and Korg nanoKONTROL's scene 4 are sending MIDI data to the M8 on channel 15; Korg nanoKONTROL's scene 3 is sending MIDI data to the M8 on channel 8 (you can find more information about this in the tables below).

  3. Specific information about the configuration of each tool can be found here for CC To Note, here for MIDI To Command and here for Control Amixer.

nanoKONTROL

This section shows the layout of the various nanoKONTROL scenes. This assumes you are using the nanoKONTROL set file found here.

Gamepad Controller

Scene 1 allows to control the M8 with the following buttons of the nanoKONTROL:

Button Command CC Pitch Note Channel
[P] Play - 0 C-1 16
[S] Shift - 1 C#-1 16
[E] Edit - 2 D-1 16
[O] Option - 3 D#-1 16
[←] Left 102 4 E-1 16
[→] Right 103 5 F-1 16
[↑] Up 104 6 F#-1 16
[↓] Down 105 7 G-1 16

Mixer, Mute and Solo

Scene 2 allows to individually Mute and/or Solo Tracks 1 to 8 of the M8 with the following buttons of the nanoKONTROL:

Button Command Pitch Note Channel
[M] Mute Tracks 1 to 8 12 to 19 C0 to G0 16
[S] Solo Tracks 1 to 8 20 to 27 G#0 to D#1 16

Chromatic Keyboard

Scene 3 is a chromatic keyboard that sends MIDI Notes from the following buttons of the nanoKONTROL:

Button Note Channel
[A] to [R] C-1 to F0 8

Audio Routing

Scene 4 allows to select different audio routings and to adjust Alsamixer levels of the System Audio In and Out:

Button/Knob Routing/Command CC Pitch Note Channel
[A] MC101->M8->OUT - 127 G9 15
[B] IN->MC101->M8->OUT - 126 F#9 15
[C] M8->MC101->OUT - 125 F9 15
[D] IN->M8->MC101->OUT - 124 E9 15
[E] M8->MC101 / IN->MC101 - 123 D#9 15
[F] M8->MC101(L) / IN->MC101(R) - 122 D9 15
[G] MC101->OUT / M8->OUT - 121 C#9 15
[H] IN->OUT / MC101->OUT / M8->OUT - 120 C9 15
[I] IN->MC101->OUT / IN->M8->OUT - 119 B8 15
[J] M8->MC101 - 118 A#8 15
[1] Adjust Output Level 118 - - 15
[2] Adjust Input Level 119 - - 15

References

Download nanoKONTROL editor

Convert MIDI Notes to Pitch Values

Control almost anything using a MIDI controller

About

A set of MIDI tools to use with M8C running on a Raspberry Pi.


Languages

Language:Shell 54.4%Language:Python 45.6%