A pythonic wrapper for REAPER's ReaScript Python API
Project description
reapy
reapy
is a nice pythonic wrapper around the quite unpythonic ReaScript Python API for REAPER.
Contents
Installation
If you feel you need more explanation than the straightforward instructions below, head to the detailed installation guide.
reapy is available via pip
:
$ pip install python-reapy
One additional step is required to let REAPER know reapy is available. First, open REAPER. Then in a terminal, run:
$ python -c "import reapy; reapy.configure_reaper()"
Restart REAPER, and you're all set! You can now import reapy
from inside or outside REAPER as any standard Python module.
Instead of creating a new ReaScript containing:
from reaper_python import *
RPR_ShowConsoleMsg("Hello world!")
you can open your usual Python shell and type:
>>> import reapy
>>> reapy.print("Hello world!")
Usage
ReaScript API
All ReaScript API functions are available in reapy
in the sub-module reapy.reascript_api
. Note that in ReaScript Python API, all function names start with "RPR_"
. That unnecessary pseudo-namespace has been removed in reapy
. Thus, you shall call reapy.reascript_api.GetCursorPosition
in order to trigger reaper_python.RPR_GetCursorPosition
. See example below.
>>> from reapy import reascript_api as RPR
>>> RPR.GetCursorPosition()
0.0
>>> RPR.SetEditCurPos(1, True, True)
>>> RPR.GetCursorPosition()
1.0
Note that if you have the SWS extension installed, the additional ReaScript functions it provides will be available in reapy.reascript_api
and usable inside and outside REAPER as well.
reapy
API
The purpose of reapy
is to provide a more pythonic API as a substitute for ReaScript API. Below is the reapy
way of executing the example above.
>>> import reapy
>>> project = reapy.Project() # Current project
>>> project.cursor_position
0.0
>>> project.cursor_position = 1
>>> project.cursor_position
1.0
The translation table matches ReaScript functions with their reapy
counterparts.
Performance
When used from inside REAPER, reapy
has almost identical performance than native ReaScript API. Yet when it is used from the outside, the performance is quite worse. More precisely, since external API calls are processed in a defer
loop inside REAPER, there can only be around 30 to 60 of them per second. In a time-critical context, you should make use of the reapy.inside_reaper
context manager.
>>> import reapy
>>> project = reapy.Project() # Current project
>>> # Unefficient (and useless) call
>>> bpms = [project.bpm for _ in range(1000)] # Takes at least 30 seconds...
>>> # Efficient call
>>> with reapy.inside_reaper():
... bpms = [project.bpm for _ in range(1000)]
...
>>> # Takes only 0.1 second!
Documentation
Check the documentation and especially the API guide and Translation Table for more information.
Contributing
For now, about a half of ReaScript API has a reapy
counterpart, the docs are far from great, and many bugs are waiting to be found. Feel free to improve the project by checking the contribution guide!
Author
Roméo Després - RomeoDespres
License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python-reapy-0.10.0.tar.gz
.
File metadata
- Download URL: python-reapy-0.10.0.tar.gz
- Upload date:
- Size: 239.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff1a701c87fa1ab8aa76dd3528b6d03e3adb7f37388e53538902953243aef634 |
|
MD5 | 2aacdf1a3a987baa2f51a218cc5a9b5f |
|
BLAKE2b-256 | 81be73ded74fadcf099c1569d494ff49e80436281a652c7829ebb5feb93fef16 |
File details
Details for the file python_reapy-0.10.0-py2.py3-none-any.whl
.
File metadata
- Download URL: python_reapy-0.10.0-py2.py3-none-any.whl
- Upload date:
- Size: 450.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c93ab7b32cbc74e988d5f43ac2f0f0799775529a785042e1a8ac59ed6e9ddaf4 |
|
MD5 | 9bd4ce1591a73619bffd5d11ca104f26 |
|
BLAKE2b-256 | dc137e9af0cfab53087bf824b0b541aca14e52ddf61e74c2e134f20177acda76 |