Need help with 2 thing in a code.

Hi guys.
I have 2 problem with my code.

First i’m building a drum set with piezo and i’m using hairless to communicate the arduino with addictive drums.

2 problem.
When I hit the snare I have the snare and Bass drum (note 36 and 38 in the same time)
I don’t understand because the rest of the code work really well.

Second, it’s possible to have a velocity but for each sensor?
My cymball are really not enought sensible and drum’s are really sensitive.

If somebody can help me with that I will really appreciated.
Thanks.
Jc

#include <MIDI.h>
#include <midi_Defs.h>
#include <midi_Message.h>
#include <midi_Namespace.h>
#include <midi_Settings.h>

/*
MIDI Toy Piano Hack Code
*/


MIDI_CREATE_DEFAULT_INSTANCE();

//========================================================================================
//Values you may need to change

//Set this value to the number of keys/piezos you are using
const int NUM_OF_KEYS = 10;
//Adjust this value to change the sensitivity of the piezos
const int THRESHOLD = 75;
//Set this value to the number of microseconds you want each MIDI note to last for
const int NOTE_LENGTH = 20;
//Adjust this value to set the range of MIDI note velocity values
const int VEL_SENSE_VAL = 2;

//Change this number to set what MIDI channel the MIDI notes are set to
const int midiChan = 1;
//Change these numbers to set what MIDI note number each key/piezo will send.
//Also make sure that the total number of numbers here matches the value of NUM_OF_KEYS
const int midiNote[NUM_OF_KEYS] = {38,36,47,41,43,46,49,57,59,55};

//Change these values to set which analog input pins you are using
//Also make sure that the total number of values here matches the value of NUM_OF_KEYS
const int triggerSensor[NUM_OF_KEYS] = {A6, A7, A8, A9, A10, A11, A12, A13, A14, A15};

//=======================================================================================

//Variables for storing certain values
int triggerVal[NUM_OF_KEYS] = {0};
bool noteIsOn[NUM_OF_KEYS] = {false};
int midiNoteTime[NUM_OF_KEYS] = {0};
int midiVelocityVal[NUM_OF_KEYS] = {0};

void setup()
{
    MIDI.begin(MIDI_CHANNEL_OMNI);
    Serial.begin(115200); //REMOVE THIS LINE IF USING HIDUINO INSTEAD OF HAIRLESS
}

void loop()
{
    //repeat the below code for each anaolog input/piezo sensor
    for (int count; count < NUM_OF_KEYS; count++)
    {
        //read the piezo value
        triggerVal[count] = analogRead(triggerSensor[count]);

        //if the value is over the threshold and there isn't currently a note on for this piezo
        if (triggerVal[count] > THRESHOLD && noteIsOn[count] == false)
        {
            //get a velocity value based on the value
            midiVelocityVal[count] = triggerVal[count] * (127.0/1023.0);

            //increase sensitivity
            midiVelocityVal[count] *= VEL_SENSE_VAL;

            //make sure we don't go out of range
            if (midiVelocityVal[count] > 127)
            midiVelocityVal[count] = 127;

            //send a MIDI note-on message
            MIDI.sendNoteOn (midiNote[count], midiVelocityVal[count], midiChan);

            //flag that the note is on
            noteIsOn[count] = true;

            //start a timer for the note to be on for
            midiNoteTime[count] = NOTE_LENGTH;
        }

        //if the note is currently on
        if (noteIsOn[count] == true)
        {
            //reduce the time value by 1
            midiNoteTime[count]--;

            //if time value equals 0
            if (midiNoteTime[count] == 0)
            {
                //turn off the note
                MIDI.sendNoteOff (midiNote[count], 0, midiChan);
                noteIsOn[count] = false;
            }

        }

    }

    //pause the loop
    delay(1);
}

Make the threshold variable an array so that each sensor can have its own sensitivity level.

something like that? const int midiNote[NUM_OF_KEYS] = {38,36,47,41,43,46,49,57,59,55}; const int triggerSensor[NUM_OF_KEYS] = {A6, A7, A8, A9, A10, A11, A12, A13, A14, A15}; const int threshold[NUM_OF_KEYS] = {50,100,10,100,50,50,50,50,50,50};

I'm sorry im really new in arduino. I try to understand some code out of the web.

Thanks. Jc

Yes that is the idea, so you can tune each sensor to its own level.