Old 04-09-2019, 04:02 AM   #41
Centauria
Human being with feelings
 
Join Date: Apr 2019
Posts: 3
Default

Hey bro, when I ran python -m reapy, it can't find python.dll

================================================== =
(py36) C:\Users\Administrator>python -m reapy
D:\PF\Anaconda3\envs\py36\lib\site-packages\reapy\tools\dist_program.py:14: Disa
bledDistAPIWarning: Can't reach distant API. Please start REAPER, or call reapy.
config.enable_dist_api() from inside REAPER to enable distant API.
warnings.warn(DisabledDistAPIWarning())

======================
reapy config infos
======================

Python DLL
----------
Can't find python DLL...

Enable or disable reapy dist API
--------------------------------
Enable dist API
D:\PF\Anaconda3\envs\py36\lib\site-packages\reapy\reascripts\enable_dist_api
.py

Disable dist API
D:\PF\Anaconda3\envs\py36\lib\site-packages\reapy\reascripts\disable_dist_ap
i.py
==================================================





and I ran into an issue when I was trying to run enable_dist_api.py in REAPER


================================================== =
Script execution error

Traceback (most recent call last):
File "enable_dist_api.py", line 12, in <module>
import reapy
ModuleNotFoundError: No module named 'reapy'
================================================== =

why can't find the module reapy?
I am sure about the version of python is the one REAPER uses.
Help...
Centauria is offline   Reply With Quote
Old 04-09-2019, 04:40 AM   #42
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 24
Default

@nir.arad

To be honest I am puzzled by your bug... I'll let you know if I find out where that comes from.

@Centauria

It seems you have installed reapy through Anaconda? I am not an Anaconda expert but from your traceback I am guessing REAPER might have trouble finding the path to your conda environment... Could you try running the following inside REAPER and show us the result?

Code:
import sys
RPR_ShowConsoleMsg(sys.path)
romeo_despres is offline   Reply With Quote
Old 04-09-2019, 05:09 AM   #43
Centauria
Human being with feelings
 
Join Date: Apr 2019
Posts: 3
Default

The output is


['C:/Users/Administrator/AppData/Roaming/REAPER/Scripts', 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\Lib', 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\DLLs', 'D:\\PF\\REAPER (x64)', 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64', 'C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python36_64\\lib\\site-packages', 'D://PF//REAPER (x64)//Plugins']

thx.
Centauria is offline   Reply With Quote
Old 04-09-2019, 05:23 AM   #44
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 24
Default

Thanks. So you can see that the place where reapy is located (D:\PF\Anaconda3\envs\py36\lib\site-packages) is not in sys.path by default when you run Python outside Anaconda. That explains why REAPER can't find it.

You can extend sys.path permanently by creating a path configuration file.

In your case, go to C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages and create a .pth file (for instance, "anaconda_env.pth") containing the following:

Code:
D:\PF\Anaconda3\envs\py36\lib\site-packages
If I'm not missing anything about Anaconda, you should now be able to import reapy from inside REAPER and thus to enable the distant API.

Last edited by romeo_despres; 04-09-2019 at 05:29 AM.
romeo_despres is offline   Reply With Quote
Old 04-09-2019, 09:27 AM   #45
Centauria
Human being with feelings
 
Join Date: Apr 2019
Posts: 3
Default

It worked!
Thank you
Centauria is offline   Reply With Quote
Old 04-21-2019, 12:29 PM   #46
chabErch
Human being with feelings
 
Join Date: Feb 2017
Posts: 1
Default

Hi @romeo_despres, great work!

Is it possible to run sws scripts with reapy?
chabErch is offline   Reply With Quote
Old 04-21-2019, 03:15 PM   #47
fladd
Human being with feelings
 
fladd's Avatar
 
Join Date: May 2006
Posts: 940
Default

This is great! I already thought I'm the only one who cares about pep8 :-)
__________________
www.fladd.de/sound
fladd is offline   Reply With Quote
Old 05-13-2019, 08:59 AM   #48
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 24
Default

Quick update: thanks to chabErch's contribution, SWS functions can now be run from outside REAPER with reapy. More precisely, if the SWS extension is installed, then reapy.reascript_api contains all functions in sws_python; otherwise it only contains native ReaScript functions.
romeo_despres is offline   Reply With Quote
Old 05-13-2019, 10:31 AM   #49
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,032
Default

@romeo_despres
Cool !


Does it also contains JS_ReaScript and Reapack API functions ?
X-Raym is offline   Reply With Quote
Old 05-14-2019, 02:48 AM   #50
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 24
Default

I have only recently discovered these and haven't been able to make them work yet (I posted a related question recently but didn't get any reply...) But it would definitely make sense to include them as well
romeo_despres is offline   Reply With Quote
Old 05-14-2019, 03:53 AM   #51
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,032
Default

