Skip to content

Instantly share code, notes, and snippets.

@Gkiokan
Created March 8, 2023 16:25
Show Gist options
  • Save Gkiokan/7579c566ca80a9dfb7f6729cefd47f7a to your computer and use it in GitHub Desktop.
Save Gkiokan/7579c566ca80a9dfb7f6729cefd47f7a to your computer and use it in GitHub Desktop.
KORG PA Set STY Parser
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