Created
March 8, 2023 16:25
-
-
Save Gkiokan/7579c566ca80a9dfb7f6729cefd47f7a to your computer and use it in GitHub Desktop.
KORG PA Set STY Parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const Parser = require('binary-parser').Parser; | |
// Define the structure of the STY file | |
const StyParser = new Parser() | |
.endianess('little') | |
.uint32('magic') | |
.uint32('version') | |
.uint32('size') | |
.string('name', { length: 32, encoding: 'ascii' }) | |
.uint16('ntracks') | |
.array('tracks', { | |
type: new Parser() | |
.uint32('size') | |
.string('name', { length: 32, encoding: 'ascii' }) | |
.uint16('npatterns') | |
.array('patterns', { | |
type: new Parser() | |
.uint32('size') | |
.uint16('nparts') | |
.array('parts', { | |
type: new Parser() | |
.uint32('size') | |
.uint16('flags') | |
.uint16('note_offset') | |
.uint8('mute') | |
}) | |
}) | |
}); | |
// Read the contents of the STY file | |
fs.readFile('path/to/your/file.sty', (err, data) => { | |
if (err) throw err; | |
// Parse the contents of the STY file | |
const parsedData = StyParser.parse(data); | |
// Use the parsed data to manipulate the style parameters | |
console.log(parsedData); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment