New Tool: (3.1) Group Nudge (Sep 2018)


(Ledger) #1

New alpha

A simple tool to help extend group tracks leftwards.

Made as I got fed up with dragging multiple tracks into groups, as when creating a large LFO sidechain group.

NOTE: track order should be preserved with this. Let me know if anything starts going out of place.


Shortcut Group Nudge

Menu: Tools: Ledger`s Scripts: Group Nudge

Menu: Pattern Editor: Group : Group Nudge


-Choose target group track from the popup

-nudge its left border with [<<] and [>>] buttons

-Bonus buttons to bypass / enable all DSPs in the selected group for A/B.

post-428-0-06520600-1536081992.png

8237 ledger.scripts.GroupNudge_V0.3.xrnx



Recommended companion tool, originally done by Cas:

Group Selected Tracks:

https://forum.renoise.com/t/new-tool-2-8-selected-tracks-to-group/36264




SCRIPTING NOTE:

Thread where API swap_tracks() bug is reported/ discussed:

https://forum.renoise.com/t/lua-api-bug-swap-tracks/49534

The function used as a workaround:

Click to view contents
--extend left border of group leftwards by one track
    ---------------------------------------  
    function extend_group_left(group_index)  
    ---------------------------------------
      
      local song = renoise.song()
      local group_track = song:track(group_index)
     
      --get the index of the track to the left of the group. This is the track we want to add to the group
      local left_of_grp_idx = (group_index - #group_track.members - 1) 
      
      --if left_of_grp_idx == 0 then there are no more tracks to the left so return early 
      if left_of_grp_idx == 0 then 
        return
      end
      
      --if group has no members already, then it is a simple add track to group operation and
      --no re-organisation is needed
      if #group_track.members == 0 then
        song:add_track_to_group(left_of_grp_idx,group_index)
        return
      end
      
      --1) Add 2 dummy tracks into group
      ----------------------------------
      --NOTE We need to insert 2 dummy tracks to account for bugs with the renoise swap tracks behaviour within groups
      --see: https://forum.renoise.com/t/lua-api-bug-swap-tracks/49534
      
      --set member_idx to the first member track of the group
      local member_idx = left_of_grp_idx + 1
     
      --loop group members to find insert point for dummy tracks (after first legitimate member; i.e. not a track in a further sub-group)
      for i = 1,#group_track.members do
        --check if member is not in a sub group by checking its parent
        if rawequal(song:track(member_idx).group_parent,group_track) == true then
          break
        end
        --if here then member was in a sub- group so increment member_idx until we get to a legitimate track
        member_idx = member_idx + 1
      end
      
      --again due to insert_track behaviour we need to insert the dummy tracks after the first present and legitimate member of the group
      --so + 1
      local insert_point = member_idx + 1
      
      --insert 2 dummy tracks at member_idx 
      local dummy_trk_2 = song:insert_track_at(insert_point)
      local dummy_trk_1 = song:insert_track_at(insert_point)
      
      --name the tracks for bug hunting i.e. if they are not deleted we will see them in pattern ed
      dummy_trk_1.name = "Dummy Track 1"
      dummy_trk_2.name = "Dummy Track 2"
      
      --2) Swap Dummy tracks to members 1 and 2 of group (this works re. the swap bug as we are not swapping two groups)
      song:swap_tracks_at(member_idx,member_idx+1)
      song:swap_tracks_at(member_idx+1,member_idx+2)
      
      --3) Preparation done, so bring the track we want into the group
      --Swap dummy member 2 with target track outside group (left_of_grp_idx was found near beginning of function)
      --note: if we were to swap dummy member 1 then both tracks get ejected from group
      song:swap_tracks_at(left_of_grp_idx,(left_of_grp_idx + 2))
     
      --4) Tidy up: delete dummy tracks by looping objects 
      --(as we are deleting tracks it is safer to loop and find the dummy track objects specifically as
      --we might lose wanted song tracks if we were calculating indexes and a mistake made)
      --As indexes can change when a track is deleted, it is simpler to use 2 loops
      for i = 1,#song.tracks do
        if rawequal(song:track(i),dummy_trk_1) then
          --delete dummy 1
          renoise.song():delete_track_at(i)
          break
        end
      end
      
      for i = 1,#song.tracks do
        if rawequal(song:track(i),dummy_trk_2) then
          --delete dummy 2
          renoise.song():delete_track_at(i)
          break
        end
      end
    end

changelog:

v0.3

-Added menu in pattern editor under: Group : Group Nudge

-Modified menu start behaviour. Menus no longer toggle but re-start the tool bringing GUI to the front of the screen. Keyboard shortcut still toggles


Lua API bug -- swap tracks
Ledgers Scripts List
(Ledger) #2

v0.3
-Added pattern editor menu.
-Changed menu calling behaviour so calling from menus no longer acts as toggle. This means that when you call tool from a menu it will either open the tool or bring the currently opened tool to the front of the screen.

I`ll probably change most of my tools to this menu behaviour as it seems unlikely that you would want to close a tool via a menu. However you may have it lost beneath other windows, so you can now rely that the menu call always results in GUI at front and centre.


(Meef Chaloin) #3

Great tool, this certainly one of the more tedious aspects of renoise so this is fantastic. Only tested it a little but seems to do what it should so far.


(Ledger) #4

Great tool, this certainly one of the more tedious aspects of renoise so this is fantastic. Only tested it a little but seems to do what it should so far.

This one required a lot more to get right than it would appear due to an API bug,

The thing that could potentially go wrong is track ordering, but no tracks should be lost. I think its all fine now but let me know if your testing brings up anything.


(Ledger) #5

Just did a fix update on an older Cas tool that is related for anyone interested:

It groups the selected tracks in the pattern editor. A good replacement for Ctrl + G in renoise.

https://forum.renoise.com/t/new-tool-2-8-selected-tracks-to-group/36264