Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to load .sfz soundfont instead of .sf3? #3

Open
ultraGentle opened this issue Aug 19, 2021 · 0 comments
Open

Possible to load .sfz soundfont instead of .sf3? #3

ultraGentle opened this issue Aug 19, 2021 · 0 comments

Comments

@ultraGentle
Copy link

ultraGentle commented Aug 19, 2021

WebMScore is great!

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'.)

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();

});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant