abcjs icon indicating copy to clipboard operation
abcjs copied to clipboard

Allow the user to customize getNote() function

Open SilentAntenna opened this issue 4 years ago • 4 comments

Hi Paul.

Thank you for this nice library. I have used it for my personal music note-taking app.
However, the 6+ version of the library is no longer compatible with the old sound font format for midi.js, which is quite an inconvenience. To solve the compatibility problem, we should allow the user to load the sound font on their own. We can keep the original getNote() function as the default loader.

SilentAntenna avatar Sep 20 '21 12:09 SilentAntenna

I am surprised by this - I thought it was compatible. What error are you seeing?

paulrosen avatar Sep 21 '21 23:09 paulrosen

File not found.

The new loader only accepts raw mp3 audio with the path being soundfontpath/instrumentname-mp3/notename.mp3. Midi.js can also load packed mp3/ogg files like instrumentname-mp3.js and instrumentname-ogg.js. You can see these files in gleitz's repo.

SilentAntenna avatar Sep 22 '21 03:09 SilentAntenna

So, would you like an option for the user to replace getNote, so that you pass in a function to use instead?

paulrosen avatar Sep 25 '21 14:09 paulrosen

This would be good.

Actually, I think the user should set this function at config.soundfont. This value can either be a string (sound font path), a normal function or a function returning a promise.

SilentAntenna avatar Sep 25 '21 14:09 SilentAntenna