Old 05-05-2020, 12:51 PM   #121
dimentorium
Human being with feelings
 
Join Date: Jan 2020
Posts: 62
Default

Hi Amberience,
just for understanding, do you want Reaper to trigger your external Python application? So something like, you click a button in Reaper and in your script some code gets executed?
dimentorium is offline   Reply With Quote
Old 05-05-2020, 03:13 PM   #122
Amberience
Human being with feelings
 
Amberience's Avatar
 
Join Date: Oct 2006
Location: swing on the spiral of our divinity
Posts: 2,119
Default

Quote:
Originally Posted by dimentorium View Post
Hi Amberience,
just for understanding, do you want Reaper to trigger your external Python application? So something like, you click a button in Reaper and in your script some code gets executed?
Yes, pretty much this, but preferably with key commands or buttons or whatever I choose. As I understand it there is an inner-reapy and an outer-reapy, so would I just need to tap into those in order to communicate between Reaper and my app running Python+Reapy?
__________________
TACOMA NARROWS BRIDGE DISASTER
Full disclosure: I am part of the inMusic Brands BFD team. Views and postings are my own

Last edited by Amberience; 05-05-2020 at 03:19 PM.
Amberience is offline   Reply With Quote
Old 05-06-2020, 12:49 AM   #123
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

Quote:
Originally Posted by romeo_despres View Post
Quote:
Originally Posted by dimentorium View Post
Hi romeo,
one other question, maybe you have an idea.
Is there a way to communicate from reaper to reapy? I would like to send a command from a button to my python application. At current I have the problem that my application does not load within reaper, so I probably need to use osc or comparable.
Hmm I guess it should be somehow possible. You can add any action you want to a toolbar by customizing it, so you can either:
  1. run your reapy script from inside REAPER directly with that action,
  2. or, if you need your reapy app to live outside REAPER, use the toolbar action to simply "send a message" to reapy (for instance by using reapy.set_ext_state, or with your own logic that could include files, sockets, flask, etc.)

Is that clear enough or would you need more detailed explanation on these steps?
Hi Amberience, doesn't the discussion above answers your question?
romeo_despres is offline   Reply With Quote
Old 05-06-2020, 01:04 AM   #124
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

For future reference if anyone is interested in Amberience's issue, more detailed discussion and examples can be found on the corresponding GitHub issue.
romeo_despres is offline   Reply With Quote
Old 05-07-2020, 09:44 PM   #125
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 83
Default KeyError using FX name as index

I'm having trouble with Track FX, when trying to use an FX name as an index, whereby I got a KeyError.

To further investigate, I tried to duplicate the basic example on page https://python-reapy.readthedocs.io/en/latest/reapy.core.html#reapy.core.FX which is:

Code:
>>> fx_list = track.fxs
>>> fx_list[0]
FX(parent_id="(MediaTrack*)0x0000000006CDEBE0", index=0)
>>> len(fx_list)
1
>>> fx_list["VST: ReaComp (Cockos)"]
FX(parent_id="(MediaTrack*)0x0000000006CDEBE0", index=0)
But my test case fails with:

KeyError: 'No FX named VST: ReaComp (Cockos)'

It was run outside reaper, on a project that had ReaComp as the only FX on a Selected track:

Code:
import reapy, sys

project = reapy.Project()
x = project.selected_tracks
if len(x) != 1: sys.exit(1)
track = x[0]
fx_list = track.fxs
print("Number of FX is", track.n_fxs)
print(fx_list[0])
print(fx_list[0].name)
print(fx_list["VST: ReaComp (Cockos)"])  # Gets KeyError
And here is the output:

Code:
Number of FX is 1
FX(parent_id="(MediaTrack*)0x00000000049C0EE0", index=0)
VST: ReaComp (Cockos)
Traceback (most recent call last):
  File "D:\Work\bug1.py", line 11, in <module>
    print(fx_list["VST: ReaComp (Cockos)"])  # Gets KeyError
  File "C:\Users\Tom Parker\AppData\Local\Programs\Python\Python38\lib\site-packages\reapy\core\fx\fx.py", line 409, in __getitem__
    i = self._get_fx_index(name=i)
  File "C:\Users\Tom Parker\AppData\Local\Programs\Python\Python38\lib\site-packages\reapy\core\fx\fx.py", line 434, in _get_fx_index
    raise KeyError("No FX named {}".format(name))
