leolabs / ableton-js

Control Ableton Live with Node.js
MIT License
368 stars 46 forks source link

Clip.set_notes(...) did not match C++ signature set_notes(...) #26

Closed deanfra closed 3 years ago

deanfra commented 3 years ago

Hi, I'm enjoying this library very much.

One issue I've noticed (using Ableton 11) is that using set_notes on a Clip (and possibly other Set commands) will throw this error.

node:39754) UnhandledPromiseRejectionWarning: Error: Python argument types in
    Clip.set_notes(Clip, list)
did not match C++ signature:
    set_notes(TPyHandle<AClip>, boost::python::tuple)
    at Ableton.handleUncompressedMessage (/<path/to/project>/node_modules/ableton-js/index.js:186:41)

My JS code looks like this

    const tracks = await ableton.song.get('tracks')
    const clipSlots = await tracks[0].get('clip_slots')
    const clip = await clipSlots[0].get('clip')
    if(clip) {
      await clip.setNotes([{ pitch: 60, time: 0, duration: 1, velocity: 98, muted: false }])
    }

I've attempted to define a custom setter in Clip.py that converts a List to Tuple, but then it throws a similar type error

UnhandledPromiseRejectionWarning: Error: set_notes() argument after ** must be a mapping, not list

I've exhausted my rudimentary Python knowledge so I thought I'd raise a ticket, thanks! 😄

https://github.com/leolabs/ableton-js/blob/2d89342d70f16a07427d17ec9fa43bc48c865d9e/midi-script/Interface.py#L102

leolabs commented 3 years ago

Hey @deanfra!

Thanks for your feedback! I haven't used setNotes in a while, but I can take a look at what's going wrong with it tomorrow. I'll keep you posted :)

deanfra commented 3 years ago

Thanks very much!

deanfra commented 3 years ago
Just some more testing around notes: function result
selectAllNotes Works
removeNotes Works (with a warning popup in Ableton 11)
deselectAllNotes Throws Error: Function call failed: deselectAllNotes doesn't exist or isn't callable.
getNotes Throws Error: get_notes() argument after ** must be a mapping, not list
replaceSelectedNotes Throws Clip.replace_selected_notes(Clip, list) did not match C++ signature: replace_selected_notes(TPyHandle<AClip>, boost::python::tuple)

Thanks

deanfra commented 3 years ago

Hi again, I was able to figure out how to make setNotes work again in Ableton 11:

  1. In clip.ts, in the function setNotes, the argument doesn't need a wrapping array, so it can be changed to
    return this.sendCommand("set_notes", notes.map(noteToTuple));
  2. In the python scripts, make sure the list gets converted into a tuple somewhere (I have my own hack for now)
leolabs commented 3 years ago

Thanks for your insights! I'll push a fix for it soon :)

deanfra commented 3 years ago

Great work, thanks!

leolabs commented 3 years ago

Hey @deanfra!

Sorry for the long delay. I've created a fix and will release it in the next version :)

deanfra commented 3 years ago

@leolabs Thanks!