Old 04-22-2013, 09:59 AM   #121
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Phoenix, AZ
Posts: 2,055
Default

wow that's a lot of scripting for something simple. These actions need to be included in either SWS or Reaper. But it seems both are slow to respond... ugh.

so enough script requests from me. spk77 is it possible to create an action that switches an fx to a specific # preset?
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-22-2013, 10:12 AM   #122
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,583
Default

Quote:
Originally Posted by Argitoth View Post
wow that's a lot of scripting for something simple. These actions need to be included in either SWS or Reaper. But it seems both are slow to respond... ugh.

so enough script requests from me. spk77 is it possible to create an action that switches an fx to a specific # preset?
Here's a template for it:

Code:
# Set preset by index

from reaper_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("Set preset by index"):

    trackIndex = 1
    fxIndex = 1
    presetIndex = 1

    if fxIndex and presetIndex and trackIndex > 0:
        track = RPR_GetTrack(0, trackIndex - 1)
        RPR_TrackFX_SetPresetByIndex(track, fxIndex - 1, presetIndex - 1)
For master track:
Code:
# Set preset by index (master track)

from reaper_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("Set preset by index (master track)"):

    fxIndex = 1
    presetIndex = 1

    masterTrackId = RPR_GetMasterTrack(0)

    if fxIndex and presetIndex > 0:
        RPR_TrackFX_SetPresetByIndex(masterTrackId, fxIndex - 1, presetIndex - 1)

Last edited by spk77; 04-22-2013 at 10:49 AM. Reason: little fix : "if fxIndex and presetIndex and trackIndex > 0":
spk77 is offline   Reply With Quote
Old 04-22-2013, 10:22 AM   #123
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,583
Default

Template for bypass/unbypass FX (toggle):
Code:
# Bypass/unbypass FX

from reaper_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("Bypass/unbypass FX"):

    trackIndex = 1
    fxIndex = 1

    if trackIndex and fxIndex > 0:

        track = RPR_GetTrack(0, trackIndex - 1)

        isEnabled = bool(RPR_TrackFX_GetEnabled(track, fxIndex - 1))

        if isEnabled:
            RPR_TrackFX_SetEnabled(track, fxIndex - 1, 0)
        else:
            RPR_TrackFX_SetEnabled(track, fxIndex - 1, 1)
...and for master track:
Code:
# Bypass/unbypass FX (master track)

from reaper_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("Bypass/unbypass FX (master track)"):

    fxIndex = 1

    if fxIndex > 0:

        masterTrackId = RPR_GetMasterTrack(0)
        isEnabled = bool(RPR_TrackFX_GetEnabled(masterTrackId, fxIndex - 1))

        if isEnabled:
            RPR_TrackFX_SetEnabled(masterTrackId, fxIndex - 1, 0)
        else:
            RPR_TrackFX_SetEnabled(masterTrackId, fxIndex - 1, 1)

Last edited by spk77; 04-23-2013 at 08:13 AM.
spk77 is offline   Reply With Quote
Old 04-22-2013, 10:25 AM   #124
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Phoenix, AZ
Posts: 2,055
Default

Okay Tony Ostinato, everything you need is right here to do exactly whatever your heart desires! Thank you spk77!

edit: hey spk77, where can I get the latest reaper API? You're using functions not in the wiki... no wonder I can't script anything.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-22-2013, 10:29 AM   #125
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,583
Default

Quote:
Originally Posted by Argitoth View Post
Okay Tony Ostinato, everything you need is right here to do exactly whatever your heart desires! Thank you spk77!

edit: hey spk77, where can I get the latest reaper API? You're using functions not in the wiki... no wonder I can't script anything.
Open REAPER's help menu -> HTML lists -> ReaScript Documentation. All functions (documentation) are there.
spk77 is offline   Reply With Quote
Old 04-22-2013, 11:27 AM   #126
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Phoenix, AZ
Posts: 2,055
Default

delete code in red so that you only go to project end if it is after the last marker.

