Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 11-24-2019, 02:46 PM   #81
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,686
Default

Quote:
Originally Posted by romeo_despres View Post
It's just JSON messages sent over the local network. Outer-reapy tells inner-reapy which fonctions it needs him to call, then inner-reapy sends the results back to outer-reapy.
I see. This in fact is rather similar to beyond. Only that beyond uses OSC instead of JSON.

I do know that OSC (close to always) uses UDP as a transport. What transport layer does reapy use to send JSON messages ?

-Michael
mschnell is offline   Reply With Quote
Old 11-25-2019, 01:50 AM   #82
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

Indeed it is very similar. I've decided to recode it myself rather than just reuse Beyond mostly because I didn't like the way Beyond fills builtins with global variables without being asked to. Quite a creative choice, but not my cup of tea

I think reapy uses TCP... I don't know much about networking though so I might be wrong!...
romeo_despres is offline   Reply With Quote
Old 11-25-2019, 09:10 AM   #83
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,686
Default

Quote:
Originally Posted by romeo_despres View Post
I think reapy uses TCP...
Then it would be no problem at all to use it across two networked boxes.

-Michael
mschnell is offline   Reply With Quote
Old 11-25-2019, 11:27 AM   #84
kkecm
Human being with feelings
 
Join Date: Nov 2019
Posts: 2
Default

Quote:
Originally Posted by romeo_despres View Post
Why exactly do you not want to use reapy.reascript_api.InsertEnvelopePoint? I do agree that it would be better to have a nicer function for this purpose, but it should still work, even from the outside.
Thanks for the quick response. In fact reapy.reascript_api.InsertEnvelopePoint works after I realized that the envelopes and tracks must be all obtained with reascript_api and not with reapy. reapy.Project().tracks[0] is not at the same level than reapy.reascript_api.GetTrack(0, 0).
kkecm is offline   Reply With Quote
Old 11-25-2019, 02:09 PM   #85
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

@mschnell

Indeed, that's why I've started doing it!

@kkecm

The objects that ReaScripts functions take as arguments are string identifiers. You can access them with the id property of reapy objects.

In your case, you could do:

Code:
import reapy
import reapy.reascript_api as RPR

t = reapy.Project().tracks[0]
RPR.InsertEnvelopePoint(t.id, ...)
romeo_despres is offline   Reply With Quote
Old 11-27-2019, 01:14 PM   #86
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 83
Default

Quote:
Originally Posted by tparker24 View Post
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() ?
I now think it was self-inflicted, because I had
Code:
warnings.filterwarnings("error")
tparker24 is offline   Reply With Quote
Old 12-29-2019, 03:47 AM   #87
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,686
Default

I have a developing project that sleeps since many month.

I did this as a suite of JSFXes. But as this is not a realtime thingy, I think It would be a good idea to use ReaScript Python or an external Python (via Reapy) for some complex "offline" calculation and data handling.

Does Reapy already provide a kind of "library" for communicating with JSFXes ?

If there is not, I can do something myself, but of course I would like to work together with the Reapy team on such basic stuff.

-Michael
mschnell is offline   Reply With Quote
Old 01-03-2020, 03:44 PM   #88
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

Quote:
Originally Posted by mschnell View Post
I have a developing project that sleeps since many month.

I did this as a suite of JSFXes. But as this is not a realtime thingy, I think It would be a good idea to use ReaScript Python or an external Python (via Reapy) for some complex "offline" calculation and data handling.

Does Reapy already provide a kind of "library" for communicating with JSFXes ?

If there is not, I can do something myself, but of course I would like to work together with the Reapy team on such basic stuff.

-Michael
I'm not sure what "communicating with JSFX" means. What kind of information would you like to exchange between a python script and a JSFX? What you can do so far with reapy is control the FX parameters (as for any FX), is it relevant to you?
romeo_despres is offline   Reply With Quote
Old 01-04-2020, 07:52 AM   #89
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by mschnell View Post
I have a developing project that sleeps since many month.

I did this as a suite of JSFXes. But as this is not a realtime thingy, I think It would be a good idea to use ReaScript Python or an external Python (via Reapy) for some complex "offline" calculation and data handling.

Does Reapy already provide a kind of "library" for communicating with JSFXes ?

If there is not, I can do something myself, but of course I would like to work together with the Reapy team on such basic stuff.

