Old 07-08-2018, 03:28 PM   #1
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default Get Notes Above Root from MIDI Chords

I have a lot of guitar voicing chords and need to convert them to notes from root 0 eg. marker name: Maj11b9 = 0,4,7,11,13,17
I can split the chords into separate items if it would be easier.
I don't want to have do them all manually.



Attached Images
File Type: png Reaper_Midi_Guitar_Chord_Voicing-2.png (36.3 KB, 587 views)
MusoBob is offline   Reply With Quote
Old 07-12-2018, 03:17 PM   #2
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

I can get the selected chord notes with Script: Mordi_Search selected notes in chord finder.lua
C, E, G, A#, D, F, A

(C13 chord)
then I need to convert them to
0,4,7,10,14,17,21

eg. for a C chord 0C 1C# 2D 3D# 4E 5F 6F# 7G 8G# 9A 10A# 11B 12C 13C# 14D 15D# 16E 17F 18F# 19G 20G# 21A 22A# 23B


If I get it working I can link it to my chord data that's in this format.
chord = "13", notes = 0,4,7,10,14,17,21

I have a bit of code working to give me the pos but maybe there is something ready made to give me this from the notes ???

Code:
      local Croot= {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}
      local Csroot= {"C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C"}
      local Droot= {"D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B", "C","C#"}
      local index={} 
      for k,v in pairs(Croot) do
         index[v]=k
      end
      note1 = index["D#"]
      note2 = note1 -1
      Msg(note2)

Last edited by MusoBob; 07-12-2018 at 07:26 PM.
MusoBob is offline   Reply With Quote
Old 07-13-2018, 01:33 AM   #3
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

This works:


Code:
local function notes2nums(input)
  local map = {A = 9, ["A#"] = 10, B = 11, C = 0, ["C#"] = 1, D = 2, ["D#"] = 3, E = 4, F = 5, ["F#"] = 6, G = 7, ["G#"] = 8}
  local base, prev
  return (input:gsub("([^,]+)", function(note)
        local num = map[note]
        base = base or num
        num = num - base
        if prev and num < prev then num = num + 12 end
        prev = num
        return tostring(num)
      end))
end
Msg(notes2nums("D,F#,A"))
Msg(notes2nums("C,E,G,A#,D,F,A"))
Msg(notes2nums("G#,B,D#,F#,B"))
MusoBob is offline   Reply With Quote
Old 07-14-2018, 01:44 AM   #4
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

I got it working to identify local chord names from notes (still got to add more chords).

But, when it counts the selected notes it's not always in the correct order, lowest to highest, like when you have a natural followed by a sharp, the below Msg() should be 48,52,56,57,58 > C,E,G#,A,A# then Note numbers will be 0,4,8,9,10 . The note numbers are working correctly just the note order in wrong:
1
48
2
52
3
56
4
58
5
57
Root
C,
Chord notes:
C,E,G#,A#,A
Note numbers:
0,4,8,10,21
Chord:
C13#5


This is the modified Script: Mordi_Search selected notes in chord finder.lua
to work locally from chord a list.
The original script does not list notes in the correct order either.
Attached Files
File Type: zip selected-notes-to-chord-name.zip (2.9 KB, 100 views)
MusoBob is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:08 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.