Code:
# Move edit cursor to next marker or project end (ignore time selection)
        ...
        # seek next marker after edit cursor
        if markerPos > cursorPos:

            # move cursor to next marker or project end
            projectEnd = getProjectEnd()
            if abs(cursorPos - projectEnd) < abs(cursorPos - markerPos) and projectEnd > cursorPos:
                RPR_CSurf_GoEnd()
            else:
                RPR_SetEditCurPos2(0, markerPos, 1, 0)
            break
            ...
Code:
# Move edit cursor to previous marker or project start/end (ignore time selection)
                ...
                if abs(cursorPos - projectEnd) < abs(cursorPos - projectStart) and projectEnd < cursorPos:
                    RPR_CSurf_GoEnd()
                else:
                    RPR_CSurf_GoStart()
                break
            else:
                if abs(cursorPos - projectEnd) < abs(cursorPos - prevMarkerPos) and projectEnd < cursorPos:
                    RPR_CSurf_GoEnd()
                else:
                    RPR_SetEditCurPos2(0, prevMarkerPos, 1, 0)
            break
            ...
hey spk77, is it possible to set the project start as the beginning of the first media item? I'm guessing there's no function that gets the first media item, so it would require a complex script that checks the entire project. not worth it?

edit: maybeee, create an array of every first media item start position of every track, and find the lowest number of start positions?
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 04-22-2013 at 03:16 PM.
Argitoth is offline   Reply With Quote
Old 04-22-2013, 12:00 PM   #127
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,583
Default

Quote:
Originally Posted by Argitoth View Post
hey spk77, is it possible to set the project start as the beginning of the first media item? I'm guessing there's no function that gets the first media item, so it would require a complex script that checks the entire project. not worth it?
Reaper item indexing works like this (3. item is the first item in timeline in this case):

track1 |----[1.item]----[2.item]---
track2 |--[3.item]---[4.item]------

Edit: So yes, we would have to check first media item position of every track (and find the lowest number of start position) to get the first item in timeline

Last edited by spk77; 04-22-2013 at 12:17 PM.
spk77 is offline   Reply With Quote
Old 04-22-2013, 12:02 PM   #128
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Phoenix, AZ
Posts: 2,055
Default

k, not worth it! reaper will hang for a long time if it has to check the entire project because of so many media items.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-22-2013, 01:37 PM   #129
Tony Ostinato
Human being with feelings
 
Join Date: Apr 2012
Posts: 90
Default

wow, itll take me some time to ponder out how to use that info but, again, wow!

in the meantime i'm busy fixing all my macros with the info ive gotten here, big big big big thanks!!

my speed rating has to have improved 20%, although its sad to have to think about speed rating, how did those guys with the fairlight samplers onstage survive??
Tony Ostinato is offline   Reply With Quote
Old 04-22-2013, 01:44 PM   #130
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Phoenix, AZ
Posts: 2,055
Default

Great, just let me / us know if you need help with anything, if something doesn't work exactly how you want it, I'm getting better at altering scripts and coming up with macros. I want to make sure you have everything you need because your video inspired me to think about how I can make it easier to compose multi-instrumental harmonies and such and think about how I do things and how I need certain things to be faster / more intuitive / more to-the-point, and not doing the same thing over and over to accomplish a small task.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-22-2013, 06:29 PM   #131
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,223
Default

Quote:
Originally Posted by Argitoth View Post
k, not worth it! reaper will hang for a long time if it has to check the entire project because of so many media items.
As spk77 said, you don't have to check every item, only every track and then first item on that track

I don't think you can set project start time from ReaScript but this will move edit cursor to media item closest to project start.
Code:
# Check that at least one media item exists
if RPR_CountMediaItems(0) != 0:
	
	# Get position of any item to compare against
	target = RPR_GetMediaItemInfo_Value(RPR_GetMediaItem(0, 0), "D_POSITION")

	# Loop through all the tracks
	for i in range (RPR_CountTracks(0)):

		# Check if track has at least one item
		if RPR_CountTrackMediaItems(RPR_GetTrack(0, i)) > 0:
			pos = RPR_GetMediaItemInfo_Value(RPR_GetTrackMediaItem(RPR_GetTrack(0, i), 0), "D_POSITION")
			if pos < target:
				target = pos
		# If not, skip it
		else:
			continue

	# Set edit cursor at target
	RPR_SetEditCurPos(target, 1, 0)
	
