Re: Coding for a modular synthesizer keyboard help
Posted: Mon Sep 15, 2025 7:52 pm
So with both the doubly linked list and a singly linked list (both of which are basically just a FIFO (queue) instead of a FILO (stack)) you still effectively have a gap problem.
Press A, Press B, Press C, release B....
You now have a gap in the middle of the list, so your tail pointer in a FIFO would have the same issue, and ultimately someone COULD still blow your array if they're clever with how they press the keys. A doubly linked list could help in that you can adjust the head/tail pointers in the list, but you'd then still have the O(n) problem where n is the distance from head to tail. Which n is arguably small in this case, but we're talking about a 6502, so those 1s add up.
Again, if you're actually playing single notes, this isn't something I foresee as being something that would generally happen. If someone presses a chord it might start getting a bit crazy though, as the software will almost certainly get the keys released in a completely different order than they were pressed. Ultimately the order issue would likely get resolved on subsequent passes of the scan loop though.
In any event I don't see a FIFO as having any additional benefit over a FILO, in fact it adds the complexity of having an additional pointer to deal with; plus you have to implement this all in software. At least the stack is mostly done in the hardware.
Press A, Press B, Press C, release B....
You now have a gap in the middle of the list, so your tail pointer in a FIFO would have the same issue, and ultimately someone COULD still blow your array if they're clever with how they press the keys. A doubly linked list could help in that you can adjust the head/tail pointers in the list, but you'd then still have the O(n) problem where n is the distance from head to tail. Which n is arguably small in this case, but we're talking about a 6502, so those 1s add up.
Again, if you're actually playing single notes, this isn't something I foresee as being something that would generally happen. If someone presses a chord it might start getting a bit crazy though, as the software will almost certainly get the keys released in a completely different order than they were pressed. Ultimately the order issue would likely get resolved on subsequent passes of the scan loop though.
In any event I don't see a FIFO as having any additional benefit over a FILO, in fact it adds the complexity of having an additional pointer to deal with; plus you have to implement this all in software. At least the stack is mostly done in the hardware.