grimmdude / MidiPlayerJS

♬ MIDI parser & player engine for browser or Node. As a parser converts MIDI events into JSON. Works well with single or multitrack MIDI files.
https://grimmdude.com/MidiPlayerJS/
MIT License
357 stars 52 forks source link

Audio not playing from MidiWriterJS dataUri #91

Closed leocaseiro closed 1 year ago

leocaseiro commented 1 year ago

Hi there,

I've been exploring the usage of this library combined with the VexFlow integration based on MidiWriterJS, but the audio doesn't play.

Am I missing something, or is it broken?

https://codesandbox.io/s/vexflow-midiwriterjs-midiplayerjs-r3g4kw

(there is a button to play the audio, I can see the logs, but no audio is been played)

grimmdude commented 1 year ago

Hi @leocaseiro,

This library only fires the MIDI events at the appropriate time (what you're seeing in the logs). In order to use them to trigger a sound you must use a soundfont library; something like https://github.com/gleitz/midi-js-soundfonts or similar.

leocaseiro commented 1 year ago

Thank you @grimmdude.

I finally understood why we need to integrate with soundfont-player

Here is a working example, if anyone is interested:

https://codesandbox.io/s/vexflow-midiwriterjs-midiplayerjs-soundfount-player-r3g4kw