Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Audio in WebGL

Discussion in 'Unity 5 Pre-order Beta' started by lami, Oct 29, 2014.

  1. lami

    lami

    Joined:
    Jun 17, 2013
    Posts:
    17
    Hi!

    I have some problems with Audioclips in WebGL.
    I have several very small Clips (about 1 to 4 seconds) that where created to sound nice when looping.
    It works fine for Webplayer and Standalone but when I switch the platform to WebGL it seems that they are converted and afterwards I experience a short moment of silence or a short amplitude (sse attached screenshot) at the beginning of the clips - which actually then breaks the nice looping sound.
    I tried with different formats (ogg, wav, mp3) and even tried editing the soundclip after conversion. But when I switch back to Unity it is still the same.
    It seems to me like it just happens to short sounds and does not affect my larger ones (~ 30 seconds)
    Is there any solution for this?

    webgl audio bug.png

    Regards,
    Steve
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    when you export to WebGL, we will transcode your audio to mp3, as we need a format which is uniformly supported on all supported browsers. Unfortunately, mp3 is not well suited for audio looping (see here for more information http://www.compuphase.com/mp3/mp3loops.htm), so this is difficult to avoid.

    Longer term, we are planning to move to AAC for WebGL audio, which does not have this issue. However, Firefox does not yet support AAC playback on OS X in the release version (they have added support in the latest nightlies, however), so we will ship 5.0 using mp3 for WebGL audio as is, and then switch to AAC later (probably for 5.1).
     
  3. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @jonas echterhoff,
    Isn't mp3 not supported by firefox?

    Quick related question:
    What format is best suited for streaming Unity - WebGL audio?
    Ogg like for WebPlayer or MP3?
     
  4. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    No, Firefox added mp3 support some time around the last year.

    Currently, mp3 is the only compressed audio format which works in Firefox, Chrome, Safari and IE.
     
    twobob likes this.
  5. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @jonas echterhoff, Oh boy bananza I was late on that! All that time away from the web, having fun with Unity... Ah! :D

    Thanks!