GithubHelp home page GithubHelp logo

perlence / rpp Goto Github PK

View Code? Open in Web Editor NEW
56.0 6.0 14.0 92 KB

Read and write Reaper RPP files with Python.

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%
python python3 reaper ply parser

rpp's Introduction

RPP

RPP is a format used to describe REAPER projects. This package is designed to be an RPP parser/emitter and uses PLY as a parser framework.

Examples

Import the package:

>>> import rpp

Decode RPP:

>>> r = rpp.loads("""\
<REAPER_PROJECT 0.1 "4.32" 1372525904
  RIPPLE 0
  GROUPOVERRIDE 0 0 0
  AUTOXFADE 1
>
""")
>>> r
Element(tag='REAPER_PROJECT', attrib=['0.1', '4.32', '1372525904'], children=[
    ['RIPPLE', '0'],
    ['GROUPOVERRIDE', '0', '0', '0'],
    ['AUTOXFADE', '1'],
])

Transform elements into RPP:

>>> from rpp import Element
>>> rpp.dumps(
...     Element(tag='REAPER_PROJECT', attrib=['0.1', '4.32', '1372525904'], children=[
...         ['RIPPLE', '0'],
...         ['GROUPOVERRIDE', '0', '0', '0'],
...         ['AUTOXFADE', '1'],
...     ]))
'<REAPER_PROJECT 0.1 4.32 1372525904\n  RIPPLE 0\n  GROUPOVERRIDE 0 0 0\n  AUTOXFADE 1\n>\n'

Element mimics the interface of xml.etree.ElementTree.Element. You can perform querying operations with findall, find, iterfind. Note that attribute and text predicates are not supported.

>>> groupoverride = r.find('.//GROUPOVERRIDE')
>>> groupoverride
['GROUPOVERRIDE', '0', '0', '0']
>>> groupoverride[1:] = ['9', '9', '9']
>>> r
Element(tag='REAPER_PROJECT', attrib=['0.1', '4.32', '1372525904'], children=[
    ['RIPPLE', '0'],
    ['GROUPOVERRIDE', '9', '9', '9'],
    ['AUTOXFADE', '1'],
])

Dependencies

rpp's People

Contributors

leighsmith avatar perlence avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rpp's Issues

Convert multiple MIDI files into single RPP with items and regions?

Is it possible to use Perlence to create a RPP file from multiple MIDI files with those files showing up as items with vertical regions? I notice that RPP files store MIDI in ASCII format. The MIDI files I have are binary. I want to be able to program in Python:

insert_MIDI(file1.mid, time=00:00:00)
insert_MIDI(file2.mid, time=00:02:25)
insert_MIDI(file3.mid, time=00:04:50)
create_region(start=00:00:00, end=00:02:25, name="intro")
create_region(start=00:02:25, end=00:04:50, name="part 1")
create_region(start=00:04:50, end=00:06:00, name="chorus")

Release a new version to pypi

I recently switched to Python 3.11 and found that rpp/rpp/encoder.py reports an error when executing from collections import Iterable.
After looking through the source code, I found that this fix has been fixed in commit 0ba3583, but it was not released to pypi.
Can you please release a new version, I guess it might be rpp 0.5? Thanks a lot :)

The rpp.dumps() method does not work properly with multi-level elements

Please see the following code

import rpp

fx_chain = '''\
<FXCHAIN_REC
  BYPASS 0 0
  <JS sstillwell/3x3 ""
    0 0 0 0 0 0 240 2400 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  >
  WAK 0 0
  BYPASS 0 0
  <JS loser/5BandJoiner ""
    0 0 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  >
  WAK 0 0
>'''

track = rpp.Element(tag='TRACK', attrib=[], children=fx_chain_formatted)
rpp_root = rpp.Element(tag='REAPER_PROJECT', attrib=['0.1', '6.09/x64', '1594105202'],
                    children=track)
final_result = rpp.dumps(rpp_root)

The logic of how the code works is simple, it starts with the fx_chain piece of data to create a project.
But the result of running the code is completely different from what I expect, only the outermost tag is kept in the final rpp.dumps operation, and all the tags in the inner level are ignored, and the result is as follows.

<REAPER_PROJECT 0.1 6.09/x64 1594105202
  BYPASS 0 0
  <JS sstillwell/3x3 ""
    0 0 0 0 0 0 240 2400 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  >
  WAK 0 0
  BYPASS 0 0
  <JS loser/5BandJoiner ""
    0 0 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  >
  WAK 0 0
>

I wonder if there is something wrong with the recursive logic in your code? THX

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.