Created
March 12, 2020 13:10
-
-
Save frabert/0c20a89119aa68868f4f62c8ea89033c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local selectedMediaItems = reaper.CountSelectedMediaItems(0) | |
local notes = { 'A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#' } | |
function transpose(amount, note) | |
local index = 0 | |
for i, v in ipairs(notes) do | |
if v == note then | |
index = i | |
end | |
end | |
if index ~= 0 then | |
local newIndex = (index + amount - 1) % #notes | |
return notes[newIndex + 1] | |
end | |
end | |
for i=0,selectedMediaItems-1 do | |
local mediaItem = reaper.GetSelectedMediaItem(0, i) | |
local note = reaper.ULT_GetMediaItemNote(mediaItem) | |
note = string.gsub(note, "([A-G]#?)", function(n) | |
return transpose(1, n) | |
end) | |
reaper.ULT_SetMediaItemNote(mediaItem, note) | |
end | |
reaper.UpdateArrange() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment