Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 07-09-2020, 04:59 PM   #1
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default Build scales depending on region name[SOLVED]thanks MusoBob

Hello, maybe my last script request
I have modified and reduced(clarity) a script from MusoBob to generate scales depending on the region.

What I'm missing is:
1. If the number of items exceeds the number of scale tones within a region, the scale should then go on.
Example A(Cmaj7): 0,2,4,5,7,9,11,12,14,16,17,19,21,23,24,26 .....
Example B(C pentatonic): 0,2,4,7,9,12,14,16,19,21,24,26 .....

2.If the selected items are in 2 different regions, the appropriate scale should start again in the respective region.

many thanks

Code:
-- 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)
  
end

  
function get_chord_notes(chord_region)  

    retval, isrgn, region_pos, region_end, region_name, region_index, region_color = reaper.EnumProjectMarkers3( 0, chord_region)
     
  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

     
     if not chord or #chord == 0 then chord = "Maj" end
     if not slash then slash = "" end
  

  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
  


  if string.find(",Maj,M,", ","..chord..",", 1, true) then note2=2  note3=4  note4=5  note5=7  note6=9  note7=11 note8=12 end 
  if string.find(",m,min,", ","..chord..",", 1, true) then note2=2  note3=3  note4=5  note5=7  note6=9  note7=11 note8=12 end 
  if string.find(",7,dom,", ","..chord..",", 1, true) then note2=2  note3=4  note4=5  note5=7  note6=9  note7=10 note8=12 end 
  if string.find(",m7,min7,-7,", ","..chord..",", 1, true) then note2=2  note3=3  note4=5  note5=7  note6=9  note7=10 note8=12 end 
  if string.find(",Maj7,maj7,Maj7,M7,", ","..chord..",", 1, true) then note2=2  note3=4  note4=5  note5=7  note6=9  note7=11 note8=12 end 
  
end

--MAIN---------------------------------------------------------------
function main()

  commandID2 = reaper.NamedCommandLookup("_SWS_SELTRKWITEM")
  reaper.Main_OnCommand(commandID2, 0) -- SWS: Select only track(s) with selected item(s) _SWS_SELTRKWITEM

  items = reaper.CountMediaItems(0)
  
  sel_tracks = reaper.CountSelectedMediaItems(0)
  
  for i = 0, sel_tracks -1  do
  
  
   track =  reaper.GetSelectedMediaItem( 0,(sel_tracks-1)-i)
  
    track_number =  reaper.GetMediaItemInfo_Value(track, "IP_ITEMNUMBER" )
     
    retval, num_markers, num_regions = reaper.CountProjectMarkers(0)

    for r = 0, num_regions -1 do -- regions loop start    
    
      retval, isrgn, pos, rgnend, name, markrgnindexnumber, color = reaper.EnumProjectMarkers3( 0, r )
      
      for i = 0, items -1 do -- items loop start
       
       media_item = reaper.GetMediaItem( 0, i )
       
       selected_item = reaper.IsMediaItemSelected(media_item) 
       
       if selected_item then
       
        current_item = reaper.GetMediaItem( 0, i )
      
        item_start = reaper.GetMediaItemInfo_Value( current_item, "D_POSITION")
        
        --Does item start within region
        
        if item_start >= pos and item_start < rgnend then 
          --Msg("r "..r)
          --Msg("markrgnindexnumber ".. markrgnindexnumber)
          get_chord_notes(r) -- get the chord notes for current region
          

          item0 =  reaper.GetSelectedMediaItem(0, 0 )
          take0 = reaper.GetActiveTake(item0)
          reaper.SetMediaItemTakeInfo_Value(take0, 'D_PITCH',note1) 
          reaper.UpdateItemInProject(item0)
     
          
           item1 = reaper.GetSelectedMediaItem(0, 1 )
           take1 = reaper.GetActiveTake(item1)
           reaper.SetMediaItemTakeInfo_Value(take1, 'D_PITCH',note1+note2) 
           reaper.UpdateItemInProject(item1)
           
          item2 =  reaper.GetSelectedMediaItem(0, 2 )
          take2 = reaper.GetActiveTake(item2)
          reaper.SetMediaItemTakeInfo_Value(take2, 'D_PITCH',note1+note3) 
          reaper.UpdateItemInProject(item2)
     
          
           item3 = reaper.GetSelectedMediaItem(0, 3 )
           take3 = reaper.GetActiveTake(item3)
           reaper.SetMediaItemTakeInfo_Value(take3, 'D_PITCH',note1+note4) 
           reaper.UpdateItemInProject(item3)
           
          item4 =  reaper.GetSelectedMediaItem(0, 4 )
          take4 = reaper.GetActiveTake(item4)
          reaper.SetMediaItemTakeInfo_Value(take4, 'D_PITCH',note1+note5) 
          reaper.UpdateItemInProject(item4)
     
           
           item5 = reaper.GetSelectedMediaItem(0, 5 )
           take5 = reaper.GetActiveTake(item5)
           reaper.SetMediaItemTakeInfo_Value(take5, 'D_PITCH',note1+note6) 
           reaper.UpdateItemInProject(item5)
           
          item6 =  reaper.GetSelectedMediaItem(0, 6 )
          take6 = reaper.GetActiveTake(item6)
          reaper.SetMediaItemTakeInfo_Value(take6, 'D_PITCH',note1+note7) 
          reaper.UpdateItemInProject(item6) 
     
          
           item7 = reaper.GetSelectedMediaItem(0, 7 )
           take7 = reaper.GetActiveTake(item7)
           reaper.SetMediaItemTakeInfo_Value(take7, 'D_PITCH',note1+note8) 
           reaper.UpdateItemInProject(item7)
          
        end
       end
      end -- items loop end
    end -- regions loop end
  end
  end  

  
