Jump to content

Howler.js dynamic music has gaps


gurkesaft
 Share

Recommended Posts

Hi all,

My goal is to create dynamic music that responds to what is happening in game. I am using Howler.js, but am happy to try other libraries. (Howler is pretty awesome, though!)

The way I'm approaching this is to chop up my music into loopable blocks, and then "queue up" the next block at the end of the current block. For this, I am currently using Howler's once('end', ...) functionality, with a structure similar to:

my_current_howl.once('end', function() { 

   my_next_howl.play();

});

It works. It's fun. The only problem is, depending on the cpu load, there is a variable gap in the music (always at least SOME gap, which precludes continuous waveforms).

It seems to me that looping does not suffer from this issue, but if I loop, then I'm stuck with one block looping over and over. I would imagine it should be possible to somehow modify the loop data while keeping the loop running but I cannot see how to do this in Hower.

Does anyone have any ideas or library suggestions? Is this a fundamental limitation? 

Cheers,
Jack

Link to comment
Share on other sites

  • 2 weeks later...

Timing is never a browsers strong point 😕

One option is to have, say, 3 pieces of music, all the same length, all set to loop, all set to start playing at the same time. But you change the volume of them to say, bring one bit of music whilst another fades out. Think of it like layering instruments in an orchestra.

Link to comment
Share on other sites

  • 4 weeks later...

Howler is doing an awesome job of maxing the compatibility. But it might be worth to take the time to setup your own AudioContext (or just use the one created by howler) and mix in time critical sounds/loops yourself.

Working with WebAudio and timing (especially if you like to sync things) I found this discussion VERY useful: WebAudio/web-audio-api-v2 [issue comment]. It helped me understand and make use of the baseLatency value.

Edited by xtoff
typo
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...