polyphonic piano with arduino??

how can I hold/save the key whenever they are held down.

This code:

buttonset = digitalRead(button[x]);

Is reading the current state of the switch on pin button[x]. The switch is being held down if it's state is the same as the last time you read it.

This means that you need to save the state of the button, in an array, and compare the current reading to the previous reading.

Questions: You are reading the state of 8 pins, whose numbers are stored in an array of length 3. Why does the array length not match the number of pins to read? Why is the type of the array boolean? That is not compatible with the data being stored in the array.

Why are speakerpin and buttonset booleans? The values being stored in these variables is not true or false.