Hairless MIDI serial error occupying

I’m building a arduino drum including the pad with a piezo and 16 channel drum kit. I modified the code from RyoKosaka’s drum code and it’s done uploading to Arduino UNO without error. Also downloaded the MIDI library from FortySevenEffects’s website.

I use “loopmidi” and “hairless MIDI” to connect the PC and drum kit. But it got a error when open the hairless MIDI. It’s appear “+0.004 -warning: got a status byte when we were expecting 1 more data bytes, sending possibly incomplete MIDI message 0x99” and other warning. Click the debug message I found out it’s keep showing many kinds of serial ports but I didn’t hit any pad. Also open the map window of “Addictive Drums” software it’s keep pressing different notes.

Should I modify the code of MIDI library or drum code?



And where is the code you are using?

Make sure you are setting the baud rate of the serial print, to the same rate as your hairless code is expecting to use.

Why are all the errors shown as pictures with all the interesting stuff on the right hand side cut off?

Can't maximum the window of hairless midi...so I slide right and left to view.
I renew the picture.

Both baud rate of serial port of code and hairless were setting "384000".

My drum code:

/*
  Make 16 single piezo pads with a multiplexer 74HC4067. 
  Refer: https://github.com/RyoKosaka/HelloDrum-arduino-Library
*/


//Determine the setting value.
//By changing the number in this array set sensitivity, threshold and so on.

//drum software: 0-ADD2, 1-EZD2
#define Drum_map 0 

// ADD2 MAP 
//cymbal1-0, cymbal2-1, ride-2, ride_edge-3, ride_bell-4, crash-5, crash_edge-6, crash_bell-7, hihat pedal-8, hihatopen-9, hihatclose-10
//floorTom-11, tom4-12, tom3-13, tom2-14, tom1-15, snare rimshot-16, snare head-17, snare cross stick-18, kick-19
byte Note[2][20] = {{79, 81, 60, 63, 61, 77, 78, 85, 48, 54, 49, 65, 47, 67, 69, 71, 37, 38, 40, 36}};


//sensitivity, threshold, scan time, mask time, note map
uint8_t CYM1[5] = {100,10,10, 30, Note[Drum_map][0]};    
uint8_t CYM2[5] = {100, 10, 10, 30, Note[Drum_map][1]};
uint8_t RIDE[9] = {100, 10, 10, 30, 4, 9, Note[Drum_map][2], Note[Drum_map][3], Note[Drum_map][4]};
uint8_t CRASH[9] = {100, 10, 10, 30, Note[Drum_map][5], Note[Drum_map][6], Note[Drum_map][7]  };
uint8_t HIHAT_PEDAL[6] = {90, 30, 70, 90, 10, Note[Drum_map][8]};
uint8_t HIHAT[6] = {100, 10, 10, 30, Note[Drum_map][9], Note[Drum_map][10]};
uint8_t FTOM[5] = {100, 55, 25, 30, Note[Drum_map][11]};
uint8_t TOM4[5] = {100, 55, 25, 30, Note[Drum_map][12]};
uint8_t TOM3[5] = {100, 55, 25, 30, Note[Drum_map][13]};
uint8_t TOM2[5] = {100, 55, 25, 30, Note[Drum_map][14]};
uint8_t TOM1[5] = {100, 55, 25, 30, Note[Drum_map][15]};
uint8_t SNARE[9] = {100, 10, 30, 10, 10,3, Note[Drum_map][16], Note[Drum_map][17], Note[Drum_map][18]};
uint8_t KICK[5] = {100, 10, 10, 30, Note[Drum_map][19]};


/////////////////////////////////////////////////////////////////////////////////////

#include <hellodrum.h>
#include <MIDI.h>
MIDI_CREATE_DEFAULT_INSTANCE();

//Define MUX pin (D2, D3, D4, D5, A0)
HelloDrumMUX_4067 mux(2, 3, 4, 5, 0); 

//name pad and define MUX pin
HelloDrum cym01(0);
HelloDrum cym02(1);
HelloDrum ride(2, 3);
HelloDrum crash(4, 5);
HelloDrum hihatPedal(6);
HelloDrum hihat(7);
HelloDrum ftom(8);
HelloDrum tom04(9);
HelloDrum tom03(10);
HelloDrum tom02(11);
HelloDrum tom01(12);
HelloDrum snare(13, 14);
HelloDrum kick(15);



void setup()
{
  //MIDI.begin();
  Serial.begin(115200);
}

void loop()
{
  mux.scan();
  cym01.singlePiezoMUX(CYM1[0], CYM1[1], CYM1[2], CYM1[3]);
  cym02.singlePiezoMUX(CYM2[0], CYM2[1], CYM2[2], CYM2[3]);
  ride.cymbal3zoneMUX(RIDE[0], RIDE[1], RIDE[2], RIDE[3], RIDE[4], RIDE[5]); 
  //cymbal3zone(byte sens, byte thre, byte scan, byte mask, byte edgeThre, byte cupThre);
  crash.cymbal3zoneMUX(CRASH[0], CRASH[1], CRASH[2], CRASH[3], CRASH[4], CRASH[5]); 
  //cymbal3zone(byte sens, byte thre, byte scan, byte mask, byte edgeThre, byte cupThre);
  hihatPedal.hihatControlMUX(HIHAT_PEDAL[0], HIHAT_PEDAL[1], HIHAT_PEDAL[2], HIHAT_PEDAL[3], HIHAT_PEDAL[4]);
  //TCRT5000, hihatPedal(byte sens, byte thre, byte scanStart, byte scanEnd, byte pedalSens)
  hihat.HHMUX(HIHAT[0], HIHAT[1], HIHAT[2], HIHAT[3]);
  ftom.singlePiezoMUX(FTOM[0], FTOM[1], FTOM[2], FTOM[3]);
  tom04.singlePiezoMUX(TOM4[0], TOM4[1], TOM4[2], TOM4[3]);
  tom03.singlePiezoMUX(TOM3[0], TOM3[1], TOM3[2], TOM3[3]);
  tom02.singlePiezoMUX(TOM2[0], TOM2[1], TOM2[2], TOM2[3]);
  tom01.singlePiezoMUX(TOM1[0], TOM1[1], TOM1[2], TOM1[3]);
  kick.singlePiezoMUX(KICK[0], KICK[1], KICK[2], KICK[3]);
  snare.dualPiezoMUX(SNARE[0], SNARE[1], SNARE[2], SNARE[3], SNARE[4], SNARE[5]); 
  //dualPiezo(byte sens, byte thre, byte scan, byte mask, byte rimSens, byte rimThre);

  if (cym01.hit == true)
  {
    MIDI.sendNoteOn(CYM1[4], cym01.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(CYM1[4], 0, 10);
  }

  if (cym02.hit == true)
  {
    MIDI.sendNoteOn(CYM2[4], cym02.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(CYM2[4], 0, 10);
  }

  //ride bow
  if (ride.hit == true)
  {
    MIDI.sendNoteOn(RIDE[7], ride.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(RIDE[7], 0, 10);
  }

  //ride edge
  else if (ride.hitRim == true)
  {
    MIDI.sendNoteOn(RIDE[8], ride.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(RIDE[8], 0, 10);
  }

  //ride cup
  else if (ride.hitCup == true)
  {
    MIDI.sendNoteOn(RIDE[9], ride.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(RIDE[9], 0, 10);
  }

  //ride choke
  if (ride.choke == true)
  {
    MIDI.sendPolyPressure(RIDE[7], 127, 10);
    MIDI.sendPolyPressure(RIDE[8], 127, 10);
    MIDI.sendPolyPressure(RIDE[9], 127, 10);
    MIDI.sendPolyPressure(RIDE[7], 0, 10);
    MIDI.sendPolyPressure(RIDE[8], 0, 10);
    MIDI.sendPolyPressure(RIDE[9], 0, 10);
  }
  
  //crash bow
  if (crash.hit == true)
  {
    MIDI.sendNoteOn(CRASH[7], crash.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(CRASH[7], 0, 10);
  }

  //crash edge
  else if (crash.hitRim == true)
  {
    MIDI.sendNoteOn(CRASH[8], crash.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(CRASH[8], 0, 10);
  }

  //crash cup
  else if (crash.hitCup == true)
  {
    MIDI.sendNoteOn(CRASH[9], crash.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(CRASH[9], 0, 10);
  }

  //crash choke
  if (crash.choke == true)
  {
    MIDI.sendPolyPressure(CRASH[7], 127, 10);
    MIDI.sendPolyPressure(CRASH[8], 127, 10);
    MIDI.sendPolyPressure(CRASH[9], 127, 10);
    MIDI.sendPolyPressure(CRASH[7], 0, 10);
    MIDI.sendPolyPressure(CRASH[8], 0, 10);
    MIDI.sendPolyPressure(CRASH[9], 0, 10);
  }

  if (hihat.hit == true)
  {
    //check open or close
    //1.open
    if (hihatPedal.openHH == true)
    {
      MIDI.sendNoteOn(HIHAT[5], hihat.velocity, 10); //(note, velocity, channel)
      MIDI.sendNoteOff(HIHAT[5], 0, 10);
    }
    //2.close
    else if (hihatPedal.closeHH == true)
    {
      MIDI.sendNoteOn(HIHAT[6], hihat.velocity, 10); //(note, velocity, channel)
      MIDI.sendNoteOff(HIHAT[6], 0, 10);
    }
  }

  //when pedal is closed, TCRT5000
  if (hihatPedal.hit == true)
  {
    MIDI.sendNoteOn(HIHAT_PEDAL[6], hihatPedal.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(HIHAT_PEDAL[6], 0, 10);
  }

  //sending state of pedal with controll change
  if (hihatPedal.moving == true)
  {
    MIDI.sendControlChange(4, hihatPedal.pedalCC, 10);
  }

  if (ftom.hit == true)
  {
    MIDI.sendNoteOn(FTOM[4], ftom.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(FTOM[4], 0, 10);
  }

  if (tom04.hit == true)
  {
    MIDI.sendNoteOn(TOM4[4], tom04.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(TOM4[4], 0, 10);
  }

  if (tom03.hit == true)
  {
    MIDI.sendNoteOn(TOM3[4], tom03.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(TOM3[4], 0, 10);
  }

  if (tom02.hit == true)
  {
    MIDI.sendNoteOn(TOM2[4], tom02.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(TOM2[4], 0, 10);
  }

  if (tom01.hit == true)
  {
    MIDI.sendNoteOn(TOM1[4], tom01.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(TOM1[4], 0, 10);
  }

  //SNARE HEAD
  if (snare.hit == true)
  {
    MIDI.sendNoteOn(SNARE[7], snare.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(SNARE[7], 0, 10);
  }
  //SNARE RIMSHOT
  else if (snare.hitRim == true)
  {
    if (snare.velocity > 60)
    {
      MIDI.sendNoteOn(SNARE[8], snare.velocity, 10); //(note, velocity, channel)
      MIDI.sendNoteOff(SNARE[8], 0, 10);
    }
    else
    {
      MIDI.sendNoteOn(SNARE[9], snare.velocity * 2, 10); //(note, velocity, channel)
      MIDI.sendNoteOff(SNARE[9], 0, 10);
    }
  }

  if (kick.hit == true)
  {
    MIDI.sendNoteOn(KICK[4], kick.velocity, 10); //(note, velocity, channel)
    MIDI.sendNoteOff(KICK[4], 0, 10);
  }
}

Or is the wrong connect of circuit ?

Is that the circuit that you haven't actually posted?

Sending note on followed immediately by a note off would normally cause you difficult, depending on the sound generating hardware. With percussion it is rare to send not off calls anyway.

Here is the circuit

Well not so much a circuit diagram more of a graphical hint of what you have.
You show your sensors as buzzers, these are not sensors, and you have a series resistor in them. Why, and what value are they?
As to the resistors on your bread board what values are these?

This code seems to be setting up what addresses to use on the multiplexer after you have called mux.scan() which I suspect is a call to scan all the multiplexer addresses.

This seems the wrong way round to me.

Can you post a link to the libraries you have used, although not hairless.

I made the circuit base on RyoKosaka’s drum project, here is the link of his circuit example “https://github.com/RyoKosaka/HelloDrum-arduino-Library/blob/master/docs/circuit.md
And I can’t find a piezo component so replace the buzzer.
The values of resistors were same as the example of circuit by RyoKosaka as below. And the multiplexer with connect the 4.7k resistor to the GND.

That is very wrong, it will reduce the signal you get drastically. The signals going into the multiplexer are very high impedance and this will reduce the signal severely. Are you sure this value is correct?

In your diagram in post #8 you have not got this resistor. But what I did notice is that you have the tip of your extension lead connected to ground and the shield connected to the signal. This is the wrong way round. Assuming you are using shielded cable the shield should be connected to ground.

In post#4 you showed your code. This is considerably different to the code that is given on that web site for a multiplexer. Where did you get all the things following the matrix.scan() call?

I also noticed that the circuit given on the website was for only an 8 channel multiplexer, did you extend this to a 16 bit multiplexer? Do you realise that this will take twice as long to scan and will result in bigger delays between hit and sound.

Did you actually try the muxSensing_16ch.ino code before you altered it? What results did you get from this?

Yes I’m using muxSensing_16ch.ino code to modify and extension to 16 channels from 8 channels. Notice that I added a TRCT500 to my HiHat pedal, 3 zone ride and cymbal.

I have tried the original code muxSensing_16ch.ino (16 single piezo) but still has the MIDI port problem as same as my modified code. It has problem in hairless MIDI output whatever I unplug or plug the cable to the jacks.

Here is his original code for 16 channel multiplexer with HC4067. I putted all HiHat 2 zone, 3 zone cymbal and dual piezo into muxSensing_ch16 code.

Multiplexer 16 channel:

Dual piezo:

3 zone cymbal:

HiHat with TRCT500:

That is only to be expected, that is nothing to worry about. You will not eliminate that.

Was that the only problem with the original code before you started adding stuff?

Did you pay any attention to the fact that you have the shield of your sensor extension wires carrying the signal? Have you changed that around? That could be picking up interference and causing the problem.

Yes it’s has problem with the original code before I started adding stuff. I think it’s my mistake connection of circuit

I don’t understand about the shield of sensor extension wires carrying the signal, could you please explain clearly, thank you.

Not sure what could be clearer but I will try again.

You have a three wire jack socket. The connector furthest from the open end is called the tip, the one closest to the open end is called the ring.

Your circuit shows the tip connected to ground and the ring connected to the signal.
Any wire you plug into this socket will be screened wire. Your wiring will make the screen into the signal wire and the connection inside the screen the ground.

This is the wrong way round, correct it at once.

Do you mean the tip / ground on the jack sockets connect to wrong way on the board?

Your diagram in post #4 was wrong.
You seem to have corrected this in your last post, #20. Only the hand written notes here are wrong.

It’s still doesn’t work

That doesn't mean it didn't need doing.
I am going through all the things that you have done wrong. It is unlikely that you have just a mistake. Look at the ones we have eliminated so far.

I still think your MIDI errors stem from an intermittent serial connection, which you have insisted is not the case.

OK, so I have been having a play with this hellodrum library, using switches to replicate two drums sensors. Using the simple sensing code in the examples.

At first I was getting exactly what you were getting, warnings about getting a status byte instead of a data byte. Looking at the data from the MIDI Monitor app, this showed that the random status bytes was the MIDI Stop command which is 0xFC.

Then I checked the baud rate that Hairless was expecting and it was the default 11520 baud. So then I changes it to the one the code was sending out, 38400 baud, and everything worked as expected. No extra status bytes and the snare and the tom were triggering as expected.

Now I know you changed the Hairless baud rate to 38400, because you showed the configuration window. But I am just wondering if the baud rate of 38400 is not very accurate on your machine. The setting of the baud rate on all machines is normally a compromise and not all baud rates are sent with the same degree of accuracy.

So I suggest you try setting the baud rate to 11520 in both Hairless and your code, and see if that helps. If not you can try other baud rates to see if you can get a combination that your machine can render more accurately.