Keep pitches of held MIDI notes in a bag
The bag object stores an unordered collection of integers. You can put numbers into the bag or remove them, and you can query what’s in the bag using the bang message. You put a number into the bag by providing the number along with a 1 (or any non-zero number), and you remove it by specifying the number along with a 0.