else:
	RPR_ShowMessageBox("No media items found", "Error", 0)

edit: you could also do it with a macro but it might be slower if you have tons of items:
Code:
SWS: Save selected item(s)
Select all items
Item navigation: Move cursor to start of items
SWS: Restore saveed selected item(s)

Last edited by Breeder; 04-22-2013 at 06:41 PM.
Breeder is offline   Reply With Quote
Old 04-27-2013, 12:27 AM   #132
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Phoenix, AZ
Posts: 2,055
Default

ok, I have a good request

-save cursor position
-restore cursor position

...oh MY GOD, there's already one in the freaking SWS extension... there's so many times I could have used this. *smack face*
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-27-2013, 12:11 PM   #133
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Phoenix, AZ
Posts: 2,055
Default

Ok, here's a real request:

Could I have a template script where I can write in a name for the script to find and select all tracks with name?

Basically I need to select a specific set of of tracks with one action but with no popup menu so I would enter the name into the script itself. Another possible script is to "select # track (keeping selection)".

Thank you!
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 04-27-2013 at 12:19 PM.
Argitoth is offline   Reply With Quote
Old 04-28-2013, 05:08 PM   #134
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,223
Default

You can select tracks with specific name by using SWS ReaConsole

http://forum.cockos.com/showpost.php...postcount=1179
Breeder is offline   Reply With Quote
Old 04-28-2013, 05:11 PM   #135
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Phoenix, AZ
Posts: 2,055
Default

So with that I can create the needed actions and include that action in a macro?
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-28-2013, 10:57 PM   #136
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,223
Default

Quote:
Originally Posted by Argitoth View Post
So with that I can create the needed actions and include that action in a macro?
Yep, and using Cycle actions editor you can all do it from reaper. No need to deal with cryptic names and reaconsole_customcommands.txt anymore.
Breeder is offline   Reply With Quote
Old 05-08-2013, 05:47 AM   #137
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,452
Default

Can someone please make a script that will move selected notes up/down to other note : little pop up window in which you enter note destination (36 38 44 etc)?thank you in advance
Sexan is offline   Reply With Quote
Old 05-14-2013, 04:21 AM   #138
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Posts: 553
Default Midi script to +2 to program change message - to control jamstix

Hey -

Mod please relocate if needed...

I need a script or JS "script" (do I call it that?) to run on a track that will pass all midi except program change.
When program change message is received at script,
add 2 to the number.

PC0 received
PC2 output to track

I will only need it active on one midi input.
My podXT Live.
I am trying to control Jamstix "liveloop"
My podxt live abcd buttons
are pc0, pc1,pc2, pc3.
In jamstix pc0 does nothing, pc1 is usually the intro.
This leaves only two left in front of me.
If I add 2 to the pc message that will give me four patterns to play with without banking.
I can do this with an autohotkey script, but want something that will work within reaper instead and not need virtual midi ports to do it.

Thanks much!
__________________
KeyMce/GenMce - pc keyboard/midi to Mackie control emulation (built with ahk). Also - an ahk script to build your own midi programs.

Last edited by flipotto; 05-14-2013 at 01:03 PM. Reason: Change to include JS plugin "script"???? Can someone help me?
flipotto is offline   Reply With Quote
Old 05-14-2013, 11:31 AM   #139
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Phoenix, AZ
Posts: 2,055
Default

Isn't that more of a JS request? I'm not sure a script can monitor, rather it can only be executed.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 05-14-2013, 08:47 PM   #140
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 1,704
Default separate copy and paste item values

being a complete noob to reascript, i could use two VERY simple example scripts to start to see how things work.

1. copy an item's (not take) volume

2. paste that value to selected items.

i see this as a two action process, selecting one item to copy, then, after
copying its volume, selecting some other items and applying the copied volume to them.

would be really helpful to me to see how this works. then i could adapt it to do other things.

thanks,
BabaG
babag is offline   Reply With Quote
Old 06-01-2013, 03:56 AM   #141
harmonicaman
Human being with feelings
 
harmonicaman's Avatar
 
Join Date: Oct 2011
Posts: 134
Default

This thread is awesome !
Is it possible with a script to move up and down (and create points with it), to a given value, an automation segment of a time selection lenght, without selecting the envelope in the track, or even showing it ?
I dont know if I'm clear, so a simple example : whole track has no pan envelope, it's panned by default to the middle. I make a track selection, I press a key shorcut and it's pan the segment to like 75% left (I could make copies of the scripts with differents values, hard left, middle, 30% right, etc)
Well in fact I thought mostly using it for panning . It would be great, and like wonderful to be able to do it without selecting a track, the script running to the track under the mouse when you press a shortcut.
Maybe other would prefer it to be applied to the lenght of selected item(s) or item under the mouse.

Edit: problem solved with a new set of actions added to select envelopes

Last edited by harmonicaman; 06-17-2013 at 09:31 AM.
harmonicaman is offline   Reply With Quote
Old 06-26-2013, 02:47 PM   #142
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,914
Default

Hi Reascripters,
I have a request if at all possible.

I know we have an action " Track: Select track under mouse"

Would it be possible to select a track at what track the mouse cursor is at in the arrange area, instead of underneath?

From the reasript api we have:
GetCursorPositionEx(ReaProject* proj)
SetTrackSelected(MediaTrack* track, bool selected)

Thanks, Wyatt
WyattRice is offline   Reply With Quote
Old 06-26-2013, 02:54 PM   #143
timlloyd
Human being with feelings
 
Join Date: Mar 2010
Posts: 4,713
Default

Quote:
Originally Posted by WyattRice View Post
Would it be possible to select a track at what track the mouse cursor is at in the arrange area, instead of underneath?
I don't understand
timlloyd is offline   Reply With Quote
Old 06-26-2013, 03:33 PM   #144
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,914
Default

Quote:
Originally Posted by timlloyd View Post
I don't understand
Thanks for the quick reply Tim.

I've messed with this enough now to know it isn't going to work.

Currently under options > preferences > editing behavior > mouse, we have an option for a track to be selected by left clicking in the arrange.

I was trying to see if I could get this to work by adding a custom action to the right click arrange menu, so I could paste items without having to left click to select a track first.

I've tried this custom action

Track: Select track under mouse
item: Paste items/tracks

Then added that to the ruler/arrange menu, but it doesn't work.
WyattRice is offline   Reply With Quote
Old 06-28-2013, 01:43 PM   #145
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,583
Default

Quote:
Originally Posted by WyattRice View Post
Thanks for the quick reply Tim.

I've messed with this enough now to know it isn't going to work.

Currently under options > preferences > editing behavior > mouse, we have an option for a track to be selected by left clicking in the arrange.

I was trying to see if I could get this to work by adding a custom action to the right click arrange menu, so I could paste items without having to left click to select a track first.

I've tried this custom action

Track: Select track under mouse
item: Paste items/tracks

Then added that to the ruler/arrange menu, but it doesn't work.

Not exactly what you requested (this can't be added to the right click arrange menu, I'm using a shortcut key here):



For some reason it doesn't work without "refreshing" the selected track first with these lines:
RPR_SetMediaTrackInfo_Value(selTrack, "I_SELECTED", 0)
RPR_SetMediaTrackInfo_Value(selTrack, "I_SELECTED", 1)

Paste item(s) to track under mouse cursor (and to mouse cursor):
Code:
from reaper_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("Paste to track under mouse cursor"):
    RPR_Main_OnCommandEx(41110, 0, 0)   # select track under mouse
    selTrack = RPR_GetSelectedTrack(0, 0)
    RPR_SetMediaTrackInfo_Value(selTrack, "I_SELECTED", 0)
    RPR_SetMediaTrackInfo_Value(selTrack, "I_SELECTED", 1)
    RPR_Main_OnCommandEx(40513, 0, 0)   # move edit cursor to mouse cursor
