-- Display a message in the console for debugging function Msg(variable) reaper.ShowConsoleMsg(tostring(variable).."\n") end function select_region() local time = reaper.GetCursorPosition() local markeridxOut, regionidx = reaper.GetLastMarkerAndCurRegion(0, time) local retval, isrgnOut, posOut, rgnendOut, nameOut, markrgnindexnumberOut, colorOut = reaper.EnumProjectMarkers3(0, regionidx) local start_time, end_time = reaper.GetSet_LoopTimeRange(true, true, posOut, rgnendOut, 0) --reaper.Main_OnCommand(40289, 0) -- Item: Unselect all items --reaper.Main_OnCommand(40717, 0) -- Item: Select all items in current time selection end --region_count , num_markersOut, num_regionsOut = reaper.CountProjectMarkers(0) --select_region() --commandID2 = reaper.NamedCommandLookup("_S&M_GOTO_SEL_REGION1") --reaper.Main_OnCommand(commandID2, 0) -- SWS/S&M: Go to/select region 1 (obeys smooth seek) --chord_region = 0 --for i = 0, region_count - 1 do function next_region() edit_pos = reaper.GetCursorPosition() play = reaper.GetPlayState() if play > 0 then pos = reaper.GetPlayPosition() else pos = edit_pos end i=0 repeat iRetval, bIsrgnOut, iPosOut, iRgnendOut, sNameOut, iMarkrgnindexnumberOut, iColorOur = reaper.EnumProjectMarkers3(0,i) if iRetval >= 1 then if bIsrgnOut == true and iPosOut > pos then -- ACTION ON REGIONS HERE reaper.SetEditCurPos(iPosOut +.2,true,true) -- moveview and seekplay break end i = i+1 end until iRetval == 0 reaper.UpdateArrange() -- Update the arrangement (often needed) reaper.Main_OnCommand(40289, 0) -- Item: Unselect all items commandID2 = reaper.NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") reaper.Main_OnCommand(commandID2, 0) --Xenakios/SWS: Select items under edit cursor on selected tracks _XENAKIOS_SELITEMSUNDEDCURSELTX retval, isrgn, region_pos, region_end, region_name, region_index, region_color = reaper.EnumProjectMarkers3( 0,chord_region +1 ) end function get_chord_notes(chord_region) --::skip:: i = i +1 --isrgnOut, region_pos, region_end, region_name, region_index, region_color = reaper.EnumProjectMarkers3(0,chord_region) retval, isrgn, region_pos, region_end, region_name, region_index, region_color = reaper.EnumProjectMarkers3( 0,chord_region) --markeridx, regionidx = reaper.GetLastMarkerAndCurRegion(0, reaper.GetCursorPosition()) --retval, isrgnOut, region_pos, region_end, region_name, region_index, region_color = reaper.EnumProjectMarkers3(0, regionidx) if string.match( region_name, "@.*") then next_region() end -- skip region marked @ ignore if string.find(region_name, "/") then root, chord, slash = string.match(region_name, "(%w[#b]?)(.*)(/%a[#b]?)$") else root, chord = string.match(region_name, "(%w[#b]?)(.*)$") slashnote = 0 slash = "" end -- root, chord = string.match(region_name, "(%w[#b]?)(.*)$") if not chord or #chord == 0 then chord = "Maj" end if not slash then slash = "" end --Msg("root " ..root) --Msg("chord " ..chord) --Msg("slash " ..slash) note1 = 0 -- 60 = C3 if root == "C" then note1 = 0 elseif root == "C#" then note1 = 1 elseif root == "Db" then note1 = 1 elseif root == "D" then note1 = 2 elseif root == "D#" then note1 = 3 elseif root == "Eb" then note1 = 3 elseif root == "E" then note1 = 4 elseif root == "F" then note1 = 5 elseif root == "F#" then note1 = 6 elseif root == "Gb" then note1 = 6 elseif root == "G" then note1 = 7 elseif root == "G#" then note1 = 8 elseif root == "Ab" then note1 = 8 elseif root == "A" then note1 = 9 elseif root == "A#" then note1 = 10 elseif root == "Bb" then note1 = 10 elseif root == "B" then note1 = 11 if not root then end end slashnote = 255 -- 48 = C2 if slash == "/C" then slashnote = -12 elseif slash == "/C#" then slashnote = -11 elseif slash == "/Db" then slashnote = -11 elseif slash == "/D" then slashnote = -10 elseif slash == "/D#" then slashnote = -9 elseif slash == "/Eb" then slashnote = -9 elseif slash == "/E" then slashnote = -8 elseif slash == "/F" then slashnote = -7 elseif slash == "/F#" then slashnote = -6 elseif slash == "/Gb" then slashnote = -6 elseif slash == "/G" then slashnote = -5 elseif slash == "/G#" then slashnote = -4 elseif slash == "/Ab" then slashnote = -4 elseif slash == "/A" then slashnote = -3 elseif slash == "/A#" then slashnote = -2 elseif slash == "/Bb" then slashnote = -2 elseif slash == "/B" then slashnote = -1 if not slash then slashnote = 255 end end --octave = note1 - slashnote --if octave > 12 and slashnote > 0 then slashnote = slashnote + 12 end --reaper.MIDI_InsertNote(take, true, false, 0, length -2, 1, note1, 50, false) -- Set root note1 note2 = 255 note3 = 255 note4 = 255 note5 = 255 note6 = 255 note7 = 255 if string.find(",Maj,M,", ","..chord..",", 1, true) then note2=4 note3=7 end if string.find(",m,min,", ","..chord..",", 1, true) then note2=3 note3=7 end if string.find(",dim,m-5,mb5,m(b5),0,", ","..chord..",", 1, true) then note2=3 note3=6 end if string.find(",aug,+,+5,(#5),", ","..chord..",", 1, true) then note2=4 note3=8 end if string.find(",-5,(b5),", ","..chord..",", 1, true) then note2=4 note3=6 end if string.find(",sus2,", ","..chord..",", 1, true) then note2=2 note3=7 end if string.find(",sus4,sus,(sus4),", ","..chord..",", 1, true) then note2=5 note3=7 end if string.find(",5,", ","..chord..",", 1, true) then note2=7 note3=12 end if string.find(",5add7,5/7,", ","..chord..",", 1, true) then note2=7 note3=10 note4=10 end if string.find(",add2,(add2),", ","..chord..",", 1, true) then note2=2 note3=4 note4=7 end if string.find(",add4,(add4),", ","..chord..",", 1, true) then note2=4 note3=5 note4=7 end if string.find(",madd4,m(add4),", ","..chord..",", 1, true) then note2=3 note3=5 note4=7 end if string.find(",11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=14 note6=17 end if string.find(",11sus4,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=14 note6=17 end if string.find(",m11,min11,-11,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=14 note6=17 end if string.find(",Maj11,maj11,M11,Maj7(add11),M7(add11),", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=14 note6=17 end if string.find(",mMaj11,minmaj11,mM11,", ","..chord..",", 1, true) then note2=3 note3=7 note4=11 note5=14 note6=17 end if string.find(",aug11,9+11,9aug11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=14 note6=18 end if string.find(",augm11, m9#11,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=14 note6=18 end if string.find(",11b5,11-5,11(b5),", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=14 note6=17 end if string.find(",11#5,11+5,11(#5),", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=14 note6=17 end if string.find(",11b9,11-9,11(b9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=13 note6=17 end if string.find(",11#9,11+9,11(#9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=15 note6=17 end if string.find(",11b5b9,11-5-9,11(b5b9),", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=13 note6=17 end if string.find(",11#5b9,11+5-9,11(#5b9),", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=13 note6=17 end if string.find(",11b5#9,11-5+9,11(b5#9),", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=15 note6=17 end if string.find(",11#5#9,11+5+9,11(#5#9),", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=15 note6=17 end if string.find(",m11b5,m11-5,m11(b5),", ","..chord..",", 1, true) then note2=3 note3=6 note4=10 note5=14 note6=17 end if string.find(",m11#5,m11+5,m11(#5),", ","..chord..",", 1, true) then note2=3 note3=8 note4=10 note5=14 note6=17 end if string.find(",m11b9,m11-9,m11(b9),", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=13 note6=17 end if string.find(",m11#9,m11+9,m11(#9),", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=15 note6=17 end if string.find(",m11b5b9,m11-5-9,m11(b5b9),", ","..chord..",", 1, true) then note2=3 note3=6 note4=10 note5=13 note6=17 end if string.find(",m11#5b9,m11+5-9,m11(#5b9),", ","..chord..",", 1, true) then note2=3 note3=8 note4=10 note5=13 note6=17 end if string.find(",m11b5#9,m11-5+9,m11(b5#9),", ","..chord..",", 1, true) then note2=3 note3=6 note4=10 note5=15 note6=17 end if string.find(",m11#5#9,m11+5+9,m11(#5#9),", ","..chord..",", 1, true) then note2=3 note3=8 note4=10 note5=15 note6=17 end if string.find(",Maj11b5,maj11b5,maj11-5,maj11(b5),", ","..chord..",", 1, true) then note2=4 note3=6 note4=11 note5=14 note6=17 end if string.find(",Maj11#5,maj11#5,maj11+5,maj11(#5),", ","..chord..",", 1, true) then note2=4 note3=8 note4=11 note5=14 note6=17 end if string.find(",Maj11b9,maj11b9,maj11-9,maj11(b9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=13 note6=17 end if string.find(",Maj11#9,maj11#9,maj11+9,maj11(#9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=15 note6=17 end if string.find(",Maj11b5b9,maj11b5b9,maj11-5-9,maj11(b5b9),", ","..chord..",", 1, true) then note2=4 note3=6 note4=11 note5=13 note6=17 end if string.find(",Maj11#5b9,maj11#5b9,maj11+5-9,maj11(#5b9),", ","..chord..",", 1, true) then note2=4 note3=8 note4=11 note5=13 note6=17 end if string.find(",Maj11b5#9,maj11b5#9,maj11-5+9,maj11(b5#9),", ","..chord..",", 1, true) then note2=4 note3=6 note4=11 note5=15 note6=17 end if string.find(",Maj11#5#9,maj11#5#9,maj11+5+9,maj11(#5#9),", ","..chord..",", 1, true) then note2=4 note3=8 note4=11 note5=15 note6=17 end if string.find(",13,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=14 note6=17 note7=21 end if string.find(",m13,min13,-13,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=14 note6=17 note7=21 end if string.find(",Maj13,maj13,M13,Maj7(add13),M7(add13),min,", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=14 note6=17 note7=21 end if string.find(",mMaj13,minmaj13,mM13,", ","..chord..",", 1, true) then note2=3 note3=7 note4=11 note5=14 note6=17 note7=21 end if string.find(",13b5,13-5,", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=14 note6=17 note7=21 end if string.find(",13#5,13+5,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=14 note6=17 note7=21 end if string.find(",13b9,13-9,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=13 note6=17 note7=21 end if string.find(",13#9,13+9,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=15 note6=17 note7=21 end if string.find(",13#11,13+11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=15 note6=18 note7=21 end if string.find(",13b5b9,13-5-9,", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=13 note6=17 note7=21 end if string.find(",13#5b9,13+5-9,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=13 note6=17 note7=21 end if string.find(",13b5#9,13-5+9,", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=15 note6=17 note7=21 end if string.find(",13#5#9,13+5+9,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=15 note6=17 note7=21 end if string.find(",13b9#11,13-9+11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=13 note6=18 note7=21 end if string.find(",m13b5,m13-5,", ","..chord..",", 1, true) then note2=3 note3=6 note4=10 note5=14 note6=17 note7=21 end if string.find(",m13#5,m13+5,", ","..chord..",", 1, true) then note2=3 note3=8 note4=10 note5=14 note6=17 note7=21 end if string.find(",m13b9,m13-9,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=13 note6=17 note7=21 end if string.find(",m13#9,m13+9,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=15 note6=17 note7=21 end if string.find(",m13b5b9,m13-5-9,", ","..chord..",", 1, true) then note2=3 note3=6 note4=10 note5=13 note6=17 note7=21 end if string.find(",m13#5b9,m13+5-9,", ","..chord..",", 1, true) then note2=3 note3=8 note4=10 note5=13 note6=17 note7=21 end if string.find(",m13b5#9,m13-5+9,", ","..chord..",", 1, true) then note2=3 note3=6 note4=10 note5=15 note6=17 note7=21 end if string.find(",m13#5#9,m13+5+9,", ","..chord..",", 1, true) then note2=3 note3=8 note4=10 note5=15 note6=17 note7=21 end if string.find(",Maj13b5,maj13b5,maj13-5,", ","..chord..",", 1, true) then note2=4 note3=6 note4=11 note5=14 note6=17 note7=21 end if string.find(",Maj13#5,maj13#5,maj13+5,", ","..chord..",", 1, true) then note2=4 note3=8 note4=11 note5=14 note6=17 note7=21 end if string.find(",Maj13b9,maj13b9,maj13-9,", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=13 note6=17 note7=21 end if string.find(",Maj13#9,maj13#9,maj13+9,", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=15 note6=17 note7=21 end if string.find(",Maj13b5b9,maj13b5b9,maj13-5-9,", ","..chord..",", 1, true) then note2=4 note3=6 note4=11 note5=13 note6=17 note7=21 end if string.find(",Maj13#5b9,maj13#5b9,maj13+5-9,", ","..chord..",", 1, true) then note2=4 note3=8 note4=11 note5=13 note6=17 note7=21 end if string.find(",Maj13b5#9,maj13b5#9,maj13-5+9,", ","..chord..",", 1, true) then note2=4 note3=6 note4=11 note5=15 note6=17 note7=21 end if string.find(",Maj13#5#9,maj13#5#9,maj13+5+9,", ","..chord..",", 1, true) then note2=4 note3=8 note4=11 note5=15 note6=17 note7=21 end if string.find(",Maj13#11,maj13#11,maj13+11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=14 note6=18 note7=21 end if string.find(",13#11,13+11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=14 note6=18 note7=21 end if string.find(",m13#11,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=14 note6=18 note7=21 end if string.find(",13sus4,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=14 note6=17 note7=21 end if string.find(",6,M6,Maj6,maj6,", ","..chord..",", 1, true) then note2=4 note3=7 note4=9 end if string.find(",m6,min6,", ","..chord..",", 1, true) then note2=3 note3=7 note4=9 end if string.find(",6add4,6/4,6(add4),Maj6(add4),M6(add4),", ","..chord..",", 1, true) then note2=4 note3=5 note4=7 note5=9 end if string.find(",m6add4,m6/4,m6(add4),", ","..chord..",", 1, true) then note2=3 note3=5 note4=7 note5=9 end if string.find(",69,6add9,6/9,6(add9),Maj6(add9),M6(add9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=9 note5=14 end if string.find(",m6add9,m6/9,m6(add9),", ","..chord..",", 1, true) then note2=3 note3=7 note4=9 note5=14 end if string.find(",6sus2,", ","..chord..",", 1, true) then note2=2 note3=7 note4=9 end if string.find(",6sus4,", ","..chord..",", 1, true) then note2=5 note3=7 note4=9 end if string.find(",6add11,6/11,6(add11),Maj6(add11),M6(add11),", ","..chord..",", 1, true) then note2=4 note3=7 note4=9 note5=17 end if string.find(",m6add11,m6/11,m6(add11),m6(add11),", ","..chord..",", 1, true) then note2=3 note3=7 note4=9 note5=17 end if string.find(",7,dom,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 end if string.find(",7add2,", ","..chord..",", 1, true) then note2=2 note3=4 note4=7 note5=10 end if string.find(",7add4,", ","..chord..",", 1, true) then note2=4 note3=5 note4=7 note5=10 end if string.find(",m7,min7,-7,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 end if string.find(",m7add4,", ","..chord..",", 1, true) then note2=3 note3=5 note4=7 note5=10 end if string.find(",Maj7,maj7,Maj7,M7,", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 end if string.find(",dim7,07,", ","..chord..",", 1, true) then note2=3 note3=6 note4=9 end if string.find(",mMaj7,minmaj7,mmaj7,min/maj7,mM7,m(addM7),m(+7),-(M7),", ","..chord..",", 1, true) then note2=3 note3=7 note4=11 end if string.find(",7sus2,", ","..chord..",", 1, true) then note2=2 note3=7 note4=10 end if string.find(",7sus4,7sus,7sus11,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 end if string.find(",Maj7sus2,maj7sus2,M7sus2,", ","..chord..",", 1, true) then note2=2 note3=7 note4=11 end if string.find(",Maj7sus4,maj7sus4,M7sus4,", ","..chord..",", 1, true) then note2=5 note3=7 note4=11 end if string.find(",aug7,+7,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 end if string.find(",7b5,7-5,", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 end if string.find(",7#5,7+5,7+,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 end if string.find(",m7b5,m7-5,", ","..chord..",", 1, true) then note2=3 note3=6 note4=10 end if string.find(",m7#5,m7+5,", ","..chord..",", 1, true) then note2=3 note3=8 note4=10 end if string.find(",Maj7b5,maj7b5,maj7-5,M7b5,", ","..chord..",", 1, true) then note2=4 note3=6 note4=11 end if string.find(",Maj7#5,maj7#5,maj7+5,M7+5,", ","..chord..",", 1, true) then note2=4 note3=8 note4=11 end if string.find(",7b9,7-9,7(addb9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=13 end if string.find(",7#9,7+9,7(add#9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=15 end if string.find(",m7b9, m7-9,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=13 end if string.find(",m7#9, m7+9,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=15 end if string.find(",Maj7b9,maj7b9,maj7-9,maj7(addb9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=13 end if string.find(",Maj7#9,maj7#9,maj7+9,maj7(add#9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=15 end if string.find(",7b9b13,7-9-13,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=13 note6=20 end if string.find(",m7b9b13, m7-9-13,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=13 note6=20 end if string.find(",7b13,7-13,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=14 note6=20 end if string.find(",m7b13,m7-13,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=14 note6=20 end if string.find(",7#9b13,7+9-13,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=15 note6=20 end if string.find(",m7#9b13,m7+9-13,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=15 note6=20 end if string.find(",7b5b9,7-5-9,", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=13 end if string.find(",7b5#9,7-5+9,", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=15 end if string.find(",7#5b9,7+5-9,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=13 end if string.find(",7#5#9,7+5+9,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=15 end if string.find(",7#11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=18 end if string.find(",7add6,7/6,", ","..chord..",", 1, true) then note2=4 note3=7 note4=9 note5=10 end if string.find(",7add11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=17 end if string.find(",7add13,7/13,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=21 end if string.find(",m7add11,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=17 end if string.find(",m7b5b9,m7-5-9,", ","..chord..",", 1, true) then note2=3 note3=6 note4=10 note5=13 end if string.find(",m7b5#9,m7-5+9,", ","..chord..",", 1, true) then note2=3 note3=6 note4=10 note5=15 end if string.find(",m7#5b9,m7+5-9,", ","..chord..",", 1, true) then note2=3 note3=8 note4=10 note5=13 end if string.find(",m7#5#9,m7+5+9,", ","..chord..",", 1, true) then note2=3 note3=8 note4=10 note5=15 end if string.find(",m7#11,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=18 end if string.find(",Maj7b5b9,maj7b5b9,maj7-5-9,", ","..chord..",", 1, true) then note2=4 note3=6 note4=11 note5=13 end if string.find(",Maj7b5#9,maj7b5#9,maj7-5+9,", ","..chord..",", 1, true) then note2=4 note3=6 note4=11 note5=15 end if string.find(",Maj7#5b9,maj7#5b9,maj7+5-9,", ","..chord..",", 1, true) then note2=4 note3=8 note4=11 note5=13 end if string.find(",Maj7#5#9,maj7#5#9,maj7+5+9,", ","..chord..",", 1, true) then note2=4 note3=8 note4=11 note5=15 end if string.find(",Maj7add11,maj7add11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=17 end if string.find(",Maj7#11,maj7#11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=18 end if string.find(",9,7(add9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=14 end if string.find(",m9,min9,-9,", ","..chord..",", 1, true) then note2=3 note3=7 note4=10 note5=14 end if string.find(",Maj9,maj9,M9,Maj7(add9),M7(add9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=14 end if string.find(",Maj9sus4,maj9sus4,", ","..chord..",", 1, true) then note2=5 note3=7 note4=11 note5=14 end if string.find(",mMaj9,minmaj9,mmaj9,min/maj9,mM9,m(addM9),m(+9),-(M9),", ","..chord..",", 1, true) then note2=3 note3=7 note4=11 note5=14 end if string.find(",9sus4,9sus,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=14 end if string.find(",aug9,+9,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=15 end if string.find(",9add6,9/6,", ","..chord..",", 1, true) then note2=4 note3=7 note4=9 note5=10 note6=14 end if string.find(",m9add6,m9/6,", ","..chord..",", 1, true) then note2=3 note3=7 note4=9 note5=14 end if string.find(",9b5,9-5,", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=14 end if string.find(",9#5,9+5,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=14 end if string.find(",m9b5,m9-5,", ","..chord..",", 1, true) then note2=3 note3=6 note4=10 note5=14 end if string.find(",m9#5,m9+5,", ","..chord..",", 1, true) then note2=3 note3=8 note4=10 note5=14 end if string.find(",Maj9b5,maj9b5,", ","..chord..",", 1, true) then note2=4 note3=6 note4=11 note5=14 end if string.find(",Maj9#5,maj9#5,", ","..chord..",", 1, true) then note2=4 note3=8 note4=11 note5=14 end if string.find(",Maj9#11,maj9#11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 note5=14 note6=18 end if string.find(",b9#11,-9+11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=13 note6=18 end if string.find(",add9,2,", ","..chord..",", 1, true) then note2=4 note3=7 note4=14 end if string.find(",madd9,m(add9),-(add9),", ","..chord..",", 1, true) then note2=3 note3=7 note4=14 end if string.find(",add11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=17 end if string.find(",madd11,m(add11),-(add11),", ","..chord..",", 1, true) then note2=3 note3=7 note4=17 end if string.find(",(b9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=13 end if string.find(",(#9),", ","..chord..",", 1, true) then note2=4 note3=7 note4=15 end if string.find(",(b5b9),", ","..chord..",", 1, true) then note2=4 note3=6 note4=13 end if string.find(",(#5b9),", ","..chord..",", 1, true) then note2=4 note3=8 note4=13 end if string.find(",(b5#9),", ","..chord..",", 1, true) then note2=4 note3=6 note4=15 end if string.find(",(#5#9),", ","..chord..",", 1, true) then note2=4 note3=8 note4=15 end if string.find(",m(b9), mb9,", ","..chord..",", 1, true) then note2=3 note3=7 note4=13 end if string.find(",m(#9), m#9,", ","..chord..",", 1, true) then note2=3 note3=7 note4=15 end if string.find(",m(b5b9), mb5b9,", ","..chord..",", 1, true) then note2=3 note3=6 note4=13 end if string.find(",m(#5b9), m#5b9,", ","..chord..",", 1, true) then note2=3 note3=8 note4=13 end if string.find(",m(b5#9), mb5#9,", ","..chord..",", 1, true) then note2=3 note3=6 note4=15 end if string.find(",m(#5#9), m#5#9,", ","..chord..",", 1, true) then note2=3 note3=8 note4=15 end if string.find(",m(#11), m#11,", ","..chord..",", 1, true) then note2=3 note3=7 note4=18 end if string.find(",(#11),", ","..chord..",", 1, true) then note2=4 note3=7 note4=18 end if string.find(",m#5,", ","..chord..",", 1, true) then note2=3 note3=8 end if string.find(",maug,augaddm3,augadd(m3),", ","..chord..",", 1, true) then note2=3 note3=7 note4=8 end if string.find(",13#9#11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=15 note6=18 note7=21 end if string.find(",13#11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=14 note6=18 note7=21 end if string.find(",13susb5,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 note5=14 note6=17 note7=21 end if string.find(",13susb5#9,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 note5=15 note6=21 end if string.find(",13susb5b9,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 note5=13 note6=17 note7=21 end if string.find(",13susb9,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=13 note6=17 note7=21 end if string.find(",13susb9#11,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=13 note6=18 note7=21 end if string.find(",13sus#5,", ","..chord..",", 1, true) then note2=5 note3=8 note4=10 note5=17 note6=21 end if string.find(",13sus#5b9,", ","..chord..",", 1, true) then note2=5 note3=8 note4=10 note5=13 note6=17 note7=21 end if string.find(",13sus#5b9#11,", ","..chord..",", 1, true) then note2=5 note3=8 note4=10 note5=13 note6=18 note7=21 end if string.find(",13sus#5#11,", ","..chord..",", 1, true) then note2=5 note3=8 note4=10 note5=18 end if string.find(",13sus#5#9#11,", ","..chord..",", 1, true) then note2=5 note3=8 note4=10 note5=15 note6=18 end if string.find(",13sus#9,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=15 note6=17 note7=21 end if string.find(",13sus#9#11,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=15 note6=18 note7=21 end if string.find(",13sus#11,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=14 note6=18 note7=21 end if string.find(",7b5b13,", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=17 note6=20 end if string.find(",7b5#9b13,", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=15 note6=20 end if string.find(",7#5#11,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=18 end if string.find(",7#5#9#11,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=15 note6=18 end if string.find(",7#5b9#11,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=13 note6=18 end if string.find(",7#9#11b13,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=15 note6=18 note7=20 end if string.find(",7#11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=18 end if string.find(",7#11b13,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=18 note6=20 end if string.find(",7susb5,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 end if string.find(",7susb5b9,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 note5=13 end if string.find(",7b5b9b13,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 note5=13 note6=20 end if string.find(",7susb5b13,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 note5=14 note6=20 end if string.find(",7susb5#9,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 note5=15 end if string.find(",7susb5#9b13,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 note5=15 note6=20 end if string.find(",7susb9,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=13 end if string.find(",7susb9b13,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=13 note6=20 end if string.find(",7susb9#11,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=13 note6=18 end if string.find(",7susb9#11b13,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=13 note6=18 note7=20 end if string.find(",7susb13,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=20 end if string.find(",7sus#5,", ","..chord..",", 1, true) then note2=5 note3=8 note4=10 end if string.find(",7sus#5#9#11,", ","..chord..",", 1, true) then note2=5 note3=8 note4=10 note5=15 note6=18 end if string.find(",7sus#5#11,", ","..chord..",", 1, true) then note2=5 note3=8 note4=10 note5=18 end if string.find(",7sus#9,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=15 end if string.find(",7sus#9b13,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=15 note6=20 end if string.find(",7sus#9#11b13,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=15 note6=18 note7=20 end if string.find(",7sus#11,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=18 end if string.find(",7sus#11b13,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=18 note6=20 end if string.find(",9b5b13,", ","..chord..",", 1, true) then note2=4 note3=6 note4=10 note5=14 note6=20 end if string.find(",9b13,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=14 note6=20 end if string.find(",9#5#11,", ","..chord..",", 1, true) then note2=4 note3=8 note4=10 note5=14 note6=18 end if string.find(",9#11,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=14 note6=18 end if string.find(",9#11b13,", ","..chord..",", 1, true) then note2=4 note3=7 note4=10 note5=14 note6=18 note7=20 end if string.find(",9susb5,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 note5=14 end if string.find(",9susb5b13,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 note5=14 note6=20 end if string.find(",9sus#11,", ","..chord..",", 1, true) then note2=5 note3=7 note4=10 note5=14 note6=18 end if string.find(",9susb5#9,", ","..chord..",", 1, true) then note2=5 note3=6 note4=10 note5=14 note6=15 end if string.find(",9sus#5#11,", ","..chord..",", 1, true) then note2=5 note3=8 note4=10 note5=14 note6=18 end if string.find(",quartal,", ","..chord..",", 1, true) then note2=5 note3=10 note4=15 end if string.find(",sowhat,", ","..chord..",", 1, true) then note2=5 note3=10 note4=16 end end function set_item_pitch() items = reaper.CountSelectedMediaItems() item_table = {} for i = 0, items -1 do --item = reaper.GetSelectedMediaItem(0,i) --items = items +1 table.insert(item_table,(items-i)-1) end --if string.find(",Maj7,maj7,Maj7,M7,", ","..chord..",", 1, true) then note2=4 note3=7 note4=11 end --table.insert(sel_notes, "Pitch="..pitch .. " Idx="..i) octave = 14 -- set to maximum octave note if note7+note1 > octave then note7 = note7 -12 end if note6+note1 > octave then note6 = note6 -12 end if note5+note1 > octave then note5 = note5 -12 end if note4+note1 > octave then note4 = note4 -12 end if note3+note1 > octave then note3 = note3 -12 end if note2+note1 > octave then note2 = note2 -12 end if note1 > octave then note1 = note1 -12 end notes_table = {} table.insert(notes_table,note7+note1) table.insert(notes_table,note6+note1) table.insert(notes_table,note5+note1) table.insert(notes_table,note4+note1) table.insert(notes_table,note3+note1) table.insert(notes_table,note2+note1) table.insert(notes_table,note1) notes_table1 = {} table.insert(notes_table1,note7+note1) table.insert(notes_table1,note6+note1) table.insert(notes_table1,note5+note1) table.insert(notes_table1,note4+note1) table.insert(notes_table1,note3+note1) table.insert(notes_table1,note2+note1) table.insert(notes_table1,note1) --[[ Msg("Note7 "..notes_table[7]) Msg("Note6 "..notes_table[6]) Msg("Note5 "..notes_table[5]) Msg("Note4 "..notes_table[4]) Msg("Note3 "..notes_table[3]) Msg("Note2 "..notes_table[2]) Msg("Note1 "..notes_table[1]) Msg("-----Sorted------") --]] table.sort(notes_table1) notes_table2 = {} for i = 1, 7 do table.insert(notes_table2, notes_table1[i]) end --[[ Msg("Note7 "..notes_table2[7]) Msg("Note6 "..notes_table2[6]) Msg("Note5 "..notes_table2[5]) Msg("Note4 "..notes_table2[4]) Msg("Note3 "..notes_table2[3]) Msg("Note2 "..notes_table2[2]) Msg("Note1 "..notes_table2[1]) --]] if note7 > 200 and item_table[7] then item7 = reaper.GetSelectedMediaItem(0,1 - items) reaper.SetMediaItemInfo_Value(item7, "B_MUTE", 1) reaper.UpdateItemInProject(item7) elseif note7 < 200 then item7 = reaper.GetSelectedMediaItem(0,1 - items) --Msg("7 ".. 1 - items .. " ".. notes_table2[7]) take = reaper.GetActiveTake(item7) reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',notes_table2[7]) reaper.SetMediaItemInfo_Value(item7, "B_MUTE", 0) reaper.UpdateItemInProject(item7) end if note6 > 240 and item_table[6] then item6 = reaper.GetSelectedMediaItem(0,2 - items) reaper.SetMediaItemInfo_Value(item6, "B_MUTE", 1) reaper.UpdateItemInProject(item6) elseif note6 < 200 then item6 = reaper.GetSelectedMediaItem(0,2 - items) --Msg("6 ".. 2 - items .. " ".. notes_table2[6]) take = reaper.GetActiveTake(item6) reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',notes_table2[6]) reaper.SetMediaItemInfo_Value(item6, "B_MUTE", 0) reaper.UpdateItemInProject(item6) end if note5 > 240 and item_table[5] then item5 = reaper.GetSelectedMediaItem(0,3 - items) reaper.SetMediaItemInfo_Value(item5, "B_MUTE", 1) reaper.UpdateItemInProject(item5) elseif note5 < 200 then item5 = reaper.GetSelectedMediaItem(0,3 - items) --Msg("5 ".. 3 - items .. " ".. notes_table2[5]) take = reaper.GetActiveTake(item5) reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',notes_table2[5]) reaper.SetMediaItemInfo_Value(item5, "B_MUTE", 0) reaper.UpdateItemInProject(item5) end if note4 > 240 and item_table[4] then item4 = reaper.GetSelectedMediaItem(0,4 - items) reaper.SetMediaItemInfo_Value(item4, "B_MUTE", 1) reaper.UpdateItemInProject(item4) elseif note4 < 200 then item4 = reaper.GetSelectedMediaItem(0,4 - items) --Msg("4 ".. 4 - items .. " ".. notes_table2[4]) take = reaper.GetActiveTake(item4) reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',notes_table2[4]) reaper.SetMediaItemInfo_Value(item4, "B_MUTE", 0) reaper.UpdateItemInProject(item4) end if note3 > 200 and item_table[3] then item3 = reaper.GetSelectedMediaItem(0,5 - items) reaper.SetMediaItemInfo_Value(item3, "B_MUTE", 1) reaper.UpdateItemInProject(item3) elseif note3 < 200 then item3 = reaper.GetSelectedMediaItem(0,5 - items) --Msg("3 ".. 5 - items .. " ".. notes_table2[3]) take = reaper.GetActiveTake(item3) reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',notes_table2[3]) reaper.SetMediaItemInfo_Value(item3, "B_MUTE", 0) reaper.UpdateItemInProject(item3) end if note2 > 200 and item_table[2] then item2 = reaper.GetSelectedMediaItem(0,6 - items) reaper.SetMediaItemInfo_Value(item2, "B_MUTE", 1) reaper.UpdateItemInProject(item3) elseif note2 < 200 then item2 = reaper.GetSelectedMediaItem(0,6 - items) --Msg("2 ".. 6 - items .. " ".. notes_table2[2]) take = reaper.GetActiveTake(item2) reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',notes_table2[2]) reaper.SetMediaItemInfo_Value(item2, "B_MUTE", 0) reaper.UpdateItemInProject(item2) end if note1 > 200 and item_table[1] then item1 = reaper.GetSelectedMediaItem(0,7 - items) reaper.SetMediaItemInfo_Value(item1, "B_MUTE", 1) reaper.UpdateItemInProject(item1) elseif note1 < 200 then item1 = reaper.GetSelectedMediaItem(0,7 - items) --Msg("Root ".. 7 - items .. " ".. notes_table2[1]) take = reaper.GetActiveTake(item1) reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',notes_table2[1]) reaper.SetMediaItemInfo_Value(item1, "B_MUTE", 0) reaper.UpdateItemInProject(item1) end end column_count = 0 items = reaper.CountSelectedMediaItems() if items == 0 then goto skip end reaper.Main_OnCommand(40297, 0) --Track: Unselect all tracks 40297 commandID2 = reaper.NamedCommandLookup("_SWS_SELTRKWITEM") reaper.Main_OnCommand(commandID2, 0) -- SWS: Select only track(s) with selected item(s) _SWS_SELTRKWITEM sel_tracks = reaper.CountSelectedTracks(0) columns = (items) / sel_tracks -- number of column of selected items --Msg("items ".. items .." tracks ".. sel_tracks) --Msg("Columns "..columns) reaper.Main_OnCommand(41173, 0) --Item navigation: Move cursor to start of items 41173 items_start = reaper.GetCursorPosition() reaper.Main_OnCommand(41174, 0) --Item navigation: Move cursor to end of items 41174 items_end = reaper.GetCursorPosition() reaper.SetEditCurPos(items_start +.2,0,0) reaper.Main_OnCommand(40289, 0) -- Item: Unselect all items commandID2 = reaper.NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") reaper.Main_OnCommand(commandID2, 0) --Xenakios/SWS: Select items under edit cursor on selected tracks _XENAKIOS_SELITEMSUNDEDCURSELTX cur_pos = reaper.GetCursorPosition() markeridx, chord_region = reaper.GetLastMarkerAndCurRegion(0, cur_pos) retval, isrgnOut, region_pos, region_end, region_name, region_index, region_color = reaper.EnumProjectMarkers3(0, chord_region) get_chord_notes(chord_region) set_item_pitch() for i = 1, columns -1 do reaper.Main_OnCommand(40289, 0) -- Item: Unselect all items reaper.Main_OnCommand(40417, 0) --Item navigation: Select and move to next item 40417 cur_pos = reaper.GetCursorPosition() reaper.SetEditCurPos(cur_pos +.2,0,0) commandID2 = reaper.NamedCommandLookup("_XENAKIOS_SELITEMSUNDEDCURSELTX") reaper.Main_OnCommand(commandID2, 0) --Xenakios/SWS: Select items under edit cursor on selected tracks _XENAKIOS_SELITEMSUNDEDCURSELTX cur_pos = reaper.GetCursorPosition() markeridx, chord_region = reaper.GetLastMarkerAndCurRegion(0, cur_pos) retval, isrgnOut, region_pos, region_end, region_name, region_index, region_color = reaper.EnumProjectMarkers3(0, chord_region) get_chord_notes(chord_region) set_item_pitch() end ::skip::