reapy.tools package

Submodules

reapy.tools.dist_program module

reapy.tools.inside_reaper module

Context manager for efficient calls from outside REAPER.

It can also be used as a function decorator.

Examples

Instead of running:

>>> project = reapy.Project()
>>> l = [project.bpm for i in range(1000)

which takes around 30 seconds, run:

>>> project = reapy.Project()
>>> with reapy.inside_reaper():
...     l = [project.bpm for i in range(1000)
...

which takes 0.1 seconds!

Example usage as decorator:

>>> @reapy.inside_reaper()
... def add_n_tracks(n):
...     for x in range(n):
...         reapy.Project().add_track()

reapy.tools.json module

Encode and decode reapy objects as JSON.

class reapy.tools.json.ClassCache[source]

Bases: dict

class reapy.tools.json.ReapyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

default(x)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
reapy.tools.json.dumps(x)[source]
reapy.tools.json.loads(s)[source]
reapy.tools.json.object_hook(x)[source]

reapy.tools.program module

Module contents

Define tools such as inside_reaper and custom json module.