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

Reply
 
Thread Tools Display Modes
Old 01-13-2021, 07:29 PM   #1
gxray
Human being with feelings
 
Join Date: Dec 2020
Location: Miami, FL USA
Posts: 396
Default API's for reading/subscribing to project "undo history" (for Realtime Collaboration)

I'm really interested in seeing how far along I can get with an extension for realtime collaboration between multiple people on a single REAPER project.

I've started work on this and have some groundwork laid for the plumbing, but I can't seem to find API methods for getting at this information:




I thought that "Undo_OnStateChange()" might accept a callback function that let you subscribe to state changes in undo-history and run some code, but I appear to have been sorely mistaken.

Does anyone know how I can get at the project history/history diff information?
If not, does anyone know where there is a parser/serializer for ".rpp" REAPER project files?

Might be able to write a custom diff tool if there's already tooling to parse the RPP files to plain objects.
__________________
Seasoned codemonkey
Dunno a thing about making music (here to learn!)
gxray is offline   Reply With Quote
Old 01-14-2021, 04:49 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Mrlimbic from Vordio wrote the most advanced rpp parser, in java,

We have portzd the v1 to lua, which I ported ti javascript

now he made a v2 more efficient, we have started port to lua with help of Aaron Cendan,
But it's been few wees of pause as it is not high priority.





It will allow to generate and manipulate rpp by writing custom functions,
and a git-like GUID based diff checker for collaboration was also in our "nice to do" projects though it was completly out of scope for now... Seems to take a loooot of time.
Though if it is something you are interested by... maybe we could finish the port...


BTW, seems you didnt learn coding via reascript, what is your background ?
X-Raym is offline   Reply With Quote
Old 01-14-2021, 09:21 AM   #3
gxray
Human being with feelings
 
Join Date: Dec 2020
Location: Miami, FL USA
Posts: 396
Default

Quote:
Originally Posted by X-Raym View Post
Mrlimbic from Vordio wrote the most advanced rpp parser, in java,

We have portzd the v1 to lua, which I ported ti javascript

now he made a v2 more efficient, we have started port to lua with help of Aaron Cendan,
But it's been few wees of pause as it is not high priority.


It will allow to generate and manipulate rpp by writing custom functions,
and a git-like GUID based diff checker for collaboration was also in our "nice to do" projects though it was completly out of scope for now... Seems to take a loooot of time.
Though if it is something you are interested by... maybe we could finish the port...
Yeah definitely, I will work on this if it is what is required to build the tooling needed for realtime project collaboration.

Really surprised that there doesn't seem to be ReaScript API's for reading the "undo history" or listening to project changes/events, or for parsing RPP's (built-in).

The parser you're mentioning, it's this one or based on it?
https://github.com/mrlimbic/reascrip.../RPPParser.lua

I also see you have this article where you talk about building an RPP tool
https://www.extremraym.com/en/ea-rpp-generator

---

So far, the general idea I have (and I don't know how well/if at all, this will even work)_is that:
  • I have a Python extension using reapy
  • The UI is HTML + CSS + JS via pywebview, with Python handlers for reapy bound to javascript so that it can be called from the UI in JS
  • When launching the Python extension, it will also start a rendezvous server for P2P connections between clients in a collaboration session (using something like py-libp2p)
  • The host launching the rendezvous server will get an identifier which contains the node's network address to send as a message to other users which want to collaborate
  • Other users will put the host's identifier in their extension, and then the Python code will start a P2P connection between their computer and the host via contacting the rendezvous server
  • Once users are connected to each other, changes made in the project by any user should be reflected realtime in the other projects
  • This can be done (I think) by either watching the project RPP file for changes, and then parsing and broadcasting them to other users via P2P messages, or by hooking into project "undo" history if this is possible
  • Media files (audio clips etc) can be streamed as binary data between connected peers, as they are added to the project. So if I add a loop/sample from my local hard-drive, the extension will copy it to the project directory on your computer as well
I only have the groundwork set up for the plugin, with reapy and the UI working + connected to REAPER currently:



I would love to get feedback/thoughts on how to do this from other people who understand REAPER and it's API + design much better than I do, like yourself and some of the other folks here.

Quote:
Originally Posted by X-Raym View Post
BTW, seems you didnt learn coding via reascript, what is your background ?
Ah, yes I only started trying to learn to produce music some months ago -- I've been a codemonkey for ~14 years (though only the last 6 or so were very serious).

Mostly I do web/mobile application development, frontend/backend/database/devops stuff.
Lot of Typescript/Javascript and Node (I really love Typescript and Node) though I've written a little bit of everything through the years haha
__________________
Seasoned codemonkey
Dunno a thing about making music (here to learn!)

Last edited by gxray; 01-14-2021 at 10:53 AM.
gxray is offline   Reply With Quote
Old 01-14-2021, 11:04 AM   #4
gxray
Human being with feelings
 
Join Date: Dec 2020
Location: Miami, FL USA
Posts: 396
Default

I want to add that Distributed Systems theory has a general toolkit for dealing with this kind of thing: "replicated datatypes" -- specifically "conflict-free replicated datatypes" (CRDT) libraries:

https://en.wikipedia.org/wiki/Confli...ated_data_type

So the technical hurdle is really to get the state of a REAPER project into a serialized/serializable format, as stateful information.
Then you can sync and replicate the state across peers and use CRDT libraries to handle most of the complexity (at least, in theory).

https://github.com/anshulahuja98/python3-crdt
__________________
Seasoned codemonkey
Dunno a thing about making music (here to learn!)
gxray is offline   Reply With Quote
Old 01-14-2021, 11:57 AM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

The parser you found is indeed the one I used for my generator, the one I ported to lua w8th mrlimbic help from his Java code.


But his updated his Java code recently and have working for a v2 of the Lua port which would use more modern Lua object styles and hoepfully be more efficient.


I'll tell you when it will be ready !


Note: I though there was an API for reading last history input but I may be wrong
X-Raym is offline   Reply With Quote
Old 01-14-2021, 11:58 AM   #6
mrlimbic
Human being with feelings
 
mrlimbic's Avatar
 
Join Date: Nov 2009
Location: UK
Posts: 669
Default

Quote:
Originally Posted by gxray View Post
The parser you're mentioning, it's this one or based on it?
https://github.com/mrlimbic/reascrip.../RPPParser.lua

I also see you have this article where you talk about building an RPP tool
https://www.extremraym.com/en/ea-rpp-generator
There is a better parser now. The new one is much faster, simpler and more fault tolerant.
__________________
Vordio - Post Production Toolkit
http://vordio.net
mrlimbic is offline   Reply With Quote
Old 01-14-2021, 01:42 PM   #7
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Problem with the undo state-approach, you might be able to get the state somehow, but you can't insert it in any way on the target system, unless the target system reloads the entire project. Which is painful for huge orchestral arrangement projects.

I once toyed around with it too to make project-changes possible, that have no Api-access yet, maybe even to replace the entire project using that(as SetProjectStateChunk-function) but you can't inject it in there, sadly.
__________________
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-14-2021, 01:45 PM   #8
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 X-Raym View Post
Note: I though there was an API for reading last history input but I may be wrong
Nope, no such api-function exists.
__________________
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
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 12:42 PM.


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