Files

20 lines
616 B
Lua
Raw Permalink Normal View History

-- MIDI Grid: toggle a diatonic triad on the cursor pitch
local dir = ({ reaper.get_action_context() })[2]:match("@?(.*[\\/])")
local G = dofile(dir .. "midigrid_lib.lua")
if not G.isActive() then return end
local hwnd, take, err = G.editor()
if not take then G.say(err) return end
local ps = G.chordPitches(G.getPitch(hwnd), 3)
if not ps then G.say("No room for a chord here") return end
local state = G.toggleChord(take, ps)
local names = {}
for _, p in ipairs(ps) do names[#names + 1] = G.noteName(p) end
G.say("Triad " .. state .. ", " .. table.concat(names, ", "))
if state == "on" then G.preview(ps) end