Ok so I have updated the functions, to something that is closer...
void addToArray(int Mappedkey){
pressedNoteOrder[sizeOfArray+1] = Mappedkey-1;
sizeOfArray++;
}
void removeFromArray(int MappedKey){
for (byte i = 0; i<sizeof(pressedNoteOrder); i++){//go through each item in the array
if(pressedNoteOrder[i] == MappedKey-1){//look for a match to the note that was released
for (byte j=i+1; j<sizeof(pressedNoteOrder); j++){
pressedNoteOrder[j-1] = pressedNoteOrder[j];//when found, shift each note after down one, i.e to clear it out of the array
}
break;
}
}
pressedNoteOrder[sizeof(pressedNoteOrder)-1] = 0;
sizeOfArray--;
}
void playArray(){
static int i = -1;
i++;
if (i > sizeOfArray){
i = 0;
}
Play(pressedNoteOrder[i]);
}
Adding seems to work fine.
PlayArray() is going through the array but seems to be going one further than the length - i.e if two buttons are held down, and the timer is calling it once a second, then it goes back to 0 as after a third (that dosnt exist) so i hear the two correct notes, and then there is a silence in the position of the third 'tick' before returning to the first note again.
Remove seems to be causing big problems, in that if I release a button, I then hear nothing after that. I think its messing the array up somehow - I know that you cant "remove" an element but I am trying to shift them all down.
Any help would be greatly appreciated
Thanks