KeyError: 'No FX named VST: ReaComp (Cockos)'
I'm running Reaper 5.99/x64, Reapy 0.6.0, and Python 3.8.2.

Thanks for any advice.
tparker24 is offline   Reply With Quote
Old 05-08-2020, 01:37 AM   #126
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

Thanks for the report. I confirm that I'm able to replicate the bug on my setup. Will investigate and keep you informed!

Fyi, I've created a corresponding GitHub issue, but will also post it here when this gets solved.
romeo_despres is offline   Reply With Quote
Old 05-08-2020, 01:59 AM   #127
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

This is actually an error in the docs that I will fix asap. Problem is you have to remove "VST: " at the beginning of the name to make it work:

Code:
>>> fx_list["VST: ReaComp (Cockos)"]
KeyError: 'No FX named VST: ReaComp (Cockos)'
>>> fx_list["ReaComp (Cockos)"]
FX(parent_id="(MediaTrack*)0x00000000053E9280", index=0)
I'm wondering now: shouldn't we remove this prefix from FX.name ? It seems confusing that track.fxs[track.fxs[0].name] raises an error. Instead we could add an FX.type property that would return "VST", "JS", etc.

Or conversely, maybe we should keep the name as it is but fix fxs[name] so that it works with the prefix. Not sure which is the best.
romeo_despres is offline   Reply With Quote
Old 05-08-2020, 07:25 AM   #128
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 83
Default

Quote:
Originally Posted by romeo_despres View Post
]I'm wondering now: shouldn't we remove this prefix from FX.name ? It seems confusing that track.fxs[track.fxs[0].name] raises an error. Instead we could add an FX.type property that would return "VST", "JS", etc.

Or conversely, maybe we should keep the name as it is but fix fxs[name] so that it works with the prefix. Not sure which is the best.
It does get a little messy. The "name" seems to actually consist of THREE parts: type:, name, (author). As in: VST: ReaComp (Cockos)

So, although I like your first idea of FX.type, it seems you would then also need a FX.author?

Rather than all that, I think I prefer your second idea, to just keep name as it is and fix fxs[name] so that it works with the prefix -- and the suffix.
tparker24 is offline   Reply With Quote
Old 05-08-2020, 07:55 AM   #129
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

Thanks for the feedback, you're totally right. I've indeed decided to go for option 2. It will soon be released on PyPI with a bunch of other fixes, I'll let you know when it's done.
romeo_despres is offline   Reply With Quote
Old 05-08-2020, 08:03 AM   #130
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 83
Default

Quote:
Originally Posted by romeo_despres View Post
Thanks for the feedback, you're totally right. I've indeed decided to go for option 2. It will soon be released on PyPI with a bunch of other fixes, I'll let you know when it's done.
Great, thanks!
tparker24 is offline   Reply With Quote
Old 05-09-2020, 06:53 AM   #131
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

Update is available on PyPI
romeo_despres is offline   Reply With Quote
Old 05-09-2020, 09:34 AM   #132
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 83
Default

Quote:
Originally Posted by romeo_despres View Post
Update is available on PyPI
Works great in the new version. Thanks!
tparker24 is offline   Reply With Quote
Old 05-23-2020, 11:34 AM   #133
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 83
Default Reapy not finding SWS routines

I'm running Reapy outside of Reaper, and having trouble finding SWS. Here's a minimal test case:

Code:
import reapy
from reapy import reascript_api as RPR
if not RPR.APIExists("CF_GetSWSVersion"):
   reapy.print("Can't find CF_GetSWSVersion")
else:
    reapy.print(RPR.CF_GetSWSVersion("",20))
The output is:
Code:
Traceback (most recent call last):
  File "D:\REAPER\Scripts\reapy_test_sws.py", line 6, in <module>
    reapy.print(RPR.CF_GetSWSVersion("",20))
AttributeError: module 'reapy.reascript_api' has no attribute 'CF_GetSWSVersion'
My Reaper is a portable install and the relevant files are I believe in the recommended locations:

Code:
D:\REAPER\Scripts\reapy_test_sws.py
D:\REAPER\Scripts\sws_python.py
D:\REAPER\Scripts\sws_python64.py

