dynamically added m4l objects not key or midi mappable?


    Sep 02 2014 | 11:00 am
    I am generating objects via javascript in an m4l patch. I've noticed that, although when in MIDI Map mode or Key Map Mode the m4l objects do light up as if they are mappable, actual assignment fails.
    So, are dynamically added m4l UI objects not mappable?

    • Sep 02 2014 | 12:13 pm
      interesting... not something I've considered before - not sure about this, but I can't think of any reason why not... be interesting to see what the answer to this is
    • Sep 02 2014 | 6:21 pm
      Well i never tried this, but it makes sense for the same reason that live.menu cannot be populated dynamically: Live parameters within devices cannot change dynamically. It's simply not built into it. Even if you change setting for a live.** ui object within the Max editor is only active after saving the device...
    • Sep 02 2014 | 6:36 pm
      Yeah Jan is right, changes to device parameter code are only updated at device load. There's a whole back and forth with Live at that point to register everything in the set
      Cheers
      -A
    • Sep 03 2014 | 9:53 am
      Thinking about what you guys have said, just want to be clear, maybe I'm missing something. For one, live.menu can indeed be populated dynamically, and it will still be mappable and automatable. Here is a quickly contrived example script, just add a default live.menu to the presentation, and connect a toggle to a js object containing this script. Isn't this changing device parameter code after the device load (with the editor closed, of course)? (I'd attach a patch but I don't think I can copy compressed with a js object, right?)
      function msg_int(val) {
        var vals = [], 
            prefix = val ? 'foo_' : 'bar_',
            count = 5+Math.random()*5,
            i = 0;
        for (; i < count; i++) {
          var randomInt = parseInt(65+Math.random()*100);
          vals[i] = prefix + String.fromCharCode(randomInt);
        }
        patcher.getnamed('live.menu').message('_parameter_range', vals);
      }
      
      In my current case, the amount of objects needed in my patch is proportional to the number of tracks in a live set. I can't know how many tracks a user may have in a set, so I'm hard-coding for a best guess maximum. I have NO idea how many tracks kids these days are using, which is why I was trying to dynamically add objects at "runtime" (which actually works if you don't mind missing crucial Live features ;). Even the fact that I've gotten this close is pretty awesome (of Max and Live, I mean).
      Is there a way to programmatically clone an existing device with all of its settings?
    • Sep 03 2014 | 10:29 am
      FYI, I believe modifying the _parameter_range attrib is unsupported - it may work today, might not work tomorrow... (well, in a future update)