stcformat
v1.0.0
Published
Parser for the ZX Spectrum Soundtracker (.stc) file format
Downloads
2
Readme
stcformat
A parser for ZX Spectrum Soundtracker (.stc) files
Installation
npm install stcformat
Usage
This package exports a function readSTC
which accepts a buffer containing the binary data of the .stc file, and returns the data as a structured JSON-like object.
const fs = require("fs");
const { readSTC } = require('stcformat');
const buf = fs.readFileSync('myfile.stc'));
const stc = readSTC(buf);
The returned object contains the following items:
tempo
- the song tempo, in frames per rowlength
- the number of positions in the songsamples
- an array of sample objectspositions
- an array of positions, where each position is a two-element array of pattern number and transposition valueornaments
- an array of ornament objectspatterns
- an array of pattern objects
Sample objects consist of the items:
repeat
- the offset from which the sample will be repeated after reaching the end of the samplerepeatLength
- the length of the repeating sectionvolumes
- an array of 32 integers from 0 to 15, giving the volume over timenoiseLevels
- an array of 32 integers from 0 to 31, giving the noise periods over timetoneMasks
- an array of 32 booleans indicating the frames on which the tone generator is maskednoiseMasks
- an array of 32 booleans indicating the frames on which the noise generator is maskedtones
- an array of 32 integers giving the pitch offsets over time
Ornament objects consist of a single item tones
, an array of 32 integers giving the semitone offsets over time.
Pattern objects consist of the items:
length
- the number of rows in the patternchannels
- an array of 3 items, giving the note data for each channel. Each channel is an array of rows, where each row is a four-element array consisting of:- Note name as a string, e.g.
"C-4"
or"F#4"
- Sample number
- Effect number (8-14 to select an envelope, 15 for an ornament)
- Effect parameter (envelope period or ornament number)
- Note name as a string, e.g.