main()  
  
reaper.Main_OnCommand(40297,0) -- unselect all tracks  


::skip::

Last edited by Dragonetti; 07-24-2020 at 06:41 AM.
Dragonetti is offline   Reply With Quote
Old 07-10-2020, 03:20 AM   #2
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Are you just doing one track at a time ?
and the scale keeps going up in octaves ?
so if there are 36 items on the one track in the chord region it will just keep going up ?
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 07-10-2020, 06:20 AM   #3
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Hi MusoBob
thank you for helping here

1. if several tracks go at the same time would be awesome. of course only selected items.

2. yes, even with 36 items with the octaves to the "infinite"(48)

another additional function. Is that possible?(two extra scripts)
3. The whole scale is shifted one note, I'm going to make a GIF.

you quickly created a scale with the appropriate thirds

Last edited by Dragonetti; 07-10-2020 at 02:47 PM.
Dragonetti is offline   Reply With Quote
Old 07-14-2020, 10:04 PM   #4
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Try this
set selected notes to scale from region chord.lua
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 07-15-2020, 03:11 AM   #5
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Thank you very much MusoBob.
So far it works quite well.
I showed 4 small bugs in the GIF.
I can no longer upload anything to reaper stash.
No idea why.
The whole script should only work with one track, this is clearer.
I once selected items from 2 tracks, then reaper crashes.
https://imgur.com/a/ha1wcyl
Dragonetti is offline   Reply With Quote
Old 07-15-2020, 04:17 AM   #6
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

You were using the chord script but I think there would be an easier way of doing it, I will look at it tomorrow.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 07-17-2020, 03:59 AM   #7
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

See what this is doing, I'll look at it more tomorrow as it's not deselecting the last item.
set selected notes to scale from region chord 2.lua
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 07-17-2020, 12:52 PM   #8
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

I am currently on the road and can unfortunately only test the script on Sunday evening, thank you in advance
Dragonetti is offline   Reply With Quote
Old 07-19-2020, 12:54 PM   #9
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

@MusoBob thank you very much, everything works fine except for one case,
if the item selection has gaps.
Dragonetti is offline   Reply With Quote
Old 07-19-2020, 08:13 PM   #10
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Try this
set selected notes to scale from region chord 3.lua
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 07-20-2020, 03:40 AM   #11
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

madness -- works great
thank you again.
I hope it's not outrageous to ask for another feature.
Is it possible to move selected items to a next or previous position on the corresponding scale.

gif example C major
Arrow to the right:
if selected item pitch == note4 (+5.00) then
new pitch is note5 (+7.00)
Left arrow:
if selected item pitch == note4 (+5.00) then
new pitch is note3 (+4.00)


--------
You could quickly generate a third, fifth or any interval for a phrase.

I think I don't need more features anymore.
Thank you

Last edited by Dragonetti; 07-20-2020 at 09:13 AM.
Dragonetti is offline   Reply With Quote
Old 07-21-2020, 02:50 PM   #12
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

It can be done but there would be a lot of variables unless I can think of a simpler way ?

