Limiting polyphony in an electro mechanical instrument

    Mar 30 2015 | 4:20 am
    This particular problem is quite difficult to explain so I will give you my scenario and hopefully it will make sense.
    I am currently building a bespoke electromechanical chromatic instrument that will be controlled by max in conjunction with maxuino and an arduino. Each 'note' features a solenoid (physical electronic actuator) that generates a sound. The external power supply and circuitry that I am using for my instrument will only be sufficient to power 8 solenoids at the same time, so effectively my instrument will be limited to playing chords comprising of a maximum of 8 notes.
    The instrument has 24 notes in total so obviously if more than the 8 notes are triggered at the same time then there is a danger of damaging my power supply/circuitry. I intend to enable the instrument to be controlled by a pre-programmed score but also separately with real time midi keyboard input. In order to prevent damage to my circuitry I need to engineer in a way of limiting the maximum number of solenoids that can be triggered from Max at the same time.
    Imagine this instrument is setup in an installation and someone who is not aware of the 8 note rule uses the keyboard and plays a 10 note chord. In the solution I am envisioning the first 8 notes (lets say left to right as an example) would trigger the solenoids as normal but then the x number of notes triggered after the 8th would be filtered out and would not be able to trigger any further solenoids. It may also be useful to mention that the solenoids are only powered for 35 ms each time a note is triggered.
    I have been tearing my hair out researching and trying out different ways of achieving this but with no success, I did see this thread on the forums which seemed similar however I don't think the suggestions made there quite address my specific problem.
    I would be most grateful for any help you can provide.
    Thank you for your time,

    • Mar 30 2015 | 7:17 am
      the [poly] object should do just what you need.
    • Mar 30 2015 | 3:59 pm
      Thank you for your reply. I had looked at Poly before and I couldn't quite get it to work but I have given it another go and it now seems to work, thank you. For some reason though my patch will select additional random notes in addition to the ones I am playing. Please see the patch for yourself. Any thoughts?
      EDIT: Upon further investigation it only seems to do this when the notes are played in quick succession using the midi keyboard. I does not seem to occur when the on screen keyboard is used.
      Max Patcher
      In Max, select New From Clipboard.
      Thank you
    • Mar 30 2015 | 4:02 pm
      you're sending the velocity out of the stripnote into the selection subpatcher as if it were a note number
    • Mar 30 2015 | 4:06 pm
      That was fast! Why yes it appears I am, how did I not notice that?! Thank you ever so much. :)
    • Mar 30 2015 | 6:14 pm
      Max Patcher
      In Max, select New From Clipboard.
      Also, you can semplify your patch using [makenote] and [spray]:
    • Mar 30 2015 | 10:26 pm
      Thank you very much, I hadn't come across the spray object before.