-Michael
AFAIK, there's no gmem-access in Python, only in EEL2, LUA, VideoProcessor and JSFX. So the answer is probably no.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 01-04-2020, 03:02 PM   #90
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,686
Default

Quote:
Originally Posted by romeo_despres View Post
I'm not sure what "communicating with JSFX" means. What kind of information would you like to exchange between a python script and a JSFX? What you can do so far with reapy is control the FX parameters (as for any FX), is it relevant to you?
External python programs doable with reapy live in their own application thread.

Scripts live in the Reaper GUI Thread.

JSFXes live in the realtime thread associated with the appropriate thread.

That is why each of those have their own implications regarding performance / latency / ability to access certain APIs, libraries, etc. Hence it sometimes makes sense (or even is required) to do some of the functionality of a complex propram in a dedicated of these environments.

AFAIU, there is a shared memory that can be accessed by both scripts and JSFXes. This is a nice basis for splitting functionality between scripts and JSFXes. Moreover we need triggers to mutually signal events (to do full blown remote procedure calls or more basic stuff). This can be done e.g. by a JSFX sending a message via MidiToReaControlPath to trigger an action and with that a scrip. or a script move a slider of a JSFX.

It would be great to have a formalized tool set for all this and an appropriate libary for JSFX and reapy that provides functions for such functionality.

-Michael
mschnell is offline   Reply With Quote
Old 01-04-2020, 03:06 PM   #91
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,686
Default

Quote:
Originally Posted by mespotine View Post
AFAIK, there's no gmem-access in Python, only in EEL2, LUA, VideoProcessor and JSFX. So the answer is probably no.
That would be very bad !
I seem to remember that gmem access for scripts (ELL and LUA) has been added not too long ago. Has the Python API for this really been forgotten ? If so this decently needs needs to be mended.
-Michael
mschnell is offline   Reply With Quote
Old 03-03-2020, 09:45 AM   #92
RCJacH
Human being with feelings
 
Join Date: Apr 2016
Location: Beijing, China
Posts: 215
Default

I have a quick question.
As you mentioned, reaper crashes when trying to import numpy. What's the reapy's way to solve this problem? Do we have to write a server side and a (local) client side of the script and run them separately?
RCJacH is offline   Reply With Quote
Old 03-03-2020, 11:47 AM   #93
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

The reapy way of solving that is to run your script outside REAPER, just as any Python script. As all ReaScript functions become available outside REAPER via reapy.reascript_api, there is (hopefully) nothing you can do with Python inside REAPER that you can not do outside using reapy.

Is that clear enough? If you tell me more about why you need client and server parts of your script, I can maybe help you with adapting it to reapy.
romeo_despres is offline   Reply With Quote
Old 03-03-2020, 02:12 PM   #94
RCJacH
Human being with feelings
 
Join Date: Apr 2016
Location: Beijing, China
Posts: 215
Default

I see, thanks for the explanation, that clears things up.

I'm trying to incorporate Magenta into my production workflow, and doing so with local script freezes reaper. Although it works using beyond.reaper (I don't know how it manages to pass reaper scripts to a local server since the source code is way beyond my py-fu level), but as you said, it's a bit slow and the API isn't pythonic. I guess I need to code up a Magenta Studio like interface to use it outside of reaper.


Just for information. I tried writing a script to run inside reaper that launches an external file, and here's the result:

1. I successfully launched another reaper.exe with the following code:
Code:
import os
path = os.path.join(os.getcwd(), "reaper.exe")
os.startfile(path)
This also works for opening a directory with the default file explorer.

2. I wrote another py file to test crash and file action, and for simplicity put it in the same folder as reaper.exe:
Code:
# external_py.py
import numpy

with open("test.txt", mode="w") as f:
    f.write(str(numpy))
Using os.startfile as mentioned above does not create that test.txt.

What worked is the following:
Code:
path = os.path.join(os.getcwd(), "external_py.py")
os.system('pyenv exec python -m external_py.py')
Note: I have numpy in a dedicated python 3.7 thus the "pyenv exec" before "python".


3. Using exec(open(path).read()) crashes reaper, it's the same as importing the external_py as a module.
RCJacH is offline   Reply With Quote
Old 03-05-2020, 10:42 AM   #95
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