##    RPR_Main_OnCommandEx(40514, 0, 0)   # move edit cursor to mouse cursor (no snapping)
    RPR_Main_OnCommandEx(40058, 0, 0)   # paste items/tracks
spk77 is offline   Reply With Quote
Old 06-28-2013, 05:27 PM   #146
WyattRice
Human being with feelings
 
WyattRice's Avatar
 
Join Date: Sep 2009
Location: Virginia
Posts: 1,914
Default

spk77,
Many Thanks!

Wyatt
WyattRice is offline   Reply With Quote
Old 07-19-2013, 06:16 PM   #147
devslashnull
Human being with feelings
 
Join Date: Jul 2013
Posts: 4
Default Toggle hardware output from track

Hello, new to the forums and reaper as of today. I've been able to use reascript to do some basic functions. Now looking for a python example for toggling the hardware output for a track? Say from 1/2 to 3/4?

I've read that I should use RPR_GetSetTrackState(), and pass the chunk data as a string into that method. But not sure what parameters GetSetTrackState is looking for. Help or examples is much appreciated!

Also why is perl preferred over python in the forums?
devslashnull is offline   Reply With Quote
Old 07-20-2013, 09:45 AM   #148
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,415
Default

Quote:
Originally Posted by devslashnull View Post
Hello, new to the forums and reaper as of today. I've been able to use reascript to do some basic functions. Now looking for a python example for toggling the hardware output for a track? Say from 1/2 to 3/4?

I've read that I should use RPR_GetSetTrackState(), and pass the chunk data as a string into that method. But not sure what parameters GetSetTrackState is looking for. Help or examples is much appreciated!

Also why is perl preferred over python in the forums?
A related request. I would like to know if it is in any way possible to change a tracks Parent Channels. Is that info in RPR_GetSetTrackState()as well and can it be changed?

Currently, I can setup a bunch of track templates with different parent channels set, and use custom actions to basically make a backdoor switch that sets the Parent channels, but managing all the templates and actions is fugly.
James HE is offline   Reply With Quote
Old 07-20-2013, 12:22 PM   #149
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,583
Default

Quote:
Originally Posted by James HE View Post
A related request. I would like to know if it is in any way possible to change a tracks Parent Channels. Is that info in RPR_GetSetTrackState()as well and can it be changed?

Currently, I can setup a bunch of track templates with different parent channels set, and use custom actions to basically make a backdoor switch that sets the Parent channels, but managing all the templates and actions is fugly.
Here are 3 scripts: main script + two examples. Keep all the files in the same folder and load "Set channels to 3_4.py" and "Set channels to 5_6.py" from ReaScript: New/load.



Download:
https://stash.reaper.fm/17258/Set%20t...20channels.zip

edit. Comment out line 36 "msg(newChunk)" in "Set_track_parent_channels.py" to get rid of the "reascript console output" -window

Last edited by spk77; 07-20-2013 at 12:28 PM.
spk77 is offline   Reply With Quote
Old 07-20-2013, 01:02 PM   #150
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,415
Default

Quote:
Originally Posted by spk77 View Post
Here are 3 scripts: main script + two examples. Keep all the files in the same folder and load "Set channels to 3_4.py" and "Set channels to 5_6.py" from ReaScript: New/load.


Download:
https://stash.reaper.fm/17258/Set%20t...20channels.zip

edit. Comment out line 36 "msg(newChunk)" in "Set_track_parent_channels.py" to get rid of the "reascript console output" -window
YAY!!!!!!!!

I haven't tested yet, but thank you!
James HE is offline   Reply With Quote
Old 07-20-2013, 01:34 PM   #151
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,583
Default

Quote:
Originally Posted by James HE View Post
YAY!!!!!!!!