Code:
      for i = 0, reg_item_count do -- set items loop start
        
        retval, isrgn, pos, rgnend, name, markrgnindexnumber, color = reaper.EnumProjectMarkers3( 0, region_num )

        sel_item = reaper.GetSelectedMediaItem(0, i )
        if not sel_item then break end
        item_start = reaper.GetMediaItemInfo_Value( sel_item, "D_POSITION")
        if item_start >= rgnend then break end
        sel_take = reaper.GetActiveTake(sel_item)
          
        item_pitch = reaper.GetMediaItemTakeInfo_Value(sel_take, 'D_PITCH')

        --CMaj
        if string.find(",Maj,M,", ","..chord..",", 1, true) and note1 == 0 then
          if item_pitch == 0 then new_pitch = note2 
          if item_pitch == 2 then new_pitch = note3
          if item_pitch == 4 then new_pitch = note4
          if item_pitch == 5 then new_pitch = note5
          ~~~~~
          ~~~~~
          if item_pitch == 12 then new_pitch = 12+note2
          if item_pitch == 14 then new_pitch = 12+note3
          if item_pitch == 16 then new_pitch = 12+note4
          if item_pitch == 17 then new_pitch = 12+note5
          ~~~~~
          ~~~~~
       end
           

       reaper.SetMediaItemTakeInfo_Value(take0, 'D_PITCH',new_pitch)
       reaper.UpdateItemInProject(sel_item)
     end -- items loop end
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 07-22-2020, 09:01 AM   #13
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

maybe you can somehow integrate "note 1" like this?
I only have 7 scales so far

Code:
                --CMaj
                if string.find(",Maj,M,", ","..chord..",", 1, true) then
                if item_pitch-note1 ==  0 then new_pitch = note2+note1 
                if item_pitch-note1 ==  2 then new_pitch = note3+note1
                if item_pitch-note1 ==  4 then new_pitch = note4+note1
                if item_pitch-note1 ==  5 then new_pitch = note5+note1
                if item_pitch-note1 ==  7 then new_pitch = note6+note1
                if item_pitch-note1 ==  9 then new_pitch = note7+note1
                if item_pitch-note1 == 11 then new_pitch = note1+note1+12
                if item_pitch-note1 == 12 then new_pitch = note2+note1+12
                if item_pitch-note1 == 14 then new_pitch = note3+note1+12
                if item_pitch-note1 == 16 then new_pitch = note4+note1+12
                if item_pitch-note1 == 17 then new_pitch = note5+note1+12
                if item_pitch-note1 == 19 then new_pitch = note6+note1+12
                if item_pitch-note1 == 21 then new_pitch = note7+note1+12
                if item_pitch-note1 == 23 then new_pitch = note1+note1+24
                if item_pitch-note1 == 24 then new_pitch = note2+note1+24
                if item_pitch-note1 == 26 then new_pitch = note3+note1+24
                if item_pitch-note1 == 28 then new_pitch = note4+note1+24
                if item_pitch-note1 == 29 then new_pitch = note5+note1+24
                if item_pitch-note1 == 31 then new_pitch = note6+note1+24
                if item_pitch-note1 == 33 then new_pitch = note7+note1+24
                if item_pitch-note1 == 35 then new_pitch = note1+note1+36
                if item_pitch-note1 == 36 then new_pitch = note2+note1+36
                if item_pitch-note1 == 38 then new_pitch = note3+note1+36
                if item_pitch-note1 == 40 then new_pitch = note4+note1+36
                if item_pitch-note1 == 41 then new_pitch = note5+note1+36
                if item_pitch-note1 == 43 then new_pitch = note6+note1+36
                if item_pitch-note1 == 45 then new_pitch = note7+note1+36
                if item_pitch-note1 == 47 then new_pitch = note1+note1+48
                if item_pitch-note1 == 48 then new_pitch = note2+note1+48
Dragonetti is offline   Reply With Quote
Old 07-22-2020, 01:09 PM   #14
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

You should be able to have a scale table
Maj = {0,2,4,5,7,9,11,14,16,17,......}

then just loop the one line

if item_pitch-note1 == Maj[i] then new_pitch = Maj[i+1]
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 07-22-2020, 02:56 PM   #15
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Can I take minus values there?
Code:
Maj = {-24,-22,-20,-19,-17,-15,-13,-12,-10,-8,-7,-5,-3,-1,0,2,4,5,7,9,11,12,14,16,17,19,21,23,24,26,28,29,31,33,35,36,38,40,41,43,45,47,48}

Last edited by Dragonetti; 07-22-2020 at 03:04 PM.
Dragonetti is offline   Reply With Quote
Old 07-22-2020, 10:08 PM   #16
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

