How to deal with extremely large audio file?

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.

Breaking it into smaller files seems to make the most sense.

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

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.

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.

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.