Search Unity

Doing sync WWW calls for AudioClip loading..

Discussion in 'General Graphics' started by ForrestX, May 6, 2015.

  1. ForrestX

    ForrestX

    Joined:
    Apr 17, 2010
    Posts:
    94
    I need to load an AudioClip externally (not from resources), but I need to do it Synchronously.

    or

    is there another (safe) way to load AudioClips from a file?

    basically I need to keep those wav files external to the BUILD, so that audio architect can overwrite those files and test ingame sounds, without having to open the original project.
     
  2. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,572
    I only know of asset bundles, but subscribing to hear about other options.
     
  3. 3agle

    3agle

    Joined:
    Jul 9, 2012
    Posts:
    508
    I'm not sure what you mean exactly by synchronously, but you can use the normal www request to download files from an external location, just use 'file:///' and Application.dataPath to reference the file.
    you can yield the www download and then choose to make the function blocking or non-blocking wherever you call it from.
    Then just use www.GetAudioClip() to fetch the audio file and do what you want with it. Could also stream it if it's a large file.

    We also have functionality to choose which audio format to load in, I don't quite remember why that is, some platform compatibility or something... That goes in the same place for us, we just have different folders for different formats.
     
  4. ForrestX

    ForrestX

    Joined:
    Apr 17, 2010
    Posts:
    94
    Indeed I went for synchro WWW calls...
    I needed to do that because I periodically give a Compiled build to an Audio architect and he simply replaces the wavs in a particular folder (StreamingAssets).
    This way I'm not forced to provide him the original project.

    It could be cool to have this feature in Master Audio :)