Ok so it is not an automatic way to load all extensions API.
Thanks for the infos !
X-Raym is offline   Reply With Quote
Old 05-14-2019, 06:01 AM   #52
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,050
Default

Quote:
Originally Posted by romeo_despres View Post
I have only recently discovered these and haven't been able to make them work yet (I posted a related question recently but didn't get any reply...) But it would definitely make sense to include them as well
Maybe post in the related threads (here and here) for them to not miss it.
nofish is offline   Reply With Quote
Old 05-14-2019, 06:39 AM   #53
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 24
Default

Quote:
Originally Posted by X-Raym
Ok so it is not an automatic way to load all extensions API.
Thanks for the infos !
That's what I was trying to do in the first place... Someday hopefully

@nofish

Thanks you're right I'll do that!
romeo_despres is offline   Reply With Quote
Old 05-14-2019, 08:01 AM   #54
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,050
Default

@romeo_despres

Not sure if it helps, but SWS uses a Pearl script to generate the Python function wrappers:
https://github.com/reaper-oss/sws/bl...ript_python.pl
nofish is offline   Reply With Quote
Old 05-14-2019, 11:08 AM   #55
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,558
Default

Somebody made one for JS-extension, even if it's a little outdated. Just browse through the JS-extension-thread. Maybe you can use it and update it.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 05-28-2019, 01:22 AM   #56
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,032
Default

Quote:
Great I'm glad it eventually worked! About your "command window" problem, I have found this which seems to answer your question (I wasn't aware of that technique and haven't tried it though).
I confirm that running a reapy script on windows by double cliking on it on WIndows is possible without having CMD window by having extension set to .pyw instead of .py.


--
Here is a minimal tkinter code snippet for reapy:


https://github.com/ReaTeam/ReaScript...er%20reapy.pyw

It is not extra quick to launch (count 1-2 seconds), I don't know if it is reapy limitation or just python. Script run from action list are quicker (but they still keyboard focus).
X-Raym is offline   Reply With Quote
Old 05-28-2019, 02:58 AM   #57
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 24
Default

Quote:
Originally Posted by X-Raym View Post
It is not extra quick to launch (count 1-2 seconds), I don't know if it is reapy limitation or just python. Script run from action list are quicker (but they still keyboard focus).
On my computer, both are quite slow: starting Python itself, but also importing reapy from outside REAPER. It indeed requires several interactions with the REAPER Web Interface, which is pretty slow.
romeo_despres is offline   Reply With Quote
Old 05-28-2019, 04:07 AM   #58
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 6,032
Default

Quote:
On my computer, both are quite slow: starting Python itself, but also importing reapy from outside REAPER. It indeed requires several interactions with the REAPER Web Interface, which is pretty slow.

It is not that a problem if the scripts seems complex (like have a nice polish GUI with lots of elements), but it really feels not good if it is just a single user input.


But I don't think anything can be done on this so we'll live with it.
It still have a lot of advantage compare to native way (like allowing all kind of python dependencies and not stealing keyboard focus).
X-Raym is offline   Reply With Quote
Old 05-28-2019, 05:21 AM   #59
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 24
Default

Indeed one probably has to wonder which option is best depending on the complexity of the program. For a simple user input, I guess it's better to use the ReaScript function "GetUserInputs" from inside REAPER. It makes me realize there is no reapy counterpart to this function, which is once again not very easy to use for a standard Python programmer... I'll try to add one soon!
romeo_despres is offline   Reply With Quote
Old 06-06-2019, 01:38 AM   #60
Kostik Vento
Human being with feelings
 
Join Date: Nov 2013
Location: Yekaterinburg, Russia
Posts: 11
Default

Quote:
Originally Posted by romeo_despres View Post
I think this project can become interesting only if other people in the community provide feedback and improvement, on the code itself as well as the documentation, structure, etc. So please don't hesitate to try it out and report bugs or missing features. And if you feel like coding yourself, feel free to fork the repository! As a Python ReaScripter, I know you dream like me of a well-established community-based REAPER API!
That's about me)) I like both Python and Reaper, I do dream, so I've forked ))
And I do have some suggestions about improvements, would you prefer to discuss them here or on GitHub?

