use .sfz soundfonts to render audio with WebMScore

211 Views Asked by At

I'm using WebMScore to render audio of music scores (it's a fork of MuseScore that runs in the browser or node).

I can successfully load my own, local .sf2 or .sf3 files, however

Trying to load an .sfz soundfont throws error 15424120. (And error.message is simply 'undefined'.)

Unlike .sf2 and .sf3, which contain the sounds and instructions in a single file, the .sfz format is just a text instruction file that refers to a separate folder of samples.

The reason I need the .sfz is that I need to be able to edit the .sfz file textually and programatically without an intervening Soundfont generator.

Is there a way to use .sfz's? Do I need to specify Zerberus (the Musescore .sfz player)? Do I need a different file structure? Please see below.

My environment is node js, with the following test case and file structure:

File Structure

Project Folder
    app.js
    testScore.mscz
    mySFZ.sfz
    samples
           one.wav
           two.wav
           etc.wav

Test Case (Works with .sf3 , errors with .sfz)

const WebMscore = require('webmscore');
const fs = require('fs');

// free example scores available at https://musescore.com/openscore/scores
const name = 'testScore.mscz';
const exportedPrefix = 'exported';
const filedata = fs.readFileSync(`./${name}`);

WebMscore.ready.then(async () => {
    const score = await WebMscore.load('mscz', filedata, [], false);
    await score.setSoundFont(fs.readFileSync('./mySFZ.sfz'));
    try { fs.writeFileSync(`./${exportedPrefix}.mp3`, await score.saveAudio('mp3')); } 
    catch (err) { console.log(err) } 
    score.destroy();
});
0

There are 0 best solutions below