I'm not sure whether here or the dev forum is apt for a javascript question.
bc dev is more c++ and whatnot and here is more lua and jsfx and what not.
I am trying to parse a rpp file to an object literal or JSON so I can use it for my own evil ends or something useful for the reap com, one of the two I can't remember which.
if you have node up n running on your machine, you could run
Code:
const fs = require('fs');
const rppPath = '/home/garrick/Documents/test/test.RPP';
or if on windows
const rppPath = 'path\\withextra\\backslash\\test.RPP';
const rppArray = fs.readFileSync(rppPath, 'utf8')
.trim()
.split("\r\n") // get rid of the \r if on win
.map(line => line.split(" ")) // <-2 spaces in split
console.log(rppArray);
running this code should give you an easy visual idea of what i'm trying to achieve... and already the parent node of '<Reaper_project' is separated from the rest
Code:
[ [ '<REAPER_PROJECT', '0.1', '"4.78/x64"', '1510032077' ],
[ '', '', 'RIPPLE', '0' ],
[ '', '', 'GROUPOVERRIDE', '0', '0', '0' ],
[ '', '', 'AUTOXFADE', '1' ],
[ '', '', 'ENVATTACH', '1' ],
[ '', '', 'MIXERUIFLAGS', '11', '48' ],
[ '', '', 'PEAKGAIN', '1' ],
[ '', '', 'FEEDBACK', '0' ],
anyways this closer to where I am now
Code:
const fs = require('fs');
const rppPath = 'path/to/file';
const rppArray = fs.readFileSync(rppPath, 'utf8')
.trim()
.split("\r\n")
.map(line => line.split(" ") // <- one space
.map(piece => piece.split(" "))) // <- one space as well
console.log(rppArray)
this gives out put like
Code:
[ [ '' ], [ '' ], [ 'RIPPLE' ], [ '0' ] ],
[ [ '' ], [ '' ], [ 'GROUPOVERRIDE' ], [ '0' ], [ '0' ], [ '0' ] ],
[ [ '' ], [ '' ], [ 'AUTOXFADE' ], [ '1' ] ],
[ [ '' ], [ '' ], [ 'ENVATTACH' ], [ '1' ] ],
[ [ '' ], [ '' ], [ 'MIXERUIFLAGS' ], [ '11' ], [ '48' ] ],
[ [ '' ], [ '' ], [ 'PEAKGAIN' ], [ '1' ] ],
[ [ '' ], [ '' ], [ 'FEEDBACK' ], [ '0' ] ],
the idea is map out the children and grand-children nodes so I can do some fancy react/electron app that takes snap-shots of reaper projects with a flux/redux pattern.
fuck me, I almost forgot to ask a question
is there a way of doing
Code:
.map(line => line.split(" ")
.. better with some fancy regex?
can you do regex then regex again on the last result in one expression?