Looks nice, thanks for the explanation. Good to know your third snippet works. Note however that it will freeze REAPER until external.py is done running. Thus if you need cpu-expensive deep learning scripts (as I guess Magenta uses), or if you want some kind of GUI, you would be better off running your scripts entirely from outside REAPER. Is it because you want to trigger scripts with keyboards shortcuts that you still run them from inside REAPER (with the os.system trick)?
romeo_despres is offline   Reply With Quote
Old 03-13-2020, 09:21 AM   #96
RCJacH
Human being with feelings
 
Join Date: Apr 2016
Location: Beijing, China
Posts: 215
Default

Yeah, I would like to open designated GUIs with short-cuts or toolbar buttons, but I can settle with opening the software externally if that fails.

I noticed that when launching reaper with os.system("reaper.exe"), a cmd.exe window pops up and freezes the original reaper until manually closing the command prompt window.

However using os.startfile solves that issue. A new reaper window is started without freezing the original reaper window. Unfortunately it only works in windows.

After a bit of searching, I found out that the following code works without freezing reaper.

Code:
import subprocess
subprocess.Popen("reaper.exe")
I might need to think about how this works with detecting which python env is needed to run the script, so it might not work as well as intended. However this might work if a package is compiled into an application.

I also confirmed that python v3.8 works when using reapy externally, however only 3.7 can be detected by reaper. (and unfortunately magenta only supports 3.7 currently).


A question, I am currently trying to add more ReaScript APIs (especially MIDI related ones) into reapy. I have also read the CONTRIBUTING.md and the log convention. I see a lot of .pyi files there, are they actually useful for the package or are they created by pycharm or something? I normally use vscode, do I need to manually update .pyi files as well when I made a change to a .py file?

Last edited by RCJacH; 03-13-2020 at 09:28 AM.
RCJacH is offline   Reply With Quote
Old 03-13-2020, 01:28 PM   #97
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
Default

You can use any command line program via python in Reaper as actions.

Here one example how you can run even .ahk programs directly without needing to compile them to .exe first.