Quote:
Originally Posted by romeo_despres View Post
P.P.S. reapy should be cross-platform but since I have only tested it on Windows I couldn't swear. Yet I do think this is an important feature. We all love REAPER for Linux.
I've tried on MacOSX Sierra, it works fine for me. There are, still, minor bugs, I've opened pull requests for them, hope to see them reviewed soon))
And there's a serious bug I've almost run into — if your reaper.ini contains non-ASCII chars, rewriting config would crash half-way with the rest of your settings gone( My luck was to have the file opened in a text editor which had the full copy of the lost contents.

P.S. I made it work under Python2 (except enable/disable_dist_api), but the resulting code lost its pythonicity a bit, so I'll keep refactoring. And alas, you can't use reapy.print in Python2 because print is reserved there and cannot be used as identifier.

Last edited by Kostik Vento; 06-06-2019 at 01:54 AM.
Kostik Vento is offline   Reply With Quote
Old 06-06-2019, 05:41 AM   #61
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 24
Default

Thank you a lot for your help! I think the simplest is to communicate on GitHub as you did. I've seen your requests but been very busy lately so I haven't been able to review them in detail... But they seem to fix a lot of important issues! I'll try to reply to you asap there
romeo_despres is offline   Reply With Quote
Old 10-03-2019, 03:10 PM   #62
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 53
Default How invoke?

I'm a little confused on how to invoke the python script that uses reapy.

I actually want the script to run OUTSIDE of Reaper, but I want to be able to invoke the script from WITHIN Reaper, say via an Action item (or a Button and/or a shortcut).

Would I need a small script to call it, that just runs maybe one of these:
ExecProcess()
or
reaper.CF_ShellExecute()
and supplying the full path name to my python script, e.g.
Code:
ExecProcess("C:\some\path\to\my_python_script.py")
Or am I making this too hard?
tparker24 is offline   Reply With Quote
Old 10-06-2019, 09:23 AM   #63
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 24
Default

I think you're right, the correct way to do that would be to have two scripts, one that runs inside REAPER and looks like:

Code:
RPR_ExecProcess('py path/to/external_script.py', -1)
and a second one (external_script.py) which is the actual reapy app.
romeo_despres is offline   Reply With Quote
Old 10-06-2019, 10:01 AM   #64
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 53
Default

Ok, thanks for confirming.

I've just started using reapy, and I'm very impressed! It was easy to install and seems very straightforward to use. Running python outside of Reaper really opens up some possibilities, because some python things don't run too well (or at all) inside the Reaper environment ... for example PyQt or wXPthon, two powerful GUI programs.

reapy kind of unleashes python. Thanks for making it available.


Quote:
Originally Posted by romeo_despres View Post
I think you're right, the correct way to do that would be to have two scripts, one that runs inside REAPER and looks like:

Code:
RPR_ExecProcess('py path/to/external_script.py', -1)
and a second one (external_script.py) which is the actual reapy app.
tparker24 is offline   Reply With Quote
Old 10-10-2019, 11:33 AM   #65
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 53
Default reapy.Project.n_selected_tracks

I thought reapy.Project.n_selected_tracks was supposed to return an integer, but I'm getting a property object instead:

Code:
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> import reapy
>>> reapy.Project.n_selected_tracks
 <property object at 0x0000000003148F48>
BTW, I get the exact same output, if there are 0, 1, or more tracks selected.
tparker24 is offline   Reply With Quote
Old 10-10-2019, 12:07 PM   #66
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 53
Default reapy.Project.n_selected_tracks

I got it to work by adding some parens:

Code:
>>> reapy.Project().n_selected_tracks
 1
Or another way:

Code:
>>> my_project = reapy.Project()
>>> my_project.n_selected_tracks
1
tparker24 is offline   Reply With Quote
Old 10-10-2019, 04:13 PM   #67
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 53
Default play_state problem

This might be a little bug:


Code:
File <my script...>
  if project.play_state == "pause":

File "C:\Users\Tom Parker\AppData\Local\Programs\Python\Python37\lib\site-packages\reapy\core\project\project.py", line 690, in play_state

  state = states[RPR.GetPlayStateEx(self.id)]
KeyError: 0
tparker24 is offline   Reply With Quote
Old 10-10-2019, 05:49 PM   #68
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 53
Default Track objects

I've noticed that reapy uses a slightly different format for the track object than does RPR:

Code:
project.get_selected_track()  
Track("(MediaTrack*)0x000000000395E870")   # reapy

RPR.GetSelectedTrack(0,0)    
(MediaTrack*)0x000000000395E870            # RPR
And Reaper doesn't like the reapy format, for example:

Code:
x = RPR.GetSelectedTrack(0,0)   # RPR format of track_id
RPR.GetMediaTrackInfo_Value(x, 'IP_TRACKNUMBER')  # Returns the correct 10.0
 

 
x = project.get_selected_track()   # reapy format of track_id
RPR.GetMediaTrackInfo_Value(x, 'IP_TRACKNUMBER')  # Returns incorrect 0
This causes me a little problem, because I have to use some reapy and some RPR. In particular, there are no direct reapy counterparts for RPR.NF_GetSWSTrackNotes and RPR.NF_SetSWSTrackNotes.

So to use those two, I guess I will have to first get the RPR form of track id, using RPR.GetSelectedTrack(0,0).

Just a small annoyance, but something to be aware of.

Do I have this right?
tparker24 is offline   Reply With Quote
Old 10-10-2019, 11:12 PM   #69
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 7,884
Default

Is Romeo still with us ?

Will Reapy be able to replace Beyond so that the Pyton API is identical for internal Reaper (script) use as for external/networked Beyond-alike access to Reaper ?

Can/will Reapy be released and documented via ReaPack ?

-Michael
mschnell is offline   Reply With Quote
Old 10-11-2019, 10:42 AM   #70
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 53
Default Sockets?

If my python script (running outside of Reaper) has certain problems, I do a sys.exit() to terminate the script. When that happens I get the following:

Code:
Exception ignored in: <socket.socket fd=488, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 50268), raddr=('127.0.0.1', 2306)>
ResourceWarning: unclosed <socket.socket fd=488, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 50268), raddr=('127.0.0.1', 2306)>
I'm wondering if this might be related to reapy. If so, do I need to somehow shutdown reapy more gracefully, before I sys.exit() ?
tparker24 is offline   Reply With Quote
Old 10-12-2019, 11:50 AM   #71
jahudka
Human being with feelings
 
