NoteMode and MIDI Channel Control via Lua

Hello forum,

I spent the last couple days reading about Lua scripts for Ardour and could come up with a script for making recording with the Behringer RD8 easier. It takes a MIDI track with all the instruments (i.e. kick, snare, etc.) and exports them to their own unique tracks. This part works as intended (Ardour8.12 on a MacBookAir with M2 - if that matters here) and can easily be adapted to other drum machines.

See: https://github.com/dottedpi/rd8_midi_splitter

The following I could not solve:

(1) I have discovered the “Sustained/Percussion mode” of MIDI tracks, and presetting this to the percussion mode would also be nice for recording a drum machine. Is there a way to make this work with the current LuaAPI and scripts? I could not really find anything in the Class Reference.

(2) I managed to access the ChannelMode of the RD8_MIDI_master track (get_playback_channel_mode()), which seems to respond to changes in the settings. However, getting the ChannelMask with get_playback_channel_mask() always gives 0 for me, no matter what I select in the Channel Selector Dialogue of the track directly in Ardour. What’s happening there?

Any help/hints on the code is highly appreciated :slight_smile:

EDIT: better phrasing of the problem (I hope); deleted a question (you can just mute the MIDI tracks if you don’t wanna record them, no channel switching needed…)