-- MIDI Grid: toggle a diatonic seventh chord 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), 4) 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("Seventh " .. state .. ", " .. table.concat(names, ", ")) if state == "on" then G.preview(ps) end