I haven't tested yet, but thank you!
I hope that it's working correctly. This is the line (f.ex) in chunk which "sets" the parent channels: MAINSEND 1 0
  • '1' = Master/parent enabled (0 would be Master/parent disabled)
  • the last '0' = parent channel 1/2 (if track has 2 channels). I guess "0" here is the line index in "parent channels" drop-down menu)

Last edited by spk77; 07-20-2013 at 01:40 PM.
spk77 is offline   Reply With Quote
Old 07-20-2013, 02:25 PM   #152
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,415
Default

Quote:
Originally Posted by spk77 View Post
I hope that it's working correctly. This is the line (f.ex) in chunk which "sets" the parent channels: MAINSEND 1 0
  • '1' = Master/parent enabled (0 would be Master/parent disabled)
  • the last '0' = parent channel 1/2 (if track has 2 channels). I guess "0" here is the line index in "parent channels" drop-down menu)
thank you for clarifying this. for my purposes, I'll need MAINSEND 0 (x) for the most part.

I guess I'll have to make multiple scripts? 64 (mono) + 32 (stereo) (Yeowch!)

This invalidates a lot of work I've already done, and also means a lot of other work for me as well. (grumble) BUT!.... This (along with some other trickery ) will allow me to create something that will pretty much make the routing for my VCA JS plugs truly automatic
James HE is offline   Reply With Quote
Old 07-20-2013, 03:30 PM   #153
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,583
Default

Quote:
Originally Posted by James HE View Post
thank you for clarifying this. for my purposes, I'll need MAINSEND 0 (x) for the most part.

I guess I'll have to make multiple scripts? 64 (mono) + 32 (stereo) (Yeowch!)

This invalidates a lot of work I've already done, and also means a lot of other work for me as well. (grumble) BUT!.... This (along with some other trickery ) will allow me to create something that will pretty much make the routing for my VCA JS plugs truly automatic
Here's a "Set track parent channels" script generator It writes 64 ".py" files (into the same folder where the script is). Probably needs some modification to get the desired undo point -names and filenames.

Code:
script = """from Set_track_parent_channels import *
from contextlib import contextmanager

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

with undoable("""

for i in range(0, 64):
    j = i
    if i == 63:
        j = i - 1
    newFile = script + "'" + "Set parent channels to " + str(i + 1) + "/" + str(j + 2) + "'" + "):" + "\n" + "    setParentChannels(" + str(i)+ ")"
    fileName = "Set_track_parent_channels " + str(i) + ".py"
    with open(fileName, "w") as f:
        f.writelines(newFile)

Last edited by spk77; 07-20-2013 at 03:38 PM.
spk77 is offline   Reply With Quote
Old 07-20-2013, 07:12 PM   #154
devslashnull
Human being with feelings
 
Join Date: Jul 2013
Posts: 4
Default

SPK77, do you think or know if it's possible to toggle the audio hardware outputs on a track?

How did you learn to edit the chunk data, I can't understand the formatting. Thank you.
devslashnull is offline   Reply With Quote
Old 07-21-2013, 12:55 AM   #155
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,583
Default

Quote:
Originally Posted by devslashnull View Post
SPK77, do you think or know if it's possible to toggle the audio hardware outputs on a track?

How did you learn to edit the chunk data, I can't understand the formatting. Thank you.
Information about chunks: http://wiki.cockos.com/wiki/index.ph...tSetTrackState

I used this script (below) to get the track chunk before adding a hardware out and after adding a hw-out. Then I copied them from the ReaScript console output and pasted to Notepad++. Then, by using an extension plugin called "Compare" in (np++), I got this result:

Hardware out 1/2 added:


I can't really understand the "HWOUT" line formatting here, though.

Get track chunk (from the first selected track):
Code:
from reaper_python import *

def msg(m):
    RPR_ShowConsoleMsg(m)

selTrackCount = RPR_CountSelectedTracks(0)
if selTrackCount > 0:
    selTrackId = RPR_GetSelectedTrack(0, 0)
    chunk = RPR_GetSetTrackState2(selTrackId, "", 1024*1024*4, 1)[2]
    msg(chunk)

else:
    msg("Select 1 track")

