spessasus / SpessaSynth

MIDI SoundFont/DLS synthesizer library written in JavaScript.
https://spessasus.github.io/SpessaSynth/
Other
63 stars 5 forks source link

How to monitor the end of mid play? #25

Closed LiHongyao closed 1 month ago

LiHongyao commented 1 month ago

I use it in react, I don't know how to monitor the end of mid play, can you tell me how to achieve it? Thank you!

spessasus commented 1 month ago

Hi @LiHongyao,

I think the easiest way for detecting when the song has ended (assuming the loop is disabled) is by checking if the currentTime property of the sequencer is equal or larger than the duration property.

Although I can add a new event to the sequencer called addOnSogEndEvent if you'd like!

LiHongyao commented 1 month ago

Hi @LiHongyao,

I think the easiest way for detecting when the song has ended (assuming the loop is disabled) is by checking if the currentTime property of the sequencer is equal or larger than the duration property.

Although I can add a new event to the sequencer called addOnSogEndEvent if you'd like!

Thank you very much for your suggestion. If possible, I think adding addOnSogEndEvent is a very meaningful thing. Looking forward to your update, thank you again!

spessasus commented 1 month ago

I've added the onSongEnded event! I hope this helps.

Also, spessasynth_lib is now available as an npm package!. This can be helpful since you use react.