Old 05-03-2013, 09:53 AM   #1
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default ReaScript: Create send-track(s) from selected track(s)

edit. The latest version (zip-file) is in the post #13: http://forum.cockos.com/showpost.php...1&postcount=13

Create send-track(s) from selected track(s)
Note: uses beta-function "SNM_AddReceive" (SWS extension v.2.3.0 Build #17)

edit: update for Sexan - disable master/parent send for newly created tracks (1. script) or selected (source) tracks (2. script):



Create send-track(s) from selected track(s) and disable master/parent send for newly created (receiving) tracks:
Code:
# Note: uses beta-function "SNM_AddReceive"
# Create send-track(s) from selected track(s)
# and disable master/parent send for newly created (receiving) tracks

from sws_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Create send-tracks from selected tracks"):

    def msg(m):
        RPR_ShowConsoleMsg(m)

    trackCount = RPR_CountSelectedTracks(0)
    if trackCount > 0:
        for i in range(trackCount):
            trackId = RPR_GetSelectedTrack(0, i)
            name = RPR_GetSetMediaTrackInfo_String(trackId, "P_NAME", "", 0)[3]
            RPR_InsertTrackAtIndex(RPR_CountTracks(0), 1)
            receiveTrackId = RPR_GetTrack(0, RPR_CountTracks(0) - 1)
            RPR_GetSetMediaTrackInfo_String(receiveTrackId, "P_NAME", name + str(" SEND"), 1)

            # disable master/parent send for newly created (receiving) tracks
            RPR_SetMediaTrackInfo_Value(receiveTrackId, "B_MAINSEND", 0)

            a = SNM_AddReceive(trackId, receiveTrackId, -1) # -1=Default type (user preferences), 0=Post-Fader (Post-Pan), 1=Pre-FX, 2=deprecated, 3=Pre-Fader (Post-FX)
            if a == 0:
                msg("Absolutely nothing happened (nothing updated")
            # remove next 2 lines to set new tracks to default color
            else:
                RPR_SetTrackColor(receiveTrackId, 0x00FFCC00)   # color = 0x00BBGGRR

    # update view
    RPR_TrackList_AdjustWindows(False)
    RPR_UpdateArrange()
Create send-track(s) from selected track(s) and disable master/parent send for selected (sending) tracks:
Code:
# Note: uses beta-function "SNM_AddReceive"
# Create send-track(s) from selected track(s)
# and disable master/parent send for selected (sending) tracks

from sws_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Create send-tracks from selected tracks"):

    def msg(m):
        RPR_ShowConsoleMsg(m)

    trackCount = RPR_CountSelectedTracks(0)
    if trackCount > 0:
        for i in range(trackCount):
            trackId = RPR_GetSelectedTrack(0, i)
            name = RPR_GetSetMediaTrackInfo_String(trackId, "P_NAME", "", 0)[3]
            RPR_InsertTrackAtIndex(RPR_CountTracks(0), 1)
            receiveTrackId = RPR_GetTrack(0, RPR_CountTracks(0) - 1)
            RPR_GetSetMediaTrackInfo_String(receiveTrackId, "P_NAME", name + str(" SEND"), 1)

            # disable master/parent send for selected (sending) tracks
            RPR_SetMediaTrackInfo_Value(trackId, "B_MAINSEND", 0)

            a = SNM_AddReceive(trackId, receiveTrackId, -1) # -1=Default type (user preferences), 0=Post-Fader (Post-Pan), 1=Pre-FX, 2=deprecated, 3=Pre-Fader (Post-FX)
            if a == 0:
                msg("Absolutely nothing happened (nothing updated")
            # remove next 2 lines to set new tracks to default color
            else:
                RPR_SetTrackColor(receiveTrackId, 0x00FFCC00)   # color = 0x00BBGGRR

    # update view
    RPR_TrackList_AdjustWindows(False)
    RPR_UpdateArrange()

Last edited by spk77; 06-15-2013 at 11:14 PM.
spk77 is offline   Reply With Quote
Old 05-03-2013, 12:46 PM   #2
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

Thank you! Scrip is working like a charm! Only bug (dont know is reaper or sws) is that sends are not shown in TCP only receives (Icons on IO) But that doesn't matter to me
Sexan is offline   Reply With Quote
Old 05-03-2013, 01:30 PM   #3
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

If you can implement after new tracks have been created, select all new tracks and execute action "Envelope: Toggle display all visible envelopes in lanes for tracks" That would be it and I would be very very thankful!
Sexan is offline   Reply With Quote
Old 05-03-2013, 02:09 PM   #4
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

I hope this works for you (remove "##"s if you want to keep the original selection):

Code:
# Note: uses beta-function "SNM_AddReceive"
# Create receive-track(s) from selected track(s)
# + disable master/parent send for selected (source) tracks
# + "toggle display all visible envelopes in lanes" for new tracks

from sws_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Create receive-tracks from selected tracks"):

##    sourceTrackL = []
    destTrackL = []

    def msg(m):
        RPR_ShowConsoleMsg(m)

    trackCount = RPR_CountSelectedTracks(0)
    if trackCount > 0:
        for i in range(trackCount):
            trackId = RPR_GetSelectedTrack(0, i)
##            sourceTrackL.append(trackId)
            name = RPR_GetSetMediaTrackInfo_String(trackId, "P_NAME", "", 0)[3]
            RPR_InsertTrackAtIndex(RPR_CountTracks(0), 1)
            receiveTrackId = RPR_GetTrack(0, RPR_CountTracks(0) - 1)
            destTrackL.append(receiveTrackId)
            RPR_GetSetMediaTrackInfo_String(receiveTrackId, "P_NAME", name + str(" SEND"), 1)

            # disable master/parent send for selected (source) tracks
            RPR_SetMediaTrackInfo_Value(trackId, "B_MAINSEND", 0)

            a = SNM_AddReceive(trackId, receiveTrackId, -1) # -1=Default type (user preferences), 0=Post-Fader (Post-Pan), 1=Pre-FX, 2=deprecated, 3=Pre-Fader (Post-FX)
            if a == 0:
                msg("Absolutely nothing happened (nothing updated")
                break
            # remove next 2 lines to set new tracks to default color
            else:
                RPR_SetTrackColor(receiveTrackId, 0x00FFCC00)   # color = 0x00BBGGRR

        RPR_PreventUIRefresh(1)

        RPR_Main_OnCommandEx(40297, 0, 0)   # unselect all tracks
        # select destination tracks
        for destTr in destTrackL:
            RPR_SetMediaTrackInfo_Value(destTr, "I_SELECTED", 1)

        RPR_Main_OnCommandEx(40891, 0, 0)   # toggle display all visible envelopes in lanes
##        RPR_Main_OnCommandEx(40297, 0, 0)   # unselect all tracks

##        for sourceTr in sourceTrackL:
##            RPR_SetMediaTrackInfo_Value(sourceTr, "I_SELECTED", 1)

        RPR_PreventUIRefresh(-1)

        # update view
        RPR_TrackList_AdjustWindows(False)
        RPR_UpdateArrange()
spk77 is offline   Reply With Quote
Old 05-03-2013, 02:49 PM   #5
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

Thank you! Its awesome! If you accept donations I would be happy to pay you!
Sexan is offline   Reply With Quote
Old 05-03-2013, 02:55 PM   #6
semiquaver
Human being with feelings
 
Join Date: Jun 2008
Posts: 4,909
Default

thanks!
semiquaver is offline   Reply With Quote
Old 05-03-2013, 03:09 PM   #7
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by Sexan View Post
Thank you! Its awesome! If you accept donations I would be happy to pay you!
Thanks for the offer but no thank you

Quote:
Originally Posted by semiquaver View Post
thanks!
You're welcome!

By the way, what should the name be - "Create send-track(s) from selected track(s)" or "Create receive(r)-track(s) from selected track(s)"?
spk77 is offline   Reply With Quote
Old 05-03-2013, 03:25 PM   #8
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

I wanted this for separate automation tracks that I can folder so I can have clearer view on automation.One name can be (for the last script) "Separated Automation tracks" or "Create send-track(s) from selected track(s)" - I think it will be easier to understand.
Sexan is offline   Reply With Quote
Old 05-05-2013, 11:50 AM   #9
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

New version with dialog and instructions:

https://stash.reaper.fm/16316/Create%...cks_dialog.zip



NOTE: Settings are saved to "reaper-extstate.ini" -file when OK-button is pressed.



Send-tracks per source track(s):
  • Select how many new send-tracks are created per source track.
New track position:
  • 0 = send-tracks are placed next to source tracks
  • 1 = send-tracks are placed at the end (after the last track)
Send type:
  • -1 = Default type (user preferences)
  • 0 = Post-Fader (Post-Pan)
  • 1 = Pre-FX
  • 2 = deprecated
  • 3 = Pre-Fader (Post-FX)
Disable master/parent send (0/1/2/3):
  • 0 = Don't disable
  • 1 = Disable master/parent send for source tracks
  • 2 = Disable master/parent send for created send-tracks
  • 3 = Disable both
Color:
  • Send-track color BBGGRR (f.ex. FFCC00)
  • 0 = default color
Show Instructions:
  • 0 = Dont' show instructions
  • 1 = Show instructions

Last edited by spk77; 05-06-2013 at 07:13 AM.
spk77 is offline   Reply With Quote
Old 05-05-2013, 01:39 PM   #10
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

Awesome! Thank you!
Can I ask you for one more favor?
User Anton posted script "Select every n midi note":
http://forum.cockos.com/showpost.php...postcount=1054

Can you modify it so you first select which row of notes you want to modify then after selecting n'th notes you can enter where to move the notes (c4 d4 e4 ...)?
We should probably open new topic for this.
Once more Thank You our Scripting Wizard!

Last edited by Sexan; 05-05-2013 at 01:46 PM.
Sexan is offline   Reply With Quote
Old 05-06-2013, 10:12 AM   #11
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by Sexan View Post
Awesome! Thank you!
Can I ask you for one more favor?
User Anton posted script "Select every n midi note":
http://forum.cockos.com/showpost.php...postcount=1054

Can you modify it so you first select which row of notes you want to modify then after selecting n'th notes you can enter where to move the notes (c4 d4 e4 ...)?
We should probably open new topic for this.
Once more Thank You our Scripting Wizard!
I'm glad you liked it. You can do something like that with clumsy "arpeggiator": http://forum.cockos.com/showthread.p...25#post1110125. I'm currently updating/fixing it.
spk77 is offline   Reply With Quote
Old 05-07-2013, 01:10 PM   #12
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Updated:
https://stash.reaper.fm/16344/Create%...ks_dialog2.zip

Run action 1:
  • At this point send-tracks are selected, source tracks are not selected.
  • Copy command Id from the action list. Use 'Custom ID string' for custom actions.
  • -1 = Don't run action 1
Run action 2 (final action):
  • Runs after everything else is executed.
  • Source tracks are selected, new tracks are not selected.
  • Copy command Id from the action list. Use 'Custom ID string' for custom actions
  • -1 = Don't run action 2
spk77 is offline   Reply With Quote
Old 05-15-2013, 11:20 PM   #13
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Updated (blue text)
https://stash.reaper.fm/16435/Create%...cks_dialog.zip

Unselect all tracks and run the script to show instructions.
Settings are saved to "reaper-extstate.ini" -file when OK-button is pressed.

Send-tracks per source track(s):
  • Select how many send-tracks are created per source track.

New track position:
  • '0' or 'next' = send-tracks are placed next to source tracks
  • '1' or 'end' = send-tracks are placed at the end (after the last track)
  • '2' or 'parent' = new track is 'folder parent' (each selected track is put into a new folder)

Send type:
  • '-1' or 'default' = Default type (user preferences)
  • '0' or 'postfader' = Post-Fader (Post-Pan)
  • '1' or 'prefx' = Pre-FX
  • '2' or 'deprecated' = deprecated
  • '3' or 'prefader' = Pre-Fader (Post-FX)
  • '4' or 'nosends' = Don't add send(s)

spk77 is offline   Reply With Quote
Old 05-16-2013, 12:53 AM   #14
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 4,823
Default

great script spk77
heda is offline   Reply With Quote
Old 05-16-2013, 01:29 AM   #15
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by heda View Post
great script spk77
Thank you
spk77 is offline   Reply With Quote
Old 10-12-2013, 10:13 AM   #16
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

Can I ask one small favour , in the second script in the first post,can you (or somebody) add so when sends are created they are in folder?
Thank you
Sexan is offline   Reply With Quote
Old 10-12-2013, 05:09 PM   #17
gwok
Human being with feelings
 
gwok's Avatar
 
Join Date: Jun 2010
Location: Nelson, BC
Posts: 3,312
Default

thanks spk77, this is really useful. Not sure if you want to add more tweaks, but if you were to, I would suggest an option to merely copy the first selected tracks color to the recieve.

cheers man, thanks for the tools
__________________
MacPro Xeon, 10.9.5
Reaper 5
gwok is offline   Reply With Quote
Old 10-13-2013, 04:31 AM   #18
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

Pretty please ?
Sexan is offline   Reply With Quote
Old 10-13-2013, 04:44 AM   #19
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by Sexan View Post
Can I ask one small favour , in the second script in the first post,can you (or somebody) add so when sends are created they are in folder?
Thank you
Hi,
Do you mean that a created send track position in a folder is "parent" or should it be "child"?
spk77 is offline   Reply With Quote
Old 10-13-2013, 05:07 AM   #20
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

Hi! All new send tracks are in folder, all sends are "child"
Sexan is offline   Reply With Quote
Old 10-13-2013, 06:32 AM   #21
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by Sexan View Post
Hi! All new send tracks are in folder, all sends are "child"
I hope I understood correctly:


Code:
# Create send-track(s) from selected track(s) -> put new track(s) into a folder as "child track"
# and disable master/parent send for selected (sending) tracks

from sws_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Create send-tracks from selected tracks"):

    def msg(m):
        RPR_ShowConsoleMsg(m)

    trackCount = RPR_CountSelectedTracks(0)
    if trackCount > 0:
        for i in range(trackCount):
            sourceTrackId = RPR_GetSelectedTrack(0, i)
            sourceTrackIndex = int(RPR_GetMediaTrackInfo_Value(sourceTrackId, "IP_TRACKNUMBER") - 1)
            name = RPR_GetSetMediaTrackInfo_String(sourceTrackId, "P_NAME", "", 0)[3]
            RPR_SetMediaTrackInfo_Value(sourceTrackId, "I_FOLDERDEPTH", 1.0)

            newTrackIndex = sourceTrackIndex + 1
            RPR_InsertTrackAtIndex(newTrackIndex, 1)
            receiveTrackId = RPR_GetTrack(0, newTrackIndex)
            RPR_GetSetMediaTrackInfo_String(receiveTrackId, "P_NAME", name + str(" SEND"), 1)
            RPR_SetMediaTrackInfo_Value(receiveTrackId, "I_FOLDERDEPTH", -1.0)

            # disable master/parent send for selected (sending) tracks
            RPR_SetMediaTrackInfo_Value(sourceTrackId, "B_MAINSEND", 0)

            a = SNM_AddReceive(sourceTrackId, receiveTrackId, -1) # -1=Default type (user preferences), 0=Post-Fader (Post-Pan), 1=Pre-FX, 2=deprecated, 3=Pre-Fader (Post-FX)
            if a == 0:
                msg("Absolutely nothing happened (nothing updated")
            # remove next 2 lines to set new tracks to default color
            else:
                RPR_SetTrackColor(receiveTrackId, 0x00FFCC00)   # color = 0x00BBGGRR

    # update view
    RPR_TrackList_AdjustWindows(False)
    RPR_UpdateArrange()
spk77 is offline   Reply With Quote
Old 10-13-2013, 07:37 AM   #22
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

Sorry for trouble that's not what I've meant

This:



All sends are in one folder

Sorry for not explaining it well
Sexan is offline   Reply With Quote
Old 10-13-2013, 07:50 AM   #23
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by Sexan View Post
Sorry for trouble that's not what I've meant

All sends are in one folder

Sorry for not explaining it well
Ok, I think I understood . I'll update the script later.
spk77 is offline   Reply With Quote
Old 10-13-2013, 08:04 AM   #24
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

Thank You!! And sorry for trouble
Sexan is offline   Reply With Quote
Old 10-13-2013, 11:06 AM   #25
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Another try:
(I didn't know where to put the new tracks - currently, the send tracks are inserted at the end)


Code:
# Create send-track(s) from selected track(s) -> put new track(s) into new folder as "child track"
# and disable master/parent send for selected (sending) tracks

from sws_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

def msg(m):
    RPR_ShowConsoleMsg(m)

def createSendTracks():
    selTrackCount = RPR_CountSelectedTracks(0)
    if selTrackCount == 0:
        return

    # insert folder parent for send tracks
    folderName = "AUTO"   # set name for folder (parent)
    RPR_InsertTrackAtIndex(RPR_CountTracks(0), 1)
    parent = RPR_GetTrack(0, RPR_CountTracks(0) - 1)
    RPR_SetMediaTrackInfo_Value(parent, "I_FOLDERDEPTH", 1.0)
    RPR_GetSetMediaTrackInfo_String(parent, "P_NAME", str(folderName), 1)

    for i in range(selTrackCount):
        sourceTrackId = RPR_GetSelectedTrack(0, i)
        name = RPR_GetSetMediaTrackInfo_String(sourceTrackId, "P_NAME", "", 0)[3]

        # insert send tracks
        RPR_InsertTrackAtIndex(RPR_CountTracks(0), 1)
        receiveTrackId = RPR_GetTrack(0, RPR_CountTracks(0) - 1)
        RPR_GetSetMediaTrackInfo_String(receiveTrackId, "P_NAME", name + str(" AUTO"), 1)

        # disable master/parent send for selected (sending) tracks
        RPR_SetMediaTrackInfo_Value(sourceTrackId, "B_MAINSEND", 0)

        a = SNM_AddReceive(sourceTrackId, receiveTrackId, -1) # -1=Default type (user preferences), 0=Post-Fader (Post-Pan), 1=Pre-FX, 2=deprecated, 3=Pre-Fader (Post-FX)
        if a == 0:
            msg("Absolutely nothing happened (nothing updated")

        # remove next 2 lines to set new tracks to default color
        else:
            RPR_SetTrackColor(receiveTrackId, 0x00FFCC00)   # color = 0x00BBGGRR

    # set last track to "last track in folder"
    RPR_SetMediaTrackInfo_Value(receiveTrackId, "I_FOLDERDEPTH", -1.0)

    # update view
    RPR_TrackList_AdjustWindows(False)
    RPR_UpdateArrange()

with undoable("Create send-tracks from selected tracks"):
    createSendTracks()

Last edited by spk77; 10-13-2013 at 11:33 AM.
spk77 is offline   Reply With Quote
Old 10-13-2013, 11:12 AM   #26
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

Thank you!
I need them at the end so its cool !

But something is wrong,it doesn't create folder?
It acts same original script?


Last edited by Sexan; 10-13-2013 at 11:29 AM.
Sexan is offline   Reply With Quote
Old 10-13-2013, 11:27 AM   #27
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by gwok View Post
thanks spk77, this is really useful. Not sure if you want to add more tweaks, but if you were to, I would suggest an option to merely copy the first selected tracks color to the recieve.

cheers man, thanks for the tools
Thanks gwok. In which script should I put that option?
spk77 is offline   Reply With Quote
Old 10-13-2013, 11:37 AM   #28
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by Sexan View Post
Thank you!
I need them at the end so its cool !

But something is wrong,it doesn't create folder?
It acts same original script?
Hmmm...it's adding a folder here.



Please try again (post # 25 updated)

changed this line
RPR_TrackList_AdjustWindows(True)
to
RPR_TrackList_AdjustWindows(False)
spk77 is offline   Reply With Quote
Old 10-13-2013, 11:41 AM   #29
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,059
Default

Now it works.
Thank you very much!
Sexan is offline   Reply With Quote
Old 10-13-2013, 11:44 AM   #30
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Glad you got it working
spk77 is offline   Reply With Quote
Old 01-22-2014, 11:50 PM   #31
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,846
Default

I envisage an action which working this way. Is it possible?

Select a bunch of (source) tracks, run the new action, then click on the destination track: Sends will be created from all selected tracks to the one destination track.

I guess this would probably need to work with their action arming or it needs to have a dialogbox in between. For example:

Select source tracks,
Run action,
Dialogbox: Please select on the destination track(s) and press OK when done.
<sends from all source tracks are created to all selected destination tracks>
<restore original (source) track selection>


Am I dreaming too big for Python?
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia 9600, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 01-24-2014, 02:20 AM   #32
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by daxliniere View Post
I envisage an action which working this way. Is it possible?

Select a bunch of (source) tracks, run the new action, then click on the destination track: Sends will be created from all selected tracks to the one destination track.

I guess this would probably need to work with their action arming or it needs to have a dialogbox in between. For example:

Select source tracks,
Run action,
Dialogbox: Please select on the destination track(s) and press OK when done.
<sends from all source tracks are created to all selected destination tracks>
<restore original (source) track selection>


Am I dreaming too big for Python?
I think it's possible - I have to do some testing first.
spk77 is offline   Reply With Quote
Old 01-24-2014, 03:35 AM   #33
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,846
Default

Quote:
Originally Posted by spk77 View Post
I think it's possible - I have to do some testing first.
Amazing, SPK77!
I can talk to someone about maybe getting it included in SWS.
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia 9600, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 01-25-2014, 12:20 AM   #34
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,846
Default

SPK77, I had another thought.
Originally I specified that the user would select tracks first, then run the action and be prompted to select destination tracks, etc..

What if it worked this way;
If track selection exists before the action is run, it works as I previously described. But if no tracks are selected when the action is run, the action should prompt the user to "select source tracks, then click OK to continue", then it would ask you to select destination tracks and press OK again to create the sends.
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia 9600, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 01-26-2014, 12:05 AM   #35
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by daxliniere View Post
SPK77, I had another thought.
Originally I specified that the user would select tracks first, then run the action and be prompted to select destination tracks, etc..

What if it worked this way;
If track selection exists before the action is run, it works as I previously described. But if no tracks are selected when the action is run, the action should prompt the user to "select source tracks, then click OK to continue", then it would ask you to select destination tracks and press OK again to create the sends.
It seems it's not possible to select tracks while a dialog window is open/focused. I think I have to use RPR_Set/GetExtState to store source tracks. It means that the same script have to be run twice - it would work like this:

1. Store source tracks (and show messagebox: "Source tracks stored. Please select destination tracks") -> Unselect all tracks.
(now the user would select the destination tracks)
2. Get destination track IDs -> restore source tracks -> loop through destination tracks (inner loop for source tracks for adding sends/receives)

Let's see if I get that working.

Last edited by spk77; 01-26-2014 at 07:12 AM.
spk77 is offline   Reply With Quote
Old 01-26-2014, 12:21 AM   #36
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,846
Default

Sounds good enough to me!
Thanks for trying, spk77!
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia 9600, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 01-26-2014, 09:45 AM   #37
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Here's my attempt (press cancel or close the dialog window to "reset" the script)

Add sends/receives to selected tracks
Code:
# Add sends/receives to selected tracks

from sws_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

def msg(m):
    RPR_ShowConsoleMsg(m)

def addReceives():
    """Sendtypes:
    -1 = Default type (user preferences)
    0 = Post-Fader (Post-Pan)
    1 = Pre-FX
    2 = deprecated
    3 = Pre-Fader (Post-FX)"""

    sendType = -1   # default type
    sourceTrackL = []
    sourceTracks = ""
    destinationTrackL = []

    selTrackCount = RPR_CountSelectedTracks(0)

    # (user has not selected the source tracks)
    if selTrackCount == 0 and not RPR_HasExtState("Saved tracks", "source_tracks"):
        sourceSelMsg = RPR_ShowMessageBox("Please select the source tracks and run the script again.", "No selected (source) tracks", 0)
        return

    # store source tracks (user has selected the source tracks)
    elif selTrackCount > 0 and not RPR_HasExtState("Saved tracks", "source_tracks"):
        for i in range(selTrackCount):
            sourceTracks += str(RPR_GetSelectedTrack(0, i)) + ","
        sourceTracks = sourceTracks.rstrip(",")

        destTrackMsg = RPR_ShowMessageBox("Source tracks stored. Please select the destination tracks.\n\nPress OK -> select the destination tracks -> run the script again\nPress cancel to exit", "Source tracks stored.", 1)
        if destTrackMsg == 2:
            RPR_DeleteExtState("Saved tracks", "source_tracks", False)
        else:
            RPR_SetExtState("Saved tracks", "source_tracks", sourceTracks, False)
        return

    # source tracks stored -> (user has not selected the destination tracks)
    elif selTrackCount == 0 and RPR_HasExtState("Saved tracks", "source_tracks"):
        destTrackMsg = RPR_ShowMessageBox("Please select the destination tracks.\n\nPress OK -> select the destination tracks -> run the script again\nPress cancel to exit", "Please select the destination tracks.", 1)
        if destTrackMsg == 2:
            RPR_DeleteExtState("Saved tracks", "source_tracks", False)
        return

    # source tracks stored -> (user has selected the destination tracks)
    elif selTrackCount > 0 and RPR_HasExtState("Saved tracks", "source_tracks"):
        sourceTrackL = RPR_GetExtState("Saved tracks", "source_tracks").split(",")

        for i in range(selTrackCount):
            destinationTrack = RPR_GetSelectedTrack(0, i)
            for sourceTrack in sourceTrackL:
                addReceive = SNM_AddReceive(sourceTrack, destinationTrack, sendType)

        RPR_DeleteExtState("Saved tracks", "source_tracks", False)

        # update view
        RPR_TrackList_AdjustWindows(False)
        return

with undoable("Add receives"):
    addReceives()


Quote:
Originally Posted by Veto View Post
For a solution with the disadvantages of having to use a dedicated keyboard shortcut and getting it to work with only one destination track, you could also use the action "Track: Select track under mouse" .

What i mean is this:
1. select source tracks
2. move pointer to destination track
3. run script by shortcut

Thinking about it, by arming the script (on a toolbar), both disadvantages could be eliminated nicely. You just need to click all destination tracks after arming.
EDIT: nope, workaround not working around... arming has only effect to items unfortunately, so one has to use a shortcut
I think we need more options with ReaScript UI elements.

Last edited by spk77; 01-30-2014 at 02:49 AM. Reason: (user has not selected the destination tracks) to (user has not selected the source tracks)
spk77 is offline   Reply With Quote
Old 01-26-2014, 04:13 PM   #38
daxliniere
Human being with feelings
 
daxliniere's Avatar
 
Join Date: Nov 2008
Location: London, UK
Posts: 1,846
Default

@Veto: Oh wow, great idea. The arming thing would have been the ideal solution (IMHO).

@spk77: I (quickly) tested your script and it works great! I will DEFINITELY get a lots of use out of this.

One question, though, you said that when the dialogbox is shown, you can't select tracks. (I assumed you meant the dialogbox holds focus). I have just tested this and, at least on my system (REAPERx32 on Win7), I can click on anything I like when the "Source tracks stored." dialogbox is open.
Would you be able to change the way this action works, please?

All the best,
__________________
Dax Liniere
London's newest premium studio complex! (Facebook)
[i7-4790K, 12Gb RAM, Win8.1x64, NVidia 9600, UAD2-OCTO, FireFaceUFX, REAPER x64]
daxliniere is offline   Reply With Quote
Old 01-26-2014, 10:47 PM   #39
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by daxliniere View Post
@Veto: Oh wow, great idea. The arming thing would have been the ideal solution (IMHO).

@spk77: I (quickly) tested your script and it works great! I will DEFINITELY get a lots of use out of this.

One question, though, you said that when the dialogbox is shown, you can't select tracks. (I assumed you meant the dialogbox holds focus). I have just tested this and, at least on my system (REAPERx32 on Win7), I can click on anything I like when the "Source tracks stored." dialogbox is open.
Would you be able to change the way this action works, please?

All the best,
Interesting...On Win XP 32bit it's not possible to do select tracks when a messagebox is open:



I have to think how to modify the script, because I can't test it on Win7.
spk77 is offline   Reply With Quote
Old 01-27-2014, 02:59 AM   #40
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,488
Default

Quote:
Originally Posted by Argitoth View Post
Is there a way to move media items to a certain track? There is no "Set media item track" in the API. Will I have to do something like "get selected track number, get selected media item track number, move + or - based on the difference"?

lol oh wait....

"MoveMediaItemToTrack(MediaItem* item, MediaTrack* desttr)"

is that what I want?
Yes and the arrange view have to be refreshed (probably) with RPR_UpdateArrange(). If you add tracks, TCP have to be refreshed with RPR_TrackList_AdjustWindows(False)

Code:
RPR_MoveMediaItemToTrack(item, destTrack)

# update arrange view
RPR_UpdateArrange()
# update TCP/MCP
RPR_TrackList_AdjustWindows(False)
spk77 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 04:00 PM.


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