Remote scripts: Add new notes?

Share your favorite Ableton Live tips, tricks, and techniques.
Post Reply
pain staging
Posts: 11
Joined: Tue Apr 06, 2021 12:13 pm

Remote scripts: Add new notes?

Post by pain staging » Sat Oct 16, 2021 6:24 am

I´m trying to add new notes in my Remote script but haven´t been able to make it work.

I´m on Live 11 so the recommended function is "add_new_notes" (documentation: https://docs.cycling74.com/max8/vignett ... model#Clip)

Code: Select all

add_new_notes
Parameter:
dictionary
Key: "notes" [list of note specification dictionaries]
Note specification dictionaries have the following keys:
pitch: [int] the MIDI note number, 0...127, 60 is C3.
start_time: [float] the note start time in beats of absolute clip time.
duration: [float] the note length in beats.
velocity (optional): [float] the note velocity, 0 ... 127 (100 by default).
mute (optional): [bool] 1 = the note is deactivated (0 by default).
probability (optional): [float] the chance that the note will be played:
1.0 = the note is always played
0.0 = the note is never played
(1.0 by default).
velocity_deviation (optional): [float] the range of velocity values at which the note can be played:
0.0 = no deviation; the note will always play at the velocity specified by the velocity property
-127.0 to 127.0 = the note will be assigned a velocity value between velocity and velocity + velocity_deviation, inclusive; if the resulting range exceeds the limits of MIDI velocity (0 to 127), then it will be clamped within those limits
(0.0 by default).
release_velocity (optional): [float] the note release velocity (64 by default).

For MIDI clips only.

Available since Live 11.0.
My attempt to add a note:

Code: Select all

# get clip ...
notes = []

note = {
	"pitch": 79,
	"start_time": 1,
	"duration": 4,
	"velocity ": 127,
        }

notes.append(note)
new_notes = {"notes": notes}

clip.add_new_notes(new_notes)
I get this exception:
No registered converter was able to produce a C++ rvalue of type struct NPythonClip::TNoteSpecification from this Python object of type str

Does anybody know how to to it correctly?

pain staging
Posts: 11
Joined: Tue Apr 06, 2021 12:13 pm

Re: Remote scripts: Add new notes?

Post by pain staging » Sat Oct 16, 2021 8:32 am

This works!

Code: Select all

import Live
# ...
new_notes = []
note = Live.Clip.MidiNoteSpecification(pitch=69, start_time=1, duration=4, velocity=127)
new_notes.append(note)
clip.add_new_notes(tuple(new_notes))

Post Reply