Old 07-14-2018, 04:07 PM   #1
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default Q: Get Selected MIDI Notes Lowest to Highest

In the below script 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_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.

Download:
selected-notes-to-chord-name.zip
MusoBob is offline   Reply With Quote
Old 07-14-2018, 06:08 PM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Short answer: Store the table with the original pitches intact, sort it using table.sort(t), done.

Fixed, changes are commented (Ctrl+F for "CHANGE"), prettied up the messages a bit, added a couple of error messages for missing MIDI editor/take: https://www.dropbox.com/s/nfhrqsit9g...order.lua?dl=1
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 07-14-2018, 09:16 PM   #3
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Thanks !!!
Just trying to add a Reascale to the bottom.
Just need to convert the notenums into an array for Cnotes to give a chord Reascale
--Cnotes = {0,4,7,10}

Code:
--Convert Chord to Reascale

x1=1
x2=0
x3=0
x4=0
x5=0
x6=0
x7=0
x8=0
x9=0
x10=0
x11=0
x12=0




--Cnotes = {0, 4, 7, 10}

  if Cnotes[2] == 1 then x2=2
  elseif Cnotes[2] == 2 then x3=2
  elseif Cnotes[2] == 3 then x4=3
  elseif Cnotes[2] == 4 then x5=3
  elseif Cnotes[2] == 5 then x6=4
  elseif Cnotes[2] == 6 then x7=5
  elseif Cnotes[2] == 7 then x8=5
  elseif Cnotes[2] == 8 then x9=6
  elseif Cnotes[2] == 9 then x10=6
  elseif Cnotes[2] == 10 then x11=7
  elseif Cnotes[2] == 11 then x12=7
  elseif Cnotes[2] == 13 then x2=9
  elseif Cnotes[2] == 14 then x3=9
  elseif Cnotes[2] == 15 then x4=9
  elseif Cnotes[2] == 16 then x5=9
  elseif Cnotes[2] == 17 then x6="B"
  elseif Cnotes[2] == 18 then x7="B"

  end
  
  if Cnotes[3] == 3 then x4=3 
  elseif Cnotes[3] == 4 then x5=3
  elseif Cnotes[3] == 5 then x6=4
  elseif Cnotes[3] == 6 then x7=5
  elseif Cnotes[3] == 7 then x8=5
  elseif Cnotes[3] == 8 then x9=6
  elseif Cnotes[3] == 9 then x10=6
  elseif Cnotes[3] == 10 then x11=7
  elseif Cnotes[3] == 11 then x12=7
  elseif Cnotes[3] == 13 then x2=9
  elseif Cnotes[3] == 14 then x3=9
  elseif Cnotes[3] == 15 then x4=9
  elseif Cnotes[3] == 16 then x5=9
  elseif Cnotes[3] == 17 then x6="B"
  elseif Cnotes[3] == 18 then x7="B"

  end
  
  if Cnotes[4] == 5 then x6=4
  elseif Cnotes[4] == 6 then x7=5
  elseif Cnotes[4] == 7 then x8=5
  elseif Cnotes[4] == 8 then x9=6
  elseif Cnotes[4] == 9 then x10=6
  elseif Cnotes[4] == 10 then x11=7
  elseif Cnotes[4] == 11 then x12=7
  elseif Cnotes[4] == 13 then x2=9
  elseif Cnotes[4] == 14 then x3=9
  elseif Cnotes[4] == 15 then x4=9
  elseif Cnotes[4] == 16 then x5=9
  elseif Cnotes[4] == 17 then x6="B"
  elseif Cnotes[4] == 18 then x7="B"  
  elseif Cnotes[4] == 19 then x8="B"
  elseif Cnotes[4] == 20 then x9="B"
  elseif Cnotes[4] == 21 then x10="D"
  elseif Cnotes[4] == 22 then x11="D"
  elseif Cnotes[4] == 23 then x12="D"
   
  end  


  if Cnotes[5] == 6 then x7=5 
  elseif Cnotes[5] == 7 then x8=5
  elseif Cnotes[5] == 8 then x9=6
  elseif Cnotes[5] == 9 then x10=6
  elseif Cnotes[5] == 10 then x11=7
  elseif Cnotes[5] == 11 then x12=7
  elseif Cnotes[5] == 13 then x2=9
  elseif Cnotes[5] == 14 then x3=9
  elseif Cnotes[5] == 15 then x4=9
  elseif Cnotes[5] == 16 then x5=9
  elseif Cnotes[5] == 17 then x6="B"
  elseif Cnotes[5] == 18 then x7="B"
  elseif Cnotes[5] == 19 then x8="B"
  elseif Cnotes[5] == 20 then x9="B"
  elseif Cnotes[5] == 21 then x10="D"
  elseif Cnotes[5] == 22 then x11="D"
  elseif Cnotes[5] == 23 then x12="D"
  
  end  


  
  if Cnotes[6] == 7 then x8=6
  elseif Cnotes[6] == 8 then x9=6
  elseif Cnotes[6] == 9 then x10=6
  elseif Cnotes[6] == 10 then x11=7
  elseif Cnotes[6] == 11 then x12=7
  elseif Cnotes[6] == 13 then x2=9
  elseif Cnotes[6] == 14 then x3=9
  elseif Cnotes[6] == 15 then x4=9
  elseif Cnotes[6] == 16 then x5=9
  elseif Cnotes[6] == 17 then x6="B"
  elseif Cnotes[6] == 18 then x7="B"
  elseif Cnotes[6] == 19 then x8="B"
  elseif Cnotes[6] == 20 then x9="B"
  elseif Cnotes[6] == 21 then x10="D"
  elseif Cnotes[6] == 22 then x11="D"
  elseif Cnotes[6] == 23 then x12="D"
  
  end   


  if Cnotes[7] == 7 then x8=7
  elseif Cnotes[7] == 8 then x9=7
  elseif Cnotes[7] == 9 then x10=7
  elseif Cnotes[7] == 10 then x11=7
  elseif Cnotes[7] == 11 then x12=7
  elseif Cnotes[7] == 13 then x2=9
  elseif Cnotes[7] == 14 then x3=9
  elseif Cnotes[7] == 15 then x4=9
  elseif Cnotes[7] == 16 then x5=9
  elseif Cnotes[7] == 17 then x6="B"
  elseif Cnotes[7] == 18 then x7="B"
  elseif Cnotes[7] == 19 then x8="B"
  elseif Cnotes[7] == 20 then x9="B"
  elseif Cnotes[7] == 21 then x10="D"
  elseif Cnotes[7] == 22 then x11="D"
  elseif Cnotes[7] == 23 then x12="D"
  
  end   


reascale = (x1 .. x2 .. x3 .. x4 .. x5 .. x6 .. x7 .. x8 .. x9 .. x10 .. x11 .. x12)

if Cnotes[3] == nil then Cnotes[3] = 0 end
if Cnotes[4] == nil then Cnotes[4] = 0 end
if Cnotes[5] == nil then Cnotes[5] = 0 end
if Cnotes[6] == nil then Cnotes[6] = 0 end
if Cnotes[7] == nil then Cnotes[7] = 0 end


Msg("Reascale:" .. reascale)
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 11:31 PM.


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