Go Down

Topic: Three midi notes in same time (Read 121 times) previous topic - next topic

Deltaplaner

Hi guys! I'm tried to build piezo drums but had a problem. For drumming need at least three midi notes send in same time (kick, hihat, snare) i can only one. I know the problem in my code. Thank you for any information.

Grumpy_Mike

A part of your code reads:-
Code: [Select]

      MIDImessage(noteOn, padMidiVals[i], velocity);
     
      delay(150);
     
      MIDImessage(noteOn, padMidiVals[i], 0);


So yes it can only output one note at a time.

The solution is simple although it might not seem to be to you.
Remove the last two lines.
Scan all the inputs, if you find one above the trigger level trigger a note and record the time from the millis() timer and set a variable to show a note is playing.

At the top level of the loop - that is every time through the loop. Look to see if a note is playing AND that the current time minus the time the note started playing exceeds the time you want it to play then clear the note playing variable and send the MIDI note off.

Once you have done this for one note and it works then extend it to N notes by using arrays for the variables and 'for loops' to look at each variable.

Go Up