How do I get a list of currently held midi notes?

    Oct 07 2012 | 12:17 am
    Title pretty much explains it. I've tried rigging the poly object and routing it so that it makes a list and zl.filters out any notes that are at less than 1 velocity, but this has too many problems and isn't worth posting here.
    This is what I want it to do: any time the object gets a midi note or set of midi notes, send it to the output as a list. Order doesn't matter. The list's size has to be the same as the number of notes currently held down. Velocity is disregarded, but it's probably useful for deciding when the notes are going to be on the list.

    • Oct 07 2012 | 12:55 am
      The [borax] object may be useful for this.
    • Oct 07 2012 | 2:11 am
      I don't think Borax will do the job here, it can't easily give you a list of held notes and it cant deal with different midi channels.
      Here are two examples one for collecting held note numbers and one for collecting held note number and midi channel which is really useful if you are using a controller which outputs multiple channels simultaneously. Don't think I've ever used the bag object before or since this.
    • Oct 07 2012 | 2:34 am
      dang, I was just putting the finishing touches on my rig using borax as you posted that! That setup you pasted is more attractive than mine though, and it will definitely be useful when I make the inevitable jump to multiple channels. Thank you very much.
    • Oct 07 2012 | 3:05 am
      No worries, the multiple midi channel one is a bit hackish but it works fine. A more elegant solution would be to use Java or Java script.
      I think I forgot to add a bang to the bag object in my first example, i'm sure you've worked it out but just bang it when you need the held notes out.
    • Oct 07 2012 | 7:39 am
      I haven't looked at leafcutter's approach so this may be redundant and or inefficient:
    • Feb 18 2017 | 6:35 pm
      Hey! Sorry for pumping up this thread again, I'm working in a patch that needs a similar trickery...
      I love your implementation Chris, but unfortunately it's not working in my situation, because i need to keep track of multiple note-ons which may have arrived for the same pitch. For example: 60 64 60 61 60 60
      In your implementation, multiple note-ons for the same pitch are not saved, resulting in a list like this: 60 64 61
      Any idea how could i solve this, taking your patch as a starting point?
    • Feb 18 2017 | 11:03 pm
      Hey Playmodes, this one should do your duplicate notes, but it's a different method. It could have multiple channels, too, but I haven't added that cos I don't know how you'd want them output. It currently doesn't handle note number 0 either, but that could be added as well. HTH, Bill
    • Feb 19 2017 | 5:59 pm
      Hey Bill!
      Thank you very much, that works like a charm!
    • Feb 21 2017 | 11:35 pm
      A variation on the ideas and patches on this thread:
      -note-ons of the same pitch are stored in the list, but repetitions not sent to noteout -note-off is generated just if the number of note-offs equals the number of note-ons stored in the list