PHP Code:
import subprocess
subprocess
.Popen(r'C:/ahk/AutoHotkey.exe "C:/Program Files/REAPER/Scripts/your/magic_ahk_script_uncompiled_improve_edit_as_often_as_you_want.ahk"'
Maybe we should start a new thread where we collect interesting command line musical tools, worth combining with Reaper, we have the freedom to do so anyway, thanks to the devs futuristic vision. Any command line can be an internal action inside Reaper, what else one would want? What does Cubase give instead? 20 GB downloads.

UPDATE: Thread created, see https://forum.cockos.com/showpost.ph...55&postcount=1

Last edited by TonE; 03-13-2020 at 01:37 PM.
TonE is offline   Reply With Quote
Old 03-13-2020, 01:36 PM   #98
RCJacH
Human being with feelings
 
Join Date: Apr 2016
Location: Beijing, China
Posts: 215
Default

Quote:
Originally Posted by TonE View Post
You can use any command line program via python in Reaper as actions.

Here one example how you can run even .ahk programs directly without needing to compile them to .exe first.

PHP Code:
import subprocess
subprocess
.Popen(r'C:/ahk/AutoHotkey.exe "C:/Program Files/REAPER/Scripts/your/magic_ahk_script_uncompiled_improve_edit_as_often_as_you_want.ahk"'
Maybe we should start a new thread where we collect interesting command line musical tools, worth combining with Reaper, we have the freedom to do so anyway, thanks to the devs futuristic vision. Any command line can be an internal action inside Reaper, what else one would want? What does Cubase give instead? 20 GB downloads.

Well the problem is when the python version or venv you wish to run script with is not the same as your global one that gets triggered by the command line. Even worse when you need the package to run on multiple systems across different OS with perhaps different path to the package lol...
RCJacH is offline   Reply With Quote
Old 03-13-2020, 01:43 PM   #99
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
Default

Quote:
Originally Posted by RCJacH View Post
Well the problem is when the python version or venv you wish to run script with is not the same as your global one that gets triggered by the command line. Even worse when you need the package to run on multiple systems across different OS with perhaps different path to the package lol...
My use case is where every user creates something for themselves. Take anything, make it a Reaper action. Of course the path has to exist on your computer. If there is no other standard, then one solution could be requiring the command line programs to be available in some Reaper subdirectory, e.g. in Scripts/command_line_tools/lowkey.exe (for example)

Your tool should require minimal versions if possible, so it should work with as old versions as possible.
TonE is offline   Reply With Quote
Old 03-18-2020, 03:01 AM   #100
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

Quote:
Originally Posted by RCJacH View Post
A question, I am currently trying to add more ReaScript APIs (especially MIDI related ones) into reapy. I have also read the CONTRIBUTING.md and the log convention. I see a lot of .pyi files there, are they actually useful for the package or are they created by pycharm or something? I normally use vscode, do I need to manually update .pyi files as well when I made a change to a .py file?
.pyi files are type hints. If you run python with a typechecker, such as mypy, these files will be used to enforce type consistency.

In order to allow anyone to contribute, type hinting is not mandatory for now. In other words, you can contribute to .py files only, and we'll be very happy with it Maybe your pull request will be edited to add type hinting, or maybe it will simply be done later.

Thanks for making me realize this should be addressed in the contributing guide. I'll try to add it soon!
romeo_despres is offline   Reply With Quote
Old 03-25-2020, 03:11 PM   #101
dimentorium
Human being with feelings
 
Join Date: Jan 2020
Posts: 76
Default

Hello romeo,
I am currently working on some python stuff in reaper and heavily using your API. Really nice work!!

One idea I wanted to ask for is, to include the RPP library for parsing and changing the project file.
https://github.com/Perlence/rpp

With that you can change the rendering settings in the file or export reaper presets programatically.
dimentorium is offline   Reply With Quote
Old 03-27-2020, 01:03 PM   #102
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

Quote:
Originally Posted by dimentorium View Post
Hello romeo,
I am currently working on some python stuff in reaper and heavily using your API. Really nice work!!

One idea I wanted to ask for is, to include the RPP library for parsing and changing the project file.
https://github.com/Perlence/rpp

With that you can change the rendering settings in the file or export reaper presets programatically.
Hi, it's very nice to hear, thanks I had never heard of this project before but it seems pretty cool! Why exactly would you need to see it included in reapy? Don't they simply complement one another?
romeo_despres is offline   Reply With Quote
Old 03-28-2020, 03:08 PM   #103
dimentorium
Human being with feelings
 
Join Date: Jan 2020
Posts: 76
Default

Hello romeo,

you are tight, they definately complement. Just thought this might be useful to add rendering functionality to reapy.

Also did some testing because I was looking for a way to read and set custom presets for VSTIs. By using the chunk function and RPP this seems to work well. Until now I did not find a good way to set or read patches programmatically (except vstpreset).

import reapy
import rpp

#get references
project = reapy.Project()
vst_track = project.tracks[0]

#load configuration from first track
vst_track_chunk = reapy.reascript_api.GetTrackStateChunk(vst_track.i d,"",8192,False)
vst_track_chunk_parsed = rpp.loads(vst_track_chunk[2])
tag_fx = vst_track_chunk_parsed.find("FXCHAIN")
tag_vst = tag_fx.find("VST")

#reference 2nd track
track2 = project.tracks[1]
track2_chunk = reapy.reascript_api.GetTrackStateChunk(track2.id," ",8192,False)
track2_chunk_parsed = rpp.loads(track2_chunk[2])
#add vsti configuration from 1st track
track2_chunk_parsed.append(tag_fx)
#convert to writeable chunk
new_chunk = rpp.dumps(track2_chunk_parsed)
#set new chunk
reapy.reascript_api.SetTrackStateChunk(track2.id,t est[2],False)
dimentorium is offline   Reply With Quote
Old 03-30-2020, 01:44 PM   #104
dimentorium
Human being with feelings
 
Join Date: Jan 2020
Posts: 76
Default

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.
dimentorium is offline   Reply With Quote
Old 04-01-2020, 04:16 AM   #105
mcannon
Human being with feelings
 
Join Date: Mar 2020
Posts: 2
Default

I can't get this to work and I'm assuming it's because I can't get Reaper to use the right version of Python (3.8.2).

I've tried adding a symlink to libpython.dylib but the terminal comes back with 'operation not permitted'.

any ideas on how to get Reaper to run the correct version?
mcannon is offline   Reply With Quote
Old 04-18-2020, 10:08 AM   #106
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

Quote:
Originally Posted by dimentorium View Post
Hello romeo,

you are tight, they definately complement. Just thought this might be useful to add rendering functionality to reapy.

Also did some testing because I was looking for a way to read and set custom presets for VSTIs. By using the chunk function and RPP this seems to work well. Until now I did not find a good way to set or read patches programmatically (except vstpreset).

import reapy
import rpp

...
I see from your example that you are right, it requires some convolutions to make reapy and rpp work hand in hand. At least, I don't like that one has to use GetTrackStateChunk instead of something easier. I'll think on that!
romeo_despres is offline   Reply With Quote
Old 04-18-2020, 10:17 AM   #107
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

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?
romeo_despres is offline   Reply With Quote
Old 04-18-2020, 10:24 AM   #108
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

Quote:
Originally Posted by mcannon View Post
I can't get this to work and I'm assuming it's because I can't get Reaper to use the right version of Python (3.8.2).

I've tried adding a symlink to libpython.dylib but the terminal comes back with 'operation not permitted'.

any ideas on how to get Reaper to run the correct version?
Have you tried to go to Options > Preferences > Plug-ins > ReaScript and then fill the Custom path to Python... with the correct libpython3.8.dylib file?

I don't really understand at which point of the process you've needed to setup a symbolink link, but I don't use macOS so I'm not sure how things work there.
romeo_despres is offline   Reply With Quote
Old 04-18-2020, 10:25 AM   #109
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

If you are in need for references to implement rendering into Reapy as well, I suggest you to port over the functions from my Ultraschall-API.
This solved tons of problems conceptually.

The most important sourcefile is that one:
https://github.com/Ultraschall/ultra...der_Module.lua

This includes as well the creation and analysing of render-strings, who hold the render-format-settings of AIFF,Wav,Opus,MP3,Flac,etc
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-18-2020, 10:34 AM   #110
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

Quote:
Originally Posted by mespotine View Post
If you are in need for references to implement rendering into Reapy as well, I suggest you to port over the functions from my Ultraschall-API.
This solved tons of problems conceptually.

The most important sourcefile is that one:
https://github.com/Ultraschall/ultra...der_Module.lua

This includes as well the creation and analysing of render-strings, who hold the render-format-settings of AIFF,Wav,Opus,MP3,Flac,etc
Thank you! Just to be sure I understand: as for Python, there is no API function for rendering in Lua, right? So you reimplemented everything on your own?
romeo_despres is offline   Reply With Quote
Old 04-18-2020, 10:41 AM   #111
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

No. I set all aspects using
https://mespotin.uber.space/Ultrasch...SetProjectInfo
and
https://mespotin.uber.space/Ultrasch...ectInfo_String

and run the action

reaper.Main_OnCommand(41824,0) -- render using it with the last rendersettings(those, we inserted)

There are some tricky parts, though. Some settings, like the online/offline-dropdownlist can't be set via API, so I'm using Julian Sader's extension for pulling that off. With his functions, I can set the things in the dialog when Render to File is opened.
For others, I need to work with the config-variables Reaper provides:
https://mespotin.uber.space/Ultrasch...Variables.html

If you want to start porting it, I suggest you to port the function "ultraschall.GetRenderTable_Project()" first. If you can get all of the attributes, you can work from there.
The function ultraschall.GetRenderTable_Project() gets all rendering-settings and attributes and returns them as a handy array.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-18-2020, 11:03 AM   #112
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

I see, thanks for the details
romeo_despres is offline   Reply With Quote
Old 04-18-2020, 11:30 AM   #113
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

If you have any questions regarding it, head over to my Ultraschall-API-Thread and I can help you further.

Would be cool, if full-scale rendering would be available for Python as well
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 04-18-2020, 01:10 PM   #114
dimentorium
Human being with feelings
 
Join Date: Jan 2020
Posts: 76
Default

Hi romeo,
basically the reading and writing of chunks works for VSTi. I am building a small preset manager, you can find everythin here.
https://github.com/dimentorium/PresetManager

Rendering of presets will also come ;-)

Concerning communication. I just use the socket to send a string from Reaper to Python, that was the easiest way.

Thanks for your feedback!
dimentorium is offline   Reply With Quote
Old 04-18-2020, 05:02 PM   #115
Levitanus
Human being with feelings
 
Join Date: Nov 2015
Location: Novosibirsk, Russia
Posts: 40
Default

Hi, wrote a bit about reapy:
https://habr.com/ru/post/497942/

About a week I wonder around the idea of this article, mainly, because of missing the content here and tidiness of the coronavirus-themes. But, when robotic-harvester, hacking zip with bitcoins and other cool articles released — I decided not to publish crude material.

However, unexpectedly today the maintainer of this review hero showed up from the lockdown and, several hours ago reapy v0.6.0 has been published on PyPi. Under the cut — the last change log, which contains (to my pleasure) no line where I have not been involved one way, or another.

Finally: why reapy is needed and how Python works inside REAPER.
Levitanus is offline   Reply With Quote
Old 04-19-2020, 04:38 AM   #116
Amberience
Human being with feelings
 
Amberience's Avatar
 
Join Date: Oct 2006
Location: swing on the spiral of our divinity
Posts: 2,242
Default

Romeo, I suspect you're saving my bacon with this work. Thank you very much!

Also thanks for the note on SciPy, Kivy, and Numpy crashing Reaper. I've been running into that and tearing my hair out.

It's a shame that this issue dates back to 2017. I would've thought that python being one of the most popular languages on the planet and with three of the most in-demand libraries for it causing crashes, that the Reaper team would investigate this issue.
Amberience is offline   Reply With Quote
Old 04-20-2020, 07:16 AM   #117
Amberience
Human being with feelings
 
Amberience's Avatar
 
Join Date: Oct 2006
Location: swing on the spiral of our divinity
Posts: 2,242
Default

Hey Romeo,
If I do the following:
Code:
import reapy as rp

class ProjectPool():

    def __init__(self):
        self.pool = rp.get_projects()
        self.get_project_tracks()

    def get_project_tracks(self):
        for project in self.pool:
            TrackPool(project)
        return

class TrackPool():

    def __init__(self, project):
        self.pool = project.tracks
        self.get_track_items()

    def get_track_items(self):
        for track in self.pool:
            ItemPool(track)
        return

class ItemPool():

    def __init__(self, track):
        self.pool = track.items
        print(self.pool)


with rp.inside_reaper():
    ProjectPool()
Then only the currently selected project returns its track.items result. Any inactive projects return empty lists.

Code:
[Item("(MediaItem*)0x00007F986D5EF420"), Item("(MediaItem*)0x00007F986D5D4970"), Item("(MediaItem*)0x00007F986D5DED70"), Item("(MediaItem*)0x00007F986D5DC8D0"), Item("(MediaItem*)0x00007F9872D2B800"), Item("(MediaItem*)0x00007F9872D2C300"), Item("(MediaItem*)0x00007F9872C5A440"), Item("(MediaItem*)0x00007F9872C5D800"), Item("(MediaItem*)0x00007F9872D3A0D0"), Item("(MediaItem*)0x00007F9872D2CBE0"), Item("(MediaItem*)0x00007F9872D2D0F0"), Item("(MediaItem*)0x00007F9872D2D600"), Item("(MediaItem*)0x00007F9872D2DB10"), Item("(MediaItem*)0x00007F9872D2E020"), Item("(MediaItem*)0x00007F9875BE6A40"), Item("(MediaItem*)0x00007F986D771000"), Item("(MediaItem*)0x00007F9875820380"), Item("(MediaItem*)0x00007F9870830230"), Item("(MediaItem*)0x00007F9875C1D890"), Item("(MediaItem*)0x00007F9872D2E530"), Item("(MediaItem*)0x00007F9872D3C860"), Item("(MediaItem*)0x00007F9875CADB40"), Item("(MediaItem*)0x00007F9875CFE240"), Item("(MediaItem*)0x00007F9875C8A280"), Item("(MediaItem*)0x00007F9875C89CB0"), Item("(MediaItem*)0x00007F986D770740"), Item("(MediaItem*)0x00007F987583AE70"), Item("(MediaItem*)0x00007F9875B705E0"), Item("(MediaItem*)0x00007F9872C63490"), Item("(MediaItem*)0x00007F9872C637A0"), Item("(MediaItem*)0x00007F9872C64080"), Item("(MediaItem*)0x00007F9872D3D8E0")]
[Item("(MediaItem*)0x00007F986D7FD0A0"), Item("(MediaItem*)0x00007F986D7FD5B0"), Item("(MediaItem*)0x00007F986D7FDAC0"), Item("(MediaItem*)0x00007F986D7FE510"), Item("(MediaItem*)0x00007F986D7FEA20"), Item("(MediaItem*)0x00007F986D7FEF30"), Item("(MediaItem*)0x00007F986D7FF440"), Item("(MediaItem*)0x00007F986D7FF950"), Item("(MediaItem*)0x00007F986D7FA380"), Item("(MediaItem*)0x00007F986D7FA690"), Item("(MediaItem*)0x00007F986D7FA9A0"), Item("(MediaItem*)0x00007F986D7FACB0"), Item("(MediaItem*)0x00007F986D7FAFC0"), Item("(MediaItem*)0x00007F986D7FB2D0"), Item("(MediaItem*)0x00007F986D7FB7E0"), Item("(MediaItem*)0x00007F986D7FBCF0"), Item("(MediaItem*)0x00007F986D7FC680"), Item("(MediaItem*)0x00007F986D7FCB90"), Item("(MediaItem*)0x00007F986D7C50A0"), Item("(MediaItem*)0x00007F986D7C53B0"), Item("(MediaItem*)0x00007F986D7F9740"), Item("(MediaItem*)0x00007F986D7F9A50"), Item("(MediaItem*)0x00007F986D7F9D60"), Item("(MediaItem*)0x00007F986D7FA070"), Item("(MediaItem*)0x00007F986D7D2C80"), Item("(MediaItem*)0x00007F986D7D3410"), Item("(MediaItem*)0x00007F986D7D3720"), Item("(MediaItem*)0x00007F986D7D3C30"), Item("(MediaItem*)0x00007F986D7D4140"), Item("(MediaItem*)0x00007F986D7D4650"), Item("(MediaItem*)0x00007F986D7D4B60"), Item("(MediaItem*)0x00007F986D7D5070")]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
I'm trying to write a ProjectPool class which goes off and gets all items for all tracks in all projects. Just trying to wrap my head around the API. Is this a Reaper limitation or something to do with the way I'm using reapy?


If I want to keep everything in one big pool like this, do I need to start appending stuff to lists or arrays and then referencing those?

Last edited by Amberience; 04-20-2020 at 07:22 AM.
Amberience is offline   Reply With Quote
Old 04-20-2020, 08:01 AM   #118
Amberience
Human being with feelings
 
Amberience's Avatar
 
Join Date: Oct 2006
Location: swing on the spiral of our divinity
Posts: 2,242
Default

I guess it's something to do with Reaper not returning info for non-active projects. Because even if I do super simple:

Code:
with rp.inside_reaper():
    for project in rp.get_projects():
        for track in project.tracks:
            print(track.name)
Then it only returns info for one of the projects I have loaded.

Another example:

Code:
import reapy as rp


with rp.inside_reaper():

    p1 = rp.Project(0)
    p2 = rp.Project(1)

    print([s.name for s in p1.tracks])
    print([s.name for s in p2.tracks])
Ideally I don't want to have to use a context manager every time I want to access a non-current project. I just wanna pull everything out into one big multi-dimensional array and then process it later on.


(conversation moved to github)

Last edited by Amberience; 04-21-2020 at 01:07 AM.
Amberience is offline   Reply With Quote
Old 05-01-2020, 02:10 AM   #119
romeo_despres
Human being with feelings
 
Join Date: Jan 2019
Posts: 63
Default

Quote:
Originally Posted by Levitanus View Post
Hi, wrote a bit about reapy
Thanks, this is much appreciated!
romeo_despres is offline   Reply With Quote
Old 05-05-2020, 10:02 AM   #120
Amberience
Human being with feelings
 
Amberience's Avatar
 
Join Date: Oct 2006
Location: swing on the spiral of our divinity
Posts: 2,242
Default

Hey Romeo,

Do you have any tutorial or prototype code for getting Reaper to trigger methods in existing instances of Reapy classes?

Lets say I have something simple like this:
Code:
import reapy as rp

class ReapyConnection:

    def __init__(self):
        self.project = rp.Project()

    def get_Selected_Items(self):
        with rp.inside_reaper():
            selected_items = self.project.selected_items
            rp.show_console_message(selected_items)


con = ReapyConnection()
con.get_Selected_Items()
How can I trigger the get_Selected_Items method within the con instance, directly inside Reaper but running the script outside of Reaper?
Amberience 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 05:00 AM.


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