Old 09-03-2012, 09:10 AM   #1
Lawrence
Human being with feelings
 
Join Date: Mar 2007
Posts: 21,551
Default Script Request Sticky?

Is it possible to make a "sticky thread" to make scripting requests from the scripting guys like Viente and Tim?

I see them doing a lot of that, quickly making new scripts to solve various issues, but all that stuff is kinda scattered all over the forum. It might be nice to go to one place and say...

"Hey! Can anyone create a quick script to _________?"

And have the scripts attached and listed there in one thread along with discussions about how they work.

I for one haven't devled into ReaScript much. The language doesn't look all that difficult for me having done Javascript and similar, but I assume to some others with no coding background at all it kinda looks like Greek.

Thanks.
Lawrence is offline   Reply With Quote
Old 09-03-2012, 09:16 AM   #2
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

I would like to share. Though i'm a complete noob in ReaScript i have a bunch of usefull scripts people may like (Thanks to Tim, gofer and IXix)
Viente is offline   Reply With Quote
Old 09-14-2012, 12:47 PM   #3
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default quantisation of parameter automation values

Hey! Can anyone create a quick script to quantise parameter automation values?

I'm interested in both quantisation on the time scale (e.g. values should be shifted towards the nearest 16th note grid line, while preventing multiple values on the same position on the timeline) and/or on the value range (e.g. for a parameter that affects tuning with a range of -12 to 12 semi-tones, it should be able to divide the 0.0-1.0 range in 25 steps, i.e. 0.00, 0.04, 0.08, 0.12, ... 0.96, 1.00).
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 09-17-2012, 11:17 PM   #4
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Select all items with same colors and solo their tracks

https://stash.reaper.fm/v/14022/Selec...ame%20color.py

Viente is offline   Reply With Quote
Old 09-24-2012, 12:44 PM   #5
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,528
Default

I see there is GetCursorContext command.
Can anyone make a script that opens toolbar at each condition?
Sexan is offline   Reply With Quote
Old 09-24-2012, 12:58 PM   #6
gwok
Human being with feelings
 
gwok's Avatar
 
Join Date: Jun 2010
Location: canada
Posts: 3,396
Default

I could really use "set selected items to one random custom color per track"
gwok is offline   Reply With Quote
Old 09-24-2012, 01:01 PM   #7
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Quote:
Originally Posted by gwok View Post
I could really use "set selected items to one random custom color per track"
Here you go!
https://stash.reaper.fm/v/14093/Auto%...all%20items.py
Viente is offline   Reply With Quote
Old 09-24-2012, 01:22 PM   #8
gwok
Human being with feelings
 
gwok's Avatar
 
Join Date: Jun 2010
Location: canada
Posts: 3,396
Default

thanks man - though I'm getting this -

"Script execution error

Traceback (most recent call last):
File "Auto color all items.py", line 1
SAVESEL = RPR_NamedCommandLookup('_SWS_SAVESEL')
^
SyntaxError: invalid syntax
"

just update python to 3.23, same result though (osx 10.6.8)
gwok is offline   Reply With Quote
Old 09-24-2012, 01:24 PM   #9
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Hmm...working here.

Do you have SWS Extension?
Viente is offline   Reply With Quote
Old 09-24-2012, 01:25 PM   #10
gwok
Human being with feelings
 
gwok's Avatar
 
Join Date: Jun 2010
Location: canada
Posts: 3,396
Default

yep, how would that have an effect?

I'll update sws now....

edit: updated SWS same result
gwok is offline   Reply With Quote
Old 09-24-2012, 02:22 PM   #11
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Maybe something with text encoding...i dont know really
It works on Windows 7
Viente is offline   Reply With Quote
Old 09-24-2012, 02:30 PM   #12
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,528
Default

Viente is that possible what I've posted above?
Sexan is offline   Reply With Quote
Old 09-24-2012, 02:33 PM   #13
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Could you please explain a little bit more what you want?
Viente is offline   Reply With Quote
Old 09-24-2012, 02:39 PM   #14
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,528
Default

int GetCursorContext()
0 if track panels, 1 if items, 2 if envelopes, otherwise unknown
can it be made so when state is 0 trigger action X,1 trigger action Y,2 trigger action Z ?
Sexan is offline   Reply With Quote
Old 09-24-2012, 02:40 PM   #15
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

I'll take a look now
Viente is offline   Reply With Quote
Old 09-24-2012, 02:41 PM   #16
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,528
Default

you are da maaaaaaaan!!
Sexan is offline   Reply With Quote
Old 09-24-2012, 02:51 PM   #17
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

Yes, but not realtime of course

Code:
cur = RPR_GetCursorContext()

if cur == 0: #panels
  ...do your actions....

elif cur == 1: #items
  ...do your actions....

elif cur == 2: #envelopes
  ...do your actions....
Viente is offline   Reply With Quote
Old 09-24-2012, 03:08 PM   #18
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

use RPR_Main_OnCommand(#,0)

within each condition, where # - number of action (i.e open toolbar)
Viente is offline   Reply With Quote
Old 09-24-2012, 03:13 PM   #19
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

gwok Please ignore this script. It won't work for you at the moment. I've just looked into the code and it was written very old and for my own project template.

I will make a new one

Veto, yeah probably
Viente is offline   Reply With Quote
Old 09-24-2012, 03:19 PM   #20
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

gwok, try this (and make sure you use the latest beta)

https://stash.reaper.fm/v/14095/Rando...ted%20track.py
Viente is offline   Reply With Quote
Old 09-24-2012, 03:40 PM   #21
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

And if you already downloaded, pls download again, i've improved it a bit

Just select any items on any tracks and it will color all items on this tracks to one random color

https://stash.reaper.fm/v/14096/Rando...ted%20track.py
Viente is offline   Reply With Quote
Old 09-24-2012, 04:16 PM   #22
gwok
Human being with feelings
 
gwok's Avatar
 
Join Date: Jun 2010
Location: canada
Posts: 3,396
Default

hey, thanks Viente - though I'm still getting an error

"Script execution error

Traceback (most recent call last):
File "Random color selected track.py", line 1
from reaper_python import *
^
SyntaxError: invalid syntax"

though I never use reascript, so maybe it is my configuration, and not your script. I'm on pre11, newest SWS, python 3.23.

Maybe I'll test some other scripts on the stash amd see if anything else works.
gwok is offline   Reply With Quote
Old 09-24-2012, 04:19 PM   #23
Viente
Human being with feelings
 
Viente's Avatar
 
Join Date: Feb 2012
Posts: 1,972
Default

A really weird behavior to be honest

it tells its error already in the first line which is

from reaper_python import *
Viente is offline   Reply With Quote
Old 09-24-2012, 04:23 PM   #24
gwok
Human being with feelings
 
gwok's Avatar
 
Join Date: Jun 2010
Location: canada
Posts: 3,396
Default

ya, so it's probably my system. I'll test some other things and post back when I know whats up

thanks
gwok is offline   Reply With Quote
Old 10-27-2012, 11:36 AM   #25
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Awesome! Big ups, Veto! Those definitely looks small and simple enough to wrap my head around, so it looks like a perfect starting point for a bit of hacking. I owe you a beer or two. Or perhaps you prefer a good smoke, if you happen to come by Amsterdam some day.

I hope to have some time this weekend to study them more intensively (I'm currently on a flakey smartphone connection and have older versions of SWS - downloading new one now… slowly - and Python (2.7.2). And I think I should do a proper system backup before messing with that…)
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 10-27-2012, 04:47 PM   #26
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Quote:
Originally Posted by Veto View Post
oh Banned wait a sec, before you're downloading hours for nothing, Python 2.7.2 wont work, sorry. There are some methods in the scripts which probably only work with the 3.x versions.

Just ask if you need help in any way about the scripts. And if you're like me, prefering a quantize dialog, be sure to check out that new script.

haha thanks i'm not such a big fan of both, but i'd love to see Amsterdam some day and when one happens to be in Amsterdam...
Let me know whenever you happen to be in the neighbourhood.

Yeah, I already had Python 2.7.2 installed (came with OS 10.8), but figured it might not work (and it didn't), so I grabbed the 3.2.3 version. But I couldn't get REAPER to work with it at first. In Preferences > ReaScript > Force Python to use dylib; I had entered
Code:
/Library/Frameworks/Python.framework/Versions/3.2/lib/libpython3.2.dylib
but REAPER told me its an incompatible version.

When I clicked the .dylib path button, the location of Python 2.x showed up - so I figured the description of Preferences > ReaScript > Custom path to dll directory must be wrong: on a Mac, there are typically no .dll files, so I started reading "dll" as ".dylib" instead. Then I removed the line from "Force Python to use dylib", and entered the path:
Code:
/Library/Frameworks/Python.framework/Versions/3.2/lib/
in the "Custom path to dll directory". Yay, REAPER now tells me: libpython3.2.dylib installed. (I have no idea why the first didn't work, but the second did. I tried this in both 32 and 64 bit versions of REAPER, with the same results. Perhaps this should be filed as a bug?)

However, I still get the same script execution error as before, it seems to fail to import the python functions from the SWS extension:

Code:
Traceback (most recent call last):
  File "Quantize selected points.py", line 7, in <module>
    from sws_python import *
ImportError: No module named sws_python
I do have SWS/S&M Extension 2.3.0 Build #7 installed now, btw. Perhaps I need a system reboot or such? I'll have another go at it tomorrow for sure. Also, staring at the code until it makes enough sense is already *very* useful for me at this point.
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 10-28-2012, 05:19 AM   #27
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Quote:
Originally Posted by Veto View Post
i'm sorry, i really wish i would actually know more than nothing about ReaScript on OS
I hope that some of the mac folks here can advise you with their experience.

Do you find a "sws_python.py" module in programs/REAPER/plugins (? for Mac).
Did you had the SWS module working with 2.7.2 ? If so, it would be no hassle to write the scripts to work with that version if thats okay.
Just out of interest, when Reaper says the py-lib is installed, does f.e.
PHP Code:
from reaper_python import *
RPR_APITest() 
gives you success?

Nevertheless i really think this qualifies as a bug on both sides, Reaper and SWS.
No, I had the same error when REAPER was using Python 2.7.2.

On my system that file is located here:
Code:
~/Library/Application Support/REAPER/Scripts/sws_python.py
There is a folder named "Plugins" only at:
Code:
/Applications/REAPER.app/Contents/Plugins
(But I don't think I'm supposed to mess with the contents of the app bundle, even though that might work as a workaround.)

A Test.py script containing just the lines you pasted works fine: "test ok".

No worries, I'm sure one of the Mac users will chime in at some point, and I'm not in a hurry. Thanks again for your help anyway, much appreciated.
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 10-28-2012, 06:39 AM   #28
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

I guess it could be related to this: http://forum.cockos.com/showthread.p...cript sys.path

That is, it seems that Python does not know where to find sws_python.py, so I should somehow point it to ~/Library/Application Support/REAPER/Scripts/. I don't see a sys.path file anywhere here though.
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 10-28-2012, 09:25 AM   #29
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

That one explains setting the path *to* Python, so the system (and REAPER) knows where to find Python. I already have that working, it seems. My problem is rather that Python can't find the modules in REAPER's "Scripts" folder, so I need to set the paths that Python itself uses. Another page linked from that one seemed more relevant though: http://www.ehow.com/how_10071616_mak...s-syspath.html. While it was helpful (I now at least know what my sys.path looks like, it is not a file), unfortunately it still did not solve the problem. I made a file named "path_to_sws_python.pth", containing the line
Code:
~/Library/Application\ Support/REAPER/Scripts
and placed in in the folder
Code:
/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/
but it doesn't show that path when I quit and restart python and make it show sys.path again.
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 10-28-2012, 09:35 AM   #30
Kainer
Human being with feelings
 
Kainer's Avatar
 
Join Date: Nov 2007
Location: Cologne/Bangkok
Posts: 1,258
Default

Reaper can render time selection, entire project, custom time range and project regions.

Isn't it possible to render/bounce each stem (selected track) in the right length/duration (tracklength in the arrangement window) with the help of some script?


(What we are getting now is: tracks all in duration of the longest track. Silence at the end of most tracks. Not useful).
__________________
I am old here

http://kainerweissmann.de
Kainer is offline   Reply With Quote
Old 10-28-2012, 01:01 PM   #31
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Awesome, that works!

I'm sure I'll figure out what the problem is when I get a bit more comfortable with Python; as already noted, it may be just be a little bug somewhere. For now, at least I know how to work around the issue and start having some hacking fun.

Big thanks again for your help!
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 10-28-2012, 06:57 PM   #32
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

[IMG]http://**************/a/img843/695/blushiesmall.png[/IMG]
Okay, after getting a bit more familiar with Python, it turns out that it was just a quite silly mistake on my part: when I unzipped your scripts, I had simply placed the resulting *folder* in /Scripts, so they actually were *not* in the exact same folder as sws_python.py, as required. Dragging them one level up solved the error. Anyway, making such silly mistakes is an essential part of learning.
</blush>

Before trying to expand its functionality (I already have a couple of ideas to keep me motivated to dig in further), I'm now trying to get a bit more familiar with the syntax first. Modifying your script to my style preferences was a great exercise. I should probably do a few tutorials and get a bit more familiar with the Python standard library and specifics of ReaScript next.

Btw, Live 9 will also get automation curves, but will apparently not yet have quantisation for automation values. Thanks for helping keep REAPER yet another step ahead of the curve.
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 11-04-2012, 08:10 PM   #33
gwok
Human being with feelings
 
gwok's Avatar
 
Join Date: Jun 2010
Location: canada
Posts: 3,396
Default

not sure if this is possible with reascript, or if someone could\would do it, though this action would be really useful

"open new project tab with current projects' bpm\time signature'

possible with reascript?
gwok is offline   Reply With Quote
Old 11-05-2012, 07:18 PM   #34
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,340
Default

@gwok,

I'm 99.9% sure it's possible. I'm not on my REAPER machine right now so I can't test it out. If no one else posts a solution I'll see what I can cook up and post either late tonight or possibly tomorrow.
Anton9 is offline   Reply With Quote
Old 11-05-2012, 08:11 PM   #35
gwok
Human being with feelings
 
gwok's Avatar
 
Join Date: Jun 2010
Location: canada
Posts: 3,396
Default

@Anton9

that would be awesome man, thanks! no rush here - (workin 120bpm atm)
gwok is offline   Reply With Quote
Old 11-07-2012, 01:33 AM   #36
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,340
Default

@gwok,

Ok so I messed around a little bit and this is what I came up with.
It's not the best solution, but it does work. What this script does is it will get the time sig. and BPM at the edit cursor position(this is handy if your project has any tempo/time sig. changes). It then creates a new project tab and sets it's time sig and BPM to match. However because the ReaScript API does'nt have a function for setting the time sig of a project directly without adding a time sig marker the new project tab will include a time sig marker at the begining. I'm going to put in a request to the devs for a set project time sig function and if it's added I'll update the script.

You may also notice in the script there are commands that switch to the previous project tab and then back to the new one.., these had to be added because the transport does'nt refresh with the settings contained in the time sig. marker until playback occurs or like I discovered until you switch tabs. The switch happens really fast so you should'nt even really notice it.

I did come up with another way of creating a new project based on current projects time/BPM using the SNM_SetIntConfigVar() and SNM_SetDoubleConfigVar() functions which would'nt require a marker being added to the new project. However it also has a transport refresh issue so I'm not posting that script for now.

Code:
 
# TEST  (Gets Time sig. and Tempo at cursor position then creates a new project tab with these settings.)

curProj = 0
CurPos = RPR_GetCursorPosition()
Tnum = 0	# Time sig. numerator
Tdnom = 0	# Time sig. denominator
BPM = 0
x = RPR_TimeMap_GetTimeSigAtTime(curProj, CurPos, Tnum, Tdnom, BPM)	# Gets the time sig. and BPM of current project at cursor position

RPR_Main_OnCommand(40859,0)	#Creates new project tab
RPR_SetTempoTimeSigMarker(0, -1, 0, 0, 0, x[4], x[2], x[3], 0)	# Sets new project tabs time sig. and BPM
RPR_UpdateTimeline()	#Updates the timeline
RPR_Main_OnCommand(40862, 0)	# Previous project tab
RPR_Main_OnCommand(40861, 0)	# Next project tab
Anton9 is offline   Reply With Quote
Old 11-07-2012, 10:47 AM   #37
gwok
Human being with feelings
 
gwok's Avatar
 
Join Date: Jun 2010
Location: canada
Posts: 3,396
Default

Thanks Anton9, so far it's working great. Just had a chance to test quick, but it's totally solid, and I don't see any issues caused by recalling the original tab for that refresh issue.


great stuff, thanks again

g
gwok is offline   Reply With Quote
Old 11-13-2012, 02:40 PM   #38
gwok
Human being with feelings
 
gwok's Avatar
 
Join Date: Jun 2010
Location: canada
Posts: 3,396
Default

another request in the tempo\time sig vein if anyone is up to it. Store and recall tempo\time sig actions.

So in one tab the settings can be stored, then in another hit load\recall and the settings are set.

thanks,

g
gwok is offline   Reply With Quote
Old 11-14-2012, 01:34 AM   #39
Anton9
Human being with feelings
 
Anton9's Avatar
 
Join Date: Jun 2009
Location: Earth
Posts: 1,340
Default

Hey gwok,

Well thanks to a tip from Jeffos I am now posting the other script I mentioned. It basically does the same thing as the other one except it does'nt put a time sig marker in the new project and it also does'nt rely on the tab switch trick. If I get some time I'll have a try at your other request.

Code:
#Copies the time sig and BPM at the edit cursor's position and creates a new project with these settings

from sws_python import *

curProj = 0
CurPos = RPR_GetCursorPosition()
Tnum = 0	# Time sig. numerator
Tdnom = 0	# Time sig. denominator
BPM = 0
x = RPR_TimeMap_GetTimeSigAtTime(curProj, CurPos, Tnum, Tdnom, BPM)	# Gets the time sig. and BPM of current project at cursor position

RPR_Main_OnCommand(40859,0)	#Creates new project tab

SNM_SetIntConfigVar("projmeaslen", x[2])	#Sets the new projects time sig numerator 
SNM_SetIntConfigVar("projtsdenom", x[3])	#Sets the new projects time sig denominator
RPR_SetCurrentBPM(0, x[4], False)	#Sets the new projects BPM
Anton9 is offline   Reply With Quote
Old 11-14-2012, 01:40 PM   #40
gwok
Human being with feelings
 
gwok's Avatar
 
Join Date: Jun 2010
Location: canada
Posts: 3,396
Default

hey Anton,

thanks for the update, though I'm getting an error with the new script -

[IMG]http://img703.**************/img703/1516/screenshot20121114at139.png[/IMG]

Uploaded with **************
gwok is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:28 PM.


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