D:\REAPER\Plugins\reaper_python.py
I discovered that I can get it to work, if I Copy those two sws files "sws_python.py" and "sws_python64.py" to \Plugins, and then I get the intended output: ['2.12.0.0', 20]

However, it's my understanding that those SWS files should not really be in \Plugins.

Is there a better way to have Reapy find SWS?

My versions are all the latest: Windows 10 x64, Reaper v6.10x64 (portable), SWS 2.12.0, reapy 0.7.0
tparker24 is offline   Reply With Quote
Old 05-26-2020, 03:29 AM   #134
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

Hi @tparker24,

Thanks for the report. I have been able to reproduce your bug and a fix is on its way. I'll let you know as soon as it is released.
romeo_despres is offline   Reply With Quote
Old 05-26-2020, 07:22 AM   #135
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

@tparker24, your bug has (hopefully) been fixed in 0.7.1.
romeo_despres is offline   Reply With Quote
Old 05-26-2020, 08:02 AM   #136
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 83
Default

Quote:
Originally Posted by romeo_despres View Post
@tparker24, your bug has (hopefully) been fixed in 0.7.1.
No luck with 0.7.1. Actually, it seems worse:

Code:
Script execution error

Traceback (most recent call last):
  File "activate_reapy_server.py", line 10, in <module>
    import reapy
  File "C:\Users\Tom Parker\AppData\Local\Programs\Python\Python38\lib\site-packages\reapy\__init__.py", line 29, in <module>
    from . import reascript_api
  File "C:\Users\Tom Parker\AppData\Local\Programs\Python\Python38\lib\site-packages\reapy\reascript_api.py", line 26, in <module>
    sys.path.append(os.path.join(_RPR.GetResourcePath(), 'Scripts'))
AttributeError: module 'reaper_python' has no attribute 'GetResourcePath'
And then it seems to go into an infinite loop, where I get this message over and over (in Reaper), and it's very difficult to break out of!
tparker24 is offline   Reply With Quote
Old 05-26-2020, 09:02 AM   #137
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

Uups... It was working at my place! Sorry I'll let you know when I have an update
romeo_despres is offline   Reply With Quote
Old 05-26-2020, 09:19 AM   #138
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

My mistake... I hope 0.7.2 (just released) will be better.
romeo_despres is offline   Reply With Quote
Old 05-26-2020, 10:28 AM   #139
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 83
Default

Quote:
Originally Posted by romeo_despres View Post
My mistake... I hope 0.7.2 (just released) will be better.
Yay! Working great. Thanks.
tparker24 is offline   Reply With Quote
Old 05-26-2020, 11:40 AM   #140
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

Quote:
Originally Posted by tparker24 View Post
Yay! Working great. Thanks.
Happy to read this! Sorry for the inconvenience.
romeo_despres is offline   Reply With Quote
Old 05-26-2020, 11:56 AM   #141
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 83
Default Feature Request

No problem. Thanks for your quick response.


With all the different versions, here's a Feature Request:

version = reapy.version() # Returns "0.7.2"
tparker24 is offline   Reply With Quote
Old 05-26-2020, 12:54 PM   #142
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

As it is pretty common for Python packages (see e.g. in PEP 8), the version of reapy is accessible as reapy.__version__.
romeo_despres is offline   Reply With Quote
Old 05-26-2020, 09:39 PM   #143
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 83
Default

Quote:
Originally Posted by romeo_despres View Post
As it is pretty common for Python packages (see e.g. in PEP 8), the version of reapy is accessible as reapy.__version__.
Good to know. Thanks.
tparker24 is offline   Reply With Quote
Old 06-14-2020, 02:33 AM   #144
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 323
Default

Hey guys! Thanks everyone for this project..looks really cool and i wish python would have a better implementation overall inside Reaper.

First of all, i get this trying to install it:

Code:
C:\WINDOWS\system32>py -m reapy
....
======================
  reapy config infos
======================

Python DLL
----------
    Can't find python DLL...
I am on python 3.8.0. Any idea why it doesnt detect the DLL?


Second, and before i keep running into errors and putting the time it takes,letme try to describe what i want to do and then you tell me if thats possible with reapy or not

I work in videogames, and my idea is to connect Wwise (audio engine), which provides its own API accesible in python, with Reaper. I am a bit confused when i read this on Reapy´s info though:

"if you want ot use it inside Reaper do that or if you want to use it outside reaper do that"

Ideally for me, i´d like to use it inside Reaper, cause i just need a script on a button to do stuff both in Reaper and Wwise simultaneously, but then i´d have to import the Wwise WAAPI module to be able to acces Wwise´s stuff. I am not sure you can import modules inside Reaper with Reapy. So maybe thats an outside case?

I am confused. Why does Python always has to be such a pain to setup and get started? do i just suck? where did i put my bourbon?

Any help would be apreciated. Thx people!
reapero is online now   Reply With Quote
Old 06-14-2020, 03:39 AM   #145
dimentorium
Human being with feelings
 
Join Date: Jan 2020
Posts: 62
Default

Hi reapero,
Please check that the environment variable Pythonpath is set (just reinstall python and check the flag).
You can also have a look at the tutorials I wrote for installing reapy.
Dimentorium.wix.com/raipt

On your use case. Use the dist Api from Reapy outside Reaper and way better to use.
dimentorium is offline   Reply With Quote
Old 06-14-2020, 08:12 AM   #146
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 323
Default

Thanks Dimentorium!

I had the path in the environment variable but anyway i uninstalled and install the new version (3.8.3) again, ticking on including the path in the env var during the installation, yet it stills fails to find the DLL when running in cmd:

Code:
py -m reapy
I had no problems running "python --version" or even the pip installations from any folder on my system, so i guess the env variable is correctly setup?

EDIT: Not sure if this is related but after seting up everything in the preferences like this




I still cant select .py as an extension when creating a new script.

Last edited by reapero; 06-14-2020 at 08:29 AM.
reapero is online now   Reply With Quote
Old 06-14-2020, 10:02 AM   #147
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

Hi reapero,

The automatic detection of python DLL by reapy is currently very basic and often fails. A new implementation that should cover most corner cases is on its way but not yet released. For now, the way you did it by manually finding the DLL is the right one. It's weird that REAPER says it detects the DLL but still refuses to create python scripts... I suppose you have tried to restart REAPER after setting up the preferences as you did?

Regarding your question about inside VS outside reaper, the rule of thumb is: if you need a GUI event loop or if you need any third party library, run outside reaper; otherwise do as you like. If you want to trigger your outer script with a button in reaper, it gets a bit tricky: you'll have to create an inner script that is fired when clicking your button and that tells your os to run the script outside reaper. I guess possible solutions could include the subprocess module or some kind of local server running outside reaper and listening to triggers.
romeo_despres is offline   Reply With Quote
Old 06-14-2020, 10:10 AM   #148
dimentorium
Human being with feelings
 
Join Date: Jan 2020
Posts: 62
Default

Hi reapero,
When I lool at your path on the setup screen, is that a 32 in the path? Did you install the 32 bit Python?
dimentorium is offline   Reply With Quote
Old 06-14-2020, 11:55 AM   #149
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 323
Default

Quote:
Originally Posted by romeo_despres View Post
Hi reapero,


Regarding your question about inside VS outside reaper, the rule of thumb is: if you need a GUI event loop or if you need any third party library, run outside reaper; otherwise do as you like. If you want to trigger your outer script with a button in reaper, it gets a bit tricky: you'll have to create an inner script that is fired when clicking your button and that tells your os to run the script outside reaper. I guess possible solutions could include the subprocess module or some kind of local server running outside reaper and listening to triggers.
Thanks for this! Its all a bit more clear in my head now

Quote:
Hi reapero,
When I lool at your path on the setup screen, is that a 32 in the path? Did you install the 32 bit Python?
That was it. I cant understand how something as popular as python defualts to 32b download whem you click on the big "downloadhere" button in their downlload site. You need to manually go and find the 64b version...sigh

I think this could be specified a little bit in the "Installation and uninstallation guide", for not so experienced python scripters like me. Python is already a frustrating thing to set up and this certainly contributed to the experience.

Thank god you gusy rock and could help during the same day, on a Sunday!

Cheers
reapero is online now   Reply With Quote
Old 06-14-2020, 01:27 PM   #150
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 60
Default

Glad we could help

