Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

How to deal with extremely large audio file?

Discussion in 'Audio & Video' started by danielnjackson, Feb 24, 2015.

  1. danielnjackson

    danielnjackson

    Joined:
    Nov 19, 2013
    Posts:
    2
    Hi,

    I'm working on a project that has some specific requirements that I'm not sure how to address. It's an art installation, which will only be run on one computer, so the size of the build isn't particularly important.

    The project has one 3 hour long audio file, only 45 seconds of which will be played at any time. It has to be able to start at any point in the 3 hour length, but after 45 seconds there's a significant silence (15 seconds or so).

    My initial assumption was that Unity would be able to load/buffer just the few seconds of the file it needed to play, but when I try to drop the (admittedly gigantic) file into the editor it crashes Unity every time.

    So: does anyone have any suggestions? I feel like there must be something very basic about the way Unity handles audio that I'm missing. Any help is deeply appreciated.
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,557
    Breaking it into smaller files seems to make the most sense.
     
  3. BenRawlesMusic

    BenRawlesMusic

    Joined:
    Jan 11, 2013
    Posts:
    165
    LaneFox's solution seems the best, but you might also be able to encode the file into a smaller format such as flac if the quality needs to remain the same, or ogg if not. But if the file is already compressed, I'd go with breaking it into smaller files. I can do it for you if you don't have experience working with audio.

    Ben
     
  4. danielnjackson

    danielnjackson

    Joined:
    Nov 19, 2013
    Posts:
    2
    Hey,

    Thanks so much for your answers. I ended up breaking the audio up into smaller pieces, it accomplished what we needed it to, but I still wonder if there's a way to get Unity to read from large external files.

    - Daniel.
     
  5. atmospherium

    atmospherium

    Joined:
    May 12, 2013
    Posts:
    38
    I can't think of a scenario where having a multi-hour audio clip would be beneficial. Even if you're playing the audio file from start to finish every time you run the program it would be much better to split it into sections and load them dynamically. There's only so much memory at your disposal and filling it unnecessarily with THAT much audio would be problematic. I would do everything within my power to avoid loading it all at once.
     
  6. KILEYI

    KILEYI

    Joined:
    Mar 7, 2015
    Posts:
    52
    i guess it can,unity supports set audio data manually,which means you can read part of the audio data direct to audioclip by copping the data to audioclip,could cause a lot of time depand on the data size.