This should take the note up to the next scale note
if item_pitch-note1 == Maj[i] then new_pitch = Maj[i+1]

This should take the note down to the next scale note
if item_pitch-note1 == Maj[i] then new_pitch = Maj[i-1]

If you want to take the scale notes down 2 octaves
Code:
Maj = {-24,-22,-20,-19,-17,-15,-13,-12,-10,-8,-7,-5,-3,-1,0,2,4,5,7,9,11,12,14,16,17,19,21,23,24,26,28,29,31,33,35,36,38,40,41,43,45,47,48}
So in your table position Maj[15] will = 0 in the scale table

if item_pitch-note1 == Maj[15] *(pitch 0)* then new_pitch = Maj[15-1] *(14) = pitch -1*

if item_pitch-note1 == Maj[5] *(pitch -17)* then new_pitch = Maj[5-1] *(4) = pitch -19*

So you loop through each selected item to check what pitch it is then set the new pitch
for i = 1, 43 do

I think that's right ? I'll look more at it later.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 07-23-2020, 03:06 AM   #17
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

all right
table position Ionian[29] will = 0 in the scale table
These scales should be enough for now.
Code:
Ionian     = {-48,-46,-44,-43,-41,-39,-37,-36,-34,-32,-31,-29,-27,-25,-24,-22,-20,-19,-17,-15,-13,-12,-10,-8,-7,-5,-3,-1,0,2,4,5,7,9,11,12,14,16,17,19,21,23,24,26,28,29,31,33,35,36,38,40,41,43,45,47,48}
Dorian     = {-48,-46,-45,-43,-41,-39,-38,-36,-34,-33,-31,-29,-27,-26,-24,-22,-21,-19,-17,-15,-14,-12,-10,-9,-7,-5,-3,-2,0,2,3,5,7,9,10,12,14,15,17,19,21,22,24,26,27,29,31,33,34,36,38,39,41,43,45,46,48}
Phrygian   = {-48,-47,-45,-43,-41,-40,-38,-36,-35,-33,-31,-29,-28,-26,-24,-23,-21,-19,-17,-16,-14,-12,-11,-9,-7,-5,-4,-2,0,1,3,5,7,8,10,12,13,15,17,19,20,22,24,25,27,29,31,32,34,36,37,39,41,43,44,46,48}
Lydian     = {-48,-46,-44,-42,-41,-39,-37,-36,-34,-32,-30,-29,-27,-25,-24,-22,-20,-18,-17,-15,-13,-12,-10,-8,-6,-5,-3,-1,0,2,4,6,7,9,11,12,14,16,18,19,21,23,24,26,28,30,31,33,35,36,38,40,42,43,45,47,48}
Mixolydian = {-48,-46,-44,-43,-41,-39,-38,-36,-34,-32,-31,-29,-27,-26,-24,-22,-20,-19,-17,-15,-14,-12,-10,-8,-7,-5,-3,-2,0,2,4,5,7,9,10,12,14,16,17,19,21,22,24,26,28,29,31,33,34,36,38,40,41,43,45,46,48}
Aeolian    = {-48,-46,-45,-43,-41,-40,-38,-36,-34,-33,-31,-29,-28,-26,-24,-22,-21,-19,-17,-16,-14,-12,-10,-9,-7,-5,-4,-2,0,2,3,5,7,8,10,12,14,15,17,19,20,22,24,26,27,29,31,32,34,36,38,39,41,43,44,46,48}
Locrian    = {-48,-47,-45,-43,-42,-40,-38,-36,-35,-33,-31,-30,-28,-26,-24,-23,-21,-19,-18,-16,-14,-12,-11,-9,-7,-6,-4,-2,0,1,3,5,6,8,10,12,13,15,17,18,21,22,24,25,27,29,30,32,34,36,37,39,41,42,44,46,48}
Code:
    if string.find(",Maj7,maj7,Maj7,Maj,M,M7,", ","..chord..",", 1, true) then note2=2  note3=4  note4=5  note5=7  note6=9  note7=11  end -- Ionian 
    if string.find(",m7,min7,-7,", ","..chord..",", 1, true)              then note2=2  note3=3  note4=5  note5=7  note6=9  note7=10  end -- Dorian
    if string.find(",m7b9,", ","..chord..",", 1, true)                    then note2=1  note3=3  note4=5  note5=7  note6=8  note7=10  end -- Phrygian
    if string.find(",maj7#11,maj#11,", ","..chord..",", 1, true)          then note2=2  note3=4  note4=6  note5=7  note6=9  note7=11  end -- Lydian
    if string.find(",7,dom,9,13,", ","..chord..",", 1, true)              then note2=2  note3=4  note4=5  note5=7  note6=9  note7=10  end -- Mixolydian
    if string.find(",m,min,", ","..chord..",", 1, true)                   then note2=2  note3=3  note4=5  note5=7  note6=8  note7=10  end -- Aeolian
    if string.find(",m7b5b9,m7-5-9,", ","..chord..",", 1, true)           then note2=1  note3=3  note4=5  note5=6  note6=8  note7=10  end -- Locrian
