Go Down

Topic: Simple MIDI Vol and Exp filter (Read 378 times) previous topic - next topic


Good evening! This is my first post  :)

I need a MIDI filter that simply filters volume and expression CC messages. I use a Hammond XK3c for organ, plus as a controller for a Yamaha Motif-Rack ES. It has two manuals, so in many cases I am playing organ on one and synth on the other. In such cases, I need to be able to change the organ's volume, but I don't want the synth to change volume (at least not the same as the organ). Thanks to posts here and other places on the Web, including the awesome SparkFunMIDI tutorial I came up with the working code below. I'm not a good programmer, so feel free to suggest better ways to do it. I'm happy with the functionality.

Code: [Select]

#include <MIDI.h>
* MIDI_FilterExp.ino
* David Summers
* 2018.01.03
* Reads MIDI IN, passes every message except
* CC mnessages for Expression (CC11) and Volume (CC04).
* Useful for controllers that send such data,
* but you wish for the controlled tone module to ignore it.
* I use this to control a Yamaha Motif-Rack ES from
* a Hammond XK3c; I want my expression pedal to
* effect the organ, but not anything on the Motif.
static const unsigned ledPinG = 6;      // LED pin on Arduino Uno
static const unsigned ledPinR = 7;      // LED pin on Arduino Uno

void setup()
  pinMode(ledPinG, OUTPUT);
  pinMode(ledPinR, OUTPUT);
  digitalWrite(ledPinG, LOW);
  digitalWrite(ledPinR, HIGH);

void loop()
  //digitalWrite(ledPinR, LOW);
  if (MIDI.read())
    switch(MIDI.getType()) // Get the type of the message we caught
      //Capture Control Change messages     
      case midi::ControlChange :
        //Capture Expression OR Volume CC messages
        if (MIDI.getData1() == 11 || MIDI.getData1() == 4)
          //Don't pass data
          digitalWrite(ledPinR, LOW);
        //All other CC messages
          MIDI.sendControlChange(MIDI.getData1(), MIDI.getData2(), MIDI.getChannel());
        digitalWrite(ledPinR, HIGH);
        //digitalWrite(ledPinR, LOW);
        //digitalWrite(ledPinR, HIGH);


I'm happy with the functionality.
The code looks fine, well done.

Go Up