Search Unity

Audio Crackling Audio Source Volume Adjustment

Discussion in 'Editor & General Support' started by dysdar, Sep 17, 2009.

  1. dysdar

    dysdar

    Joined:
    May 13, 2008
    Posts:
    13
    Hi. I am experiencing a very noticeable clicking/crackling noise with audio when adjusting audio source volume (audio.volume) via a script. I am working with Stereo uncompressed WAV files, and am simply adjusting the volume level of the audio source in relation to the distance from the camera with a script. The crackling/clicking is definitely not the result of an incorrect audio loop but seems to be directly related to quicker changes in amplitude. I have tried lerping the volume value and am still getting crackling with even quite slow changes in volume. Anyone got any suggestions? Thanks.
     
  2. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hello!

    Could you please show us a project or an example to check what your issue is? ;)
     
  3. dysdar

    dysdar

    Joined:
    May 13, 2008
    Posts:
    13
    Hi there. Here is a link to a simple example demonstrating the issue. I do not want to use positional mono audio in my project, instead am using stereo sound files. All I need is a simple system where distance from an object relates to volume of sound. In the example, move towards and away from the sphere using keys W S. You should hear crackling which does not occur when there is no movement. Am I missing something? Thanks very much.

    The example can be found here.....

    http://www.dysdar.org.uk/unityforum/
     
  4. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    My last paragraph here talks about it briefly:

    http://www.unifycommunity.com/wiki/index.php?title=Audio

    Unity has no concept of what direction a waveform is moving. So if you change the volume down, and the waveform is ascending, crackle. If you change the volume up, and the waveform is moving down, crackle. There's really no avoiding this at the current time without plugins.
     
  5. dysdar

    dysdar

    Joined:
    May 13, 2008
    Posts:
    13
    Thanks for the reply anyway Jessy. Is both surprising and frustrating. Really hope this issue is resolved in future updates. Do you know of any plugins that might help the issue? Or do I need to look into making my own? Thanks again.
     
  6. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Sorry, I have no experience with Unity plugins. But you'd need something that is essentially an entire other audio engine.
     
  7. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    Sorry, I forgot to offer the suggestion that I've sometimes found to be helpful in the past:

    I have no idea what's going on under the hood, but I've found that scripting the level of mono files tends to result in significantly fewer crackles. You can split your stereo file into two mono files, put them directly to the left and right of the listener (at the same distance, and 1 world unit is probably best). Then just set each of their volumes to be equal, and you may have better results.
     
  8. soren

    soren

    Joined:
    Feb 18, 2008
    Posts:
    123
    Hi dysdar,
    You're definitely not the first to report this issue since is been around since the first incarnation of Unity. This has been a hard one to solve with our existing audio backend (OpenAL, which behaviour differs wildly across hardware/OS's). However this is *fixed* in the upcoming 2.6 release (I just gave your project a run and there's def. crackles in 2.5 but not in 2.6). Until 2.6 (which is just around the corner) you can try out Jessy's suggestions and/or consult the advices given in other threads. Like:

    http://forum.unity3d.com/viewtopic.php?t=19455&postdays=0&postorder=asc&highlight=crackle&start=15
    http://forum.unity3d.com/viewtopic.php?t=26963&highlight=crackle
     
  9. dysdar

    dysdar

    Joined:
    May 13, 2008
    Posts:
    13
    Hi again. Thanks for your suggestions and input.

    Jessy, I have just tried putting two mono files either side of the listener. Unfortunately even more aggressive clicks and digital artifacts occur, seems that it doesn't work well with Mouse Look script. Am sure this method might help in other situations, but it seems its not the solution for me now.

    Soren, thanks for checking in 2.6. Great news it works in the new version. I think I'll wait for this to be released before completing the project as no other fixes have worked thus far. To be honest am just relieved it is going to be sorted soon as I only noticed the issue quite late on in developing my project.

    Thanks again guys. Andy.