Last edited by spk77; 07-21-2013 at 11:40 PM.
spk77 is offline   Reply With Quote
Old 07-21-2013, 07:52 PM   #156
devslashnull
Human being with feelings
 
Join Date: Jul 2013
Posts: 4
Default

That's very helpful! thank you!

I setup something similar with sublime text 2 and sublimemerge package. I can see the difference between the chunkdata.

Now I'm looking at some of your other scripts trying to understand how you're passing the modified chunk data to the object. A bit over my head, but pieces of your scripts make sense to me.

thanks again.
devslashnull is offline   Reply With Quote
Old 08-01-2013, 11:33 AM   #157
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,415
Default

Quote:
Originally Posted by spk77 View Post
I hope that it's working correctly. This is the line (f.ex) in chunk which "sets" the parent channels: MAINSEND 1 0
  • '1' = Master/parent enabled (0 would be Master/parent disabled)
  • the last '0' = parent channel 1/2 (if track has 2 channels). I guess "0" here is the line index in "parent channels" drop-down menu)
Finally got python working correctly.

Working great! One odd little behavior with this script, After running the script, any plug-in parameters that were shown in the tcp/mcp disappear.

If I make a macro that cuts the FX chain, runs the script, then pastes the FX chain, It works fine, so it's no big deal (hopefully). Still. I wonder why it does that? and if it can be avoided?
James HE is offline   Reply With Quote
Old 08-01-2013, 12:17 PM   #158
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,583
Default

Quote:
Originally Posted by James HE View Post
Finally got python working correctly.

Working great! One odd little behavior with this script, After running the script, any plug-in parameters that were shown in the tcp/mcp disappear.

If I make a macro that cuts the FX chain, runs the script, then pastes the FX chain, It works fine, so it's no big deal (hopefully). Still. I wonder why it does that? and if it can be avoided?
This should fix it:

Try to change line 13 in "Set_track_parent_channels.py"
oldChunkL = RPR_GetSetTrackState2(selTrackId, "", 1024*1024*4, 1)[2].split("\n")

to
oldChunkL = RPR_GetSetTrackState2(selTrackId, "", 1024*1024*4, 0)[2].split("\n")
spk77 is offline   Reply With Quote
Old 08-01-2013, 05:17 PM   #159
semiquaver
Human being with feelings
 
Join Date: Jun 2008
Posts: 4,914
Default

Hey folks! here is a script I could really use:

I would like an action to set midi items to ignore project tempo and use instead the tempo at the time position they start at!

straighforward enough except for the dreaded chunk parsing...

TIA
semiquaver is offline   Reply With Quote
Old 08-01-2013, 06:51 PM   #160
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,415
Default

Quote:
Originally Posted by spk77 View Post
Here's a "Set track parent channels" script generator It writes 64 ".py" files (into the same folder where the script is). Probably needs some modification to get the desired undo point -names and filenames.

Code:
script = """from Set_track_parent_channels import *
from contextlib import contextmanager

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

with undoable("""

for i in range(0, 64):
    j = i
    if i == 63:
        j = i - 1
    newFile = script + "'" + "Set parent channels to " + str(i + 1) + "/" + str(j + 2) + "'" + "):" + "\n" + "    setParentChannels(" + str(i)+ ")"
    fileName = "Set_track_parent_channels " + str(i) + ".py"
    with open(fileName, "w") as f:
        f.writelines(newFile)

The script to create files was great thanks spk! you sir, are the bees knees.

(the fix for the shown parameter knobs worked as well)

very minor nit pick is that the script names start at 0 and channels names start at 1. but this is not even an issue, really.

I have a general question about getting these into the action list. I can only figure out how to do them one at a time.

For future reference, is there a way to import scripts to the action list in masse?

(apologies if this is covered elsewhere.)

(one almost good side effect of doing this one at a time is that I don't have to worry about renaming "...1" "...2" etc... to "...01" "...02" in order to get the Cmd ID's to be in order.)

Last edited by James HE; 08-01-2013 at 07:12 PM.
James HE 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 09:12 PM.


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