Giter Club home page Giter Club logo

reapy's Introduction

reapy

reapy is a nice pythonic wrapper around the quite unpythonic ReaScript Python API for REAPER.

Contents

  1. Installation
  2. Usage
  3. Contributing
  4. Author
  5. License

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!

A small overhead due to sending function and arguments over the network will still occur each time a reapy function is called from outside REAPER. When running the same function many times in a row (e.g. over a thousand times), using reapy.map may significantly increase performance. See its documentation for more details.

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!

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

reapy's People

Contributors

romeodespres avatar levitanus avatar kostikvento avatar teetow avatar chaberch avatar mercuree avatar tomas1808 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.