The only thing I can think of is that this line is not working...
Code:
playednotes[note] > 0 ? (
... because I have had issues before using "arrays" that were solved by using parenthesis, so changing it to...
Code:
(playednotes[note]) > 0 ? (
... might work.
If not, I'll try to test it later.