Quote:
Originally Posted by reapero View Post
I think this could be specified a little bit in the "Installation and uninstallation guide", for not so experienced python scripters like me.
You're absolutely right. The installation process is about to get simpler and the documentation better, because these are two pain points that have often been raised. I hope it will avoid other to experience what you've been through!
romeo_despres is offline   Reply With Quote
Old 06-15-2020, 09:36 AM   #151
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 323
Default

Just a headsup to say how easy it is to script using this API, this is great!

And the ability to connect with the gazillion cool py modules out there? Jeez..i cant wait to see what you guys come up with!

Thanks a million!
reapero is online now   Reply With Quote
Old 06-25-2020, 02:43 PM   #152
Perken
Human being with feelings
 
Perken's Avatar
 
Join Date: May 2019
Location: Los Angeles / God forbid…
Posts: 41
Default

Hey, I’m struggling with installing the wrapper. A couple of similar cases were adressed back on PC previously, but I can’t seem to get the hang of it on my mac. The ‘python3 -m reapy’ command doesn’t find the DLL file :

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/reapy/tools/network/machines.py:99:
DisabledDistAPIWarning: Can't reach distant API.
Please start REAPER, or call reapy.config.enable_dist_api() from inside REAPER to enable distant API.
warnings.warn(errors.DisabledDistAPIWarning())

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

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

When running:
import sys
RPR_ShowConsoleMsg(sys.path)
from reascript, I get these paths:

['/Users/antoinebalaine/Library/Application Support/REAPER/Scripts',
'/usr/lib/python2.7', '/usr/lib/python2.7/plat-darwin',
'/usr/lib/python2.7/plat-mac',
'/usr/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload',
'/Users/antoinebalaine/Library/Python/2.7/lib/python/site-packages', '/Library/Python/2.7/site-packages',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
'/Applications/REAPER64.app/Contents/Plugins']

The distant api script doesn’t open reapy either.
I’m confused as to why Reaper is reading the 2.7 version of python, and there doesn’t seem to be any 3.8-version-specific .dylib files.

Can anybody give me any pointers ?
Perken is offline   Reply With Quote
Old 06-29-2020, 05:53 AM   #153
dimentorium
Human being with feelings
 
Join Date: Jan 2020
Posts: 62
Default

Hi perken,
can you check in the preferences where Reaper is looking for python? I do not have MAC for testing, but maybe the configuration there might help identifying the issue.
dimentorium is offline   Reply With Quote
Old 06-29-2020, 04:47 PM   #154
Perken
Human being with feelings
 
Perken's Avatar
 
Join Date: May 2019
Location: Los Angeles / God forbid…
Posts: 41
Default

This is the path I have : /usr/lib
That's the one that was found automatically by reaper.

I never found any Python DLL file on my computer - are those file extensions readable on mac ?
I'm getting python scripts to print to the console, but other than that I'm pretty much clueless...
Perken is offline   Reply With Quote
Old 06-30-2020, 12:41 AM   #155
dimentorium
Human being with feelings
 
Join Date: Jan 2020
Posts: 62
Default

Hi Perken,
ac does not have a DLL, this is a Windows filetype. Also be aware, that on MAC you always have Python 2.7 installed by default; this is what Reaper is finding.

Please check the following (don't be bothered if you already did some of the steps, its just to make sure):
- Do you have 64it or 32 Bit Reaper => install appropriate Python 32 or 64Bit
- Check in the preferences of Reaper to point it to the path of Python 3.8 as you can also read in this post https://forums.cockos.com/showthread.php?p=1910071
- Check within Reaper, that its using Python 3.8 (as you already did)
- Try importing Reapy inside Reaper
- Follow steps to add the distant api, maybe you have to look for the files manually (on Windows its in %Python%\lin\sit-packages\reapy\...)
dimentorium is offline   Reply With Quote
Old 06-30-2020, 11:25 AM   #156
Perken
Human being with feelings
 
Perken's Avatar
 
Join Date: May 2019
Location: Los Angeles / God forbid…
Posts: 41
Default

Found it ! Thank you very much for your help dimentorium !

For future mac users: after installing the latest python version, it still took updating the shell profile and running authorizations in /Applications/Python 3.8 and restarting the computer before reaper was able to use it.
My path in the prefs ended up looking like:

/Library/Frameworks/Python.framework/Versions/3.8/
libpython3.8.dylib
Perken 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 12:56 AM.


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