Dragonetti is offline   Reply With Quote
Old 07-23-2020, 04:22 AM   #18
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

You can add "scale = Ionian"
Code:
if string.find(",Maj7,maj7,Maj7,Maj,M,M7,", ","..chord..",", 1, true) then note2=2  note3=4  note4=5  note5=7  note6=9  note7=11  scale = Ionian end -- Ionian
then use
Code:
scale{i}
Are you making the rest of the script or did you need me to do it ?
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 07-23-2020, 06:06 AM   #19
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Unfortunately I'm not far enough in scripting.
Maybe you can help me again.
Thanks
Dragonetti is offline   Reply With Quote
Old 07-23-2020, 06:17 PM   #20
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Try these
set selected items to next scale note.lua
set selected items to previous scale note.lua
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 07-24-2020, 06:40 AM   #21
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default


absolutely awesome.
That's really fun.
Thank you MusoBob
Dragonetti is offline   Reply With Quote
Old 07-31-2020, 06:36 PM   #22
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Not sure what this script does exactly but you may be able to use or modify it
https://forum.cockos.com/showthread.php?t=240604
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 08-02-2020, 04:06 AM   #23
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

I don't know how to install them and what they can actually do.
For me at the moment only audio items manipulation are interesting
Dragonetti is offline   Reply With Quote
Old 08-02-2020, 05:31 AM   #24
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

@MusoBob
how do I get this "if" integrated:
if a pitch value does not belong to the scale, it should be increased by 1
Code:
if item_pitch-note1 ~= scale[s] then 
     new_pitch = item_pitch+1 --increase existing pitch value by 1 
    reaper.SetMediaItemTakeInfo_Value(sel_take, 'D_PITCH',new_pitch)
     reaper.UpdateItemInProject(sel_item)
Dragonetti is offline   Reply With Quote
Old 08-02-2020, 12:32 PM   #25
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Highlight the same section and paste this over and see if it works.
This is for set selected items to next scale note.lua
Code:
      get_chord_notes(item_region)
      
      match=0
    
      for s = 1, 57 do
      
        if not sel_item then break end
        sel_take = reaper.GetActiveTake(sel_item)
        item_pitch = reaper.GetMediaItemTakeInfo_Value(sel_take, 'D_PITCH')          
        
        if item_pitch-note1 == scale[s] then
          match=1
          new_pitch = scale[s+1]+note1 --new_pitch = scale[s+1]
          reaper.SetMediaItemTakeInfo_Value(sel_take, 'D_PITCH',new_pitch)
          reaper.UpdateItemInProject(sel_item)
          break
        end
        
      end
      
      if match==0 then
        new_pitch = item_pitch+1
        reaper.SetMediaItemTakeInfo_Value(sel_take, 'D_PITCH',new_pitch)
        reaper.UpdateItemInProject(sel_item)
      end
    end      

::finish::  
end
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 08-02-2020, 03:27 PM   #26
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

somehow nothing happens
Dragonetti is offline   Reply With Quote
Old 08-02-2020, 03:48 PM   #27
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

This is what I get:



__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 08-02-2020, 03:57 PM   #28
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

I didn't keep the "main ()".
Now everything works.
Thank you
Dragonetti is offline   Reply With Quote
Old 08-02-2020, 05:05 PM   #29
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Cool, I updated the scripts in the links.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 08-02-2020, 05:15 PM   #30
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

with previouse I would use -1, then you can transpose better
Dragonetti is offline   Reply With Quote
Old 08-02-2020, 05:41 PM   #31
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Yes that's what I have
Code:
      if match==0 then
        new_pitch = item_pitch-1
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 08-10-2020, 11:25 AM   #32
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

https://stash.reaper.fm/42343/scale_builder.lua

Last edited by Dragonetti; 07-02-2021 at 07:43 AM.
Dragonetti 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 01:23 AM.


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