Join Date: Jul 2010
Posts: 36
Default Sends & receives & envelopes

@tparker24, just as a side note about the compatibility of reapy.Track and the native MediaTrack - the native MediaTrack object should be available as track.id if I'm reading reapy source well - so you should be able to do this:

Code:
x = project.get_selected_track()
RPR.GetMediaTrackInfo_Value(x.id, 'IP_TRACKNUMBER')
Anyway, I wanted to ask about APIs for track send / receive envelopes. When I'm working on a larger project with lots of aux busses for stuff like reverbs and delays I often need to toggle visibility for a lot of send volume envelopes, preferably with a single keystroke. I've tried writing a ReaScript for that, but I'm stuck because the ReaScript API doesn't have nice methods for working with send / receive envelopes' states - there is just the RPR_SetEnvelopeStateChunk method for setting the state as XML, but that's just such a pain to work with.. So I'd like to ask if you have any pointers about working with the XML chunk (like a documentation link), and also suggest a couple of features for reapy which would allow me to do this (and which might be of interest to others as well):
  • Implement __eq__ magic methods throughout the API to allow checking object identity ("is this track from project.tracks the same as this track from project.selected_tracks?")
  • Add reapy.Track.receives (now there's only Track.sends, which I believe doesn't include receives)
  • Add methods to reapy.Envelope to allow changing envelope state (active, visible, armed)
  • Add reapy.Send.envelopes and reapy.FX.envelopes - those two would be awesome, but also I think they'd be the hardest to implement, because from the ReaScript perspective there's no such thing as a send's envelope - it's the track's envelope - so I think these envelope lists should somehow proxy and filter the owning track's envelopes list (but not sure how you'd do that since I'm not sure you can check that a given track's envelope actually corresponds to a given send's or effect's parameter)

Also I'm loving this API! Truly amazing work, sir, even though I'm not all too proficient in Python I can appreciate how much easier it would be to develop custom actions and extensions using reapy than the native API. Thank you for all the time and effort you're putting into this!
jahudka is offline   Reply With Quote
Old 10-12-2019, 02:33 PM   #72
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 53
Default Track objects

Quote:
Originally Posted by jahudka View Post
@tparker24, just as a side note about the compatibility of reapy.Track and the native MediaTrack - the native MediaTrack object should be available as track.id if I'm reading reapy source well - so you should be able to do this:

Code:
x = project.get_selected_track()
RPR.GetMediaTrackInfo_Value(x.id, 'IP_TRACKNUMBER')

@jahudka,

Yes, indeed, that did it! Thank you very much!
tparker24 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:37 PM.


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