@stringsync/vexml
Version:
MusicXML to Vexflow
23 lines (22 loc) • 748 B
JavaScript
import * as mxl from '../../mxl';
import { MusicXMLParser } from '../../parsing/musicxml';
import { DEFAULT_CONFIG } from '../../config';
import { NoopLogger } from '../../debug';
/** Parses an MXL blob. */
export class MXLParser {
config;
log;
constructor(opts) {
this.config = { ...DEFAULT_CONFIG, ...opts?.config };
this.log = opts?.logger ?? new NoopLogger();
}
async parse(blob) {
const musicXML = await this.raw(blob);
const musicXMLParser = new MusicXMLParser({ config: this.config, logger: this.log });
return musicXMLParser.parse(musicXML);
}
/** Returns the MusicXML document as a string. */
async raw(blob) {
return new mxl.MXL(blob).getMusicXML();
}
}