Change Midi note values within lua scripts?

Hi, I want to implement a short humanizing function for midi notes with lua. So in a selected region I get all midi notes, but I found no function to change for instance the node value or the position of the note.

Here a code snippet:
local nl = ARDOUR.LuaAPI.note_list (mr:model ())
for n in nl:iter () do
print(n:note ())
print(n:time())

But how do I chance note and time?
If you have any Ideas, thank you very much.

We don’t providers mutators for Evoral::Event from lua at this time.

You don’t have to use Lua, Ardour has this built-in: The Transforming MIDI—Mathematical Operations dialog allows to add some randomness (which isn’t the same as humanization, but may suffice).

Otherwise you could do this in realtime, as plugin: have a look at the midi_remap example script:

Thank you very much.
I have found the Transform midi function, but I didn’t figure out how to slightly adjust the starting of a midi note. But it is usefull to adjust the velocity of midi notes.
Your real time example looks promising.

What I want to do is:
I program drums on the piano roll, for instance one bar with 16th hihats. They are perfectly on the beat. But I want to humanize the hihat by adjusting randomly the starting point of the hihats a little (some a little bit behind and some a little bit upfront).

I’ll try to program a solution.

You can do exactly that with the MIDI Transform tool : look at this post.
Regards

1 Like

Thanks a lot for this info. I did not found it.
I will try this.