- Home /
Question by
L-W · Mar 08, 2015 at 02:35 AM ·
audiowwwcompressionogg
Compressing a WWW.GetAudioClip()'s Data?
Hello!
I've managed to read a .ogg file from my hard drive via Unity's WWW class with the code:
FileInfo f = new FileInfo(rootLocation + FilePath);
WWW www = new WWW("file://" + f.FullName);
AudioClip clip = www.GetAudioClip(true, false, AudioType.OGGVORBIS);
and it plays just fine, but the .ogg file itself is only 1,684KB whereas the above created AudioClip's (float[]) data array has a length of Hz x Seconds, which is 44100 x 85.334. This clogs the RAM of the game by about 30mb.
If I import that same .ogg file into Unity with the 'Compressed in memory' Load Type, and compress it down to about 1mb, it only fills the RAM with 1mb when loaded (as expected).
My question is, how can I somehow take the data of the AudioClip loaded in via WWW and apply the same magic that the Unity Editor does when importing the .ogg file, to compress it down to a much smaller size?
Comment