Midi2gate note numbers and digital output (Arduino nano)

Hi All,

I’m struggling on getting instruments from my drumcomputer onto the required digital output pins/gates.

Using the following software from:

My drumcomputer Behringer RD-6 uses the following midi notes:

// BEHRINGER RD-6 (8 instruments):
// - BD midi note36
// - SD midi note40
// - LT midi note45
// - HT midi note50
// - CP midi note39
// - CY midi note51
// - OH midi note46
// - CH midi note42

The bass drum works correct. It uses note #36, and the output/gate is correct on D2.
Solar so good!

From the code, it looks like a sort of map is created for the other instruments:
constexpr byte GATE01 = 2;
constexpr byte GATE02 = 3;
constexpr byte GATE03 = 4;
constexpr byte GATE04 = 5;
constexpr byte GATE05 = 6;
constexpr byte GATE06 = 7;
constexpr byte GATE07 = 13;
constexpr byte GATE08 = 12;
constexpr byte GATE09 = 11;
constexpr byte GATE10 = 10;
constexpr byte GATE11 = 9;
constexpr byte GATE12 = 8;

Adapting this table does not work (I calculated the difference from #36 and higher):

constexpr byte GATE01 = 2;
constexpr byte GATE05 = 3;
constexpr byte GATE10 = 4;
constexpr byte GATE15 = 5;
constexpr byte GATE04 = 6;
constexpr byte GATE16 = 7;
constexpr byte GATE11 = 8;
constexpr byte GATE07 = 9;

Am I completely looking in the wrong direction in getting my instruments on the required outputs?

Many thanks!

Ron

It will never work, you are just triggering the bass drum every time, you need to get the note value and maybe put it in a simple case statement in your note on and note off. Also handle note on with velocity 0 which are note off.

switch(note) {
case 36:
Do something;
Break;

Case 37:
Do something;
Break;

Etc

}

Hi Craig,

That’s seems to do the trick indeed.
I wanted to keep away from setting every note statically, I have for now came up with this for (only showing the ‘note on’ part:

void handleNoteOn(byte channel, byte note, byte velocity)
{
switch (channel) {
case MIDI_CHANNEL:
// switch (velocity) {
// case 1 … 127:
switch (note) {
case 36:
digitalWrite(GATE01, HIGH);
break;
case 40:
digitalWrite(GATE02, HIGH);
break;
case 45:
digitalWrite(GATE03, HIGH);
break;
case 50:
digitalWrite(GATE04, HIGH);
break;
case 39:
digitalWrite(GATE05, HIGH);
break;
case 51:
digitalWrite(GATE06, HIGH);
break;
case 46:
digitalWrite(GATE07, HIGH);
break;
case 42:
digitalWrite(GATE08, HIGH);
break;
}

I need to work on the logic for your suggestion about the velocity being set to zero, in combination with note-on.

For now the 8 instruments provide a gate own each of the required pins!

I will post my alternative sketch later on GIT when completely done/satisfied…

1 Like

Glad you got it working. I would start a timer for each gate you set high and then set the gate low after 20ms or so, or use the note off. You can put the counter in the loop to check for the count and then turn that gate low. In your note on, check for velocity 0, if it’s 0 do nothing.

Hi Craig,

One simple solution for the ‘notes-on wih velocity zero’ scenario is handled by the library already:

including the following should do the trick:

struct MySettings : public midi::DefaultSettings
{
    static const bool HandleNullVelocityNoteOnAsNoteOff = true;
};

I indeed have to think of a good method of adjusting the timer for the gate length, as I also want to make this dependent of the ‘accent’ on the drumcomputer. On midi level this is differentiated simply by increased velocity (velocity eiher 82 vs 127).