Note on and off with list
To store all note on messages in a list and delete them when a note off message is received, use the bag object.
To store all note on messages in a list and delete them when a note off message is received, use the bag object.
This example shows how to get a complete list with all currently played notes using bag object. In this example we are also using the thresh 0 object in order to output all notes being held by bag as a single list.
This abstraction, which I call “inlist”, checks to see if a given number belongs to a previously-collected set of numbers. Numbers in the middle inlet are added to the set, and numbers in right inlet are deleted from the set. A clear message in the left inlet deletes the entire set.
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.