DAW Midi to trigger ommiting all notes and cosidering only one -note on pooling?

Hi guys

I´ve build a midi to trigger module.
It converts each "note on" into a trigger , starting from C1.
It works great if I receive notes with intervals , with little delay between them.
Like the following picture.

But , if I receive all notes together, like a chord (C1+D1+E1) , the "HandleNoteOn" consider only one "note on" ( I cant remember each one now).

How to pool all "note on" and fire all "chord" triggers?

Trigger *triggers[MAXTRIGGERS] = {&t8, &t9, &t10, &t11, &t12, &t13, &t2, &t3, &t4, &t5, &t6, &t7};

void setup()
{
  //  Serial.begin(9600);
  MIDI.begin(MIDI_CHANNEL_OMNI);
  MIDI.setHandleNoteOn(HandleNoteOn);

  for (int i = 0; i < MAXTRIGGERS; i++)
    triggers[i]->setLenght(20);

  //trigger check
  for (int i = 0; i < MAXTRIGGERS; i++)
  {
    triggers[i]->start();
    delay(TESTDELAY);
    triggers[i]->end();
  }
}

void loop()
{
  MIDI.read();
  for (int i = 0; i < MAXTRIGGERS; i++)
    triggers[i]->compute();
}

void HandleNoteOn(byte channel, byte pitch, byte velocity)
{
  if ((pitch >= PITCHSTART) && (pitch < (PITCHSTART + MAXTRIGGERS)))
  {
    if (velocity > 0)
      triggers[pitch - PITCHSTART]->start(ELECTROMECANICALTRIGGERLENGHT);
    // else
    //   triggers[pitch - PITCHSTART]->end();
  }
}

TIA

Gibran

Your code looks very odd, have you posted all of it? In particular I can’t see where the midi comes in and how you remove the trigger from stuff. If you are using delay then that will screw you up.

I did a similar project years ago, you can see it here.
http://www.thebox.myzen.co.uk/Hardware/Glockenspiel.html

Hi Grumpy

I already did some code cleaning and reached the following version.
But I think that my USB/MIDI interface have something to do with the problem.
No matter how many notes I send together on a chord from Ableton , I receive only one package on arduino , only the first note.

I installed a MIDI monitor and it receives all notes from Ableton.

I´ll take a look on your code today !

Thank you !

void loop()
{
  byte _incomingByte;
  byte _pitch;
  byte _velocity;

  while (Serial.available() > 2)
  {
    _incomingByte = Serial.read();
    _pitch = (int)Serial.read();
    _velocity = (int)Serial.read();
    if ((_incomingByte == 0x90) &&
        (((_pitch >= PITCHSTART) && (_pitch < (PITCHSTART + MAXTRIGGERS)) && (_velocity > 0))))
      triggers[_pitch - PITCHSTART]->start(ELECTROMECANICALTRIGGERLENGHT);
  }
  for (int i = 0; i < MAXTRIGGERS; i++)
    triggers[i]->compute();
}

Hi Grumpy

I merged your code with mine and again , chords reaches arduino like like one first note.
Maybe its time to test another USB interface.

Many thanks

Again you are not posting all the code. In that project I linked to the time the trigger lasts is controlled by a monostable, a hardware chip.

How are you controlling the time the trigger signal lasts for? I suspect it is this bit of the code that is blocking reception of the other MIDI messages.

I did do another project like this in my book, Arduino Music and Audio Projects | SpringerLink you can download the software from that page.

That uses all software to determine how long a note lasts by timing the arrival of the note and using a state machine like the blink without delay example, so that it is none blocking.

This video MIDI Beater - YouTube doesn’t show more than one thing being hit at the same time but it will do that.