Search Unity

AudioSource loop has audible gap in Webgl Player

Discussion in 'Web' started by DriesVienne, Jan 15, 2020.

  1. DriesVienne

    DriesVienne

    Joined:
    Jun 22, 2013
    Posts:
    27
    Tested on Firefox 72.0.1 (64-bit) (Windows)
    Build using Unity 2019.2.17f1

    See attached project for reproduction.

    Steps to reproduce
    - Open Unity project, open 'ReproScene', run in editor. Observe the audio looping correctly.
    - Build And Run for WebGL, Observe a gap when looping the audio.

    With some sounds this is more noticeable than with others.
    I'm not sure how to proceed from here.
    Any advice?

    Greetings,
    Dries
     

    Attached Files:

  2. FMEJIA5

    FMEJIA5

    Joined:
    Apr 27, 2020
    Posts:
    1
    Did you ever find a solution?
     
  3. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    Landed a fix to this issue in our trunk repository yesterday. It will be in for certain in 2021.1. Not yet sure how far we will be able to backport it, but trying to push it as far back as possible.

    To manually workaround, find file Audio.js inside the Unity installation directory, and modify the code from

    Code (JavaScript):
    1. JS_Sound_SetLoopPoints: function (channelInstance, loopStart, loopEnd)
    2. {
    3.     if (WEBAudio.audioWebEnabled == 0)
    4.         return;
    5.     var channel = WEBAudio.audioInstances[channelInstance];
    6.     channel.source.loopStart = loopStart;
    7.     channel.source.loopEnd = loopEnd;
    8. },
    9.  
    to

    Code (JavaScript):
    1. JS_Sound_SetLoopPoints: function (channelInstance, loopStart, loopEnd)
    2. {
    3.     if (WEBAudio.audioWebEnabled == 0)
    4.         return;
    5.     var channel = WEBAudio.audioInstances[channelInstance];
    6.     channel.source.loopStart = loopStart - 2112/44100;
    7.     channel.source.loopEnd = loopEnd - 2112/44100;
    8. },
    9.  
    Does that help?