如何减小iPhone应用程序的.wav音频文件的大小?

时间:2023-01-12 18:42:14

I have some music that loops. The .wav file size is about 8 meg. I load this and just loop it... everything was working fine until I added another 4 meg .wav file. Now the game crashes... removing the additional audio file fixed the crashing.

我有一些循环的音乐。 .wav文件大小约为8兆。我加载它只是循环它...一切正常,直到我添加另一个4 meg .wav文件。现在游戏崩溃...删除额外的音频文件修复了崩溃。

So how can I reduce the size of these .wav files? I thought about releasing the memory after I'm done with the 4 meg file but what I tried didn't work (and I'd rather the game itself be a smaller file size so it's easier to download).

那么如何减小这些.wav文件的大小呢?我想在完成4兆字节文件之后释放内存,但我尝试的东西不起作用(我宁愿游戏本身是一个较小的文件大小,所以它更容易下载)。

Thanks!

5 个解决方案

#1


If you're only playing one sound file at a time, just use mp3 or aac. That way you also get hardware decoding, for improved performance and battery life.

如果你一次只播放一个声音文件,只需使用mp3或aac。这样您就可以获得硬件解码,从而提高性能和延长电池寿命。

Unfortunately, the iPhone can only play one hardware decoded sound file at a time. So if you're looking to ever play more than one at once, you'll need to do your own decoding of the second file; IMA 4:1 is recommended, though you'll have to find or implement your own decoder, Apple doesn't give you one.

不幸的是,iPhone一次只能播放一个硬件解码的声音文件。因此,如果您希望一次播放多个,您需要自己解码第二个文件;建议使用IMA 4:1,但是你必须找到或实现自己的解码器,Apple不会给你一个。

This is all based off of this blog post, which goes into a bit more detail.

这完全基于这篇博文,更详细。

#2


Actually .WAV is a container. The contents can be compressed or uncompressed, it all depends on the WAVEFORMATEX structure contained in the first "fmt " tag in the .WAV file.

实际上.WAV是一个容器。内容可以压缩或解压缩,这完全取决于.WAV文件中第一个“fmt”标记中包含的WAVEFORMATEX结构。

For instance, in Windows 7 all of the built-in sounds are .WAV files that contain MP3 data.

例如,在Windows 7中,所有内置声音都是包含MP3数据的.WAV文件。

You can just author your .WAV files as MP3 files and (assuming that the iPhone correctly handles the .WAV container) they should work.

您可以将.WAV文件创建为MP3文件,并且(假设iPhone正确处理.WAV容器)它们应该可以工作。

#3


Wav in a uncompressed format will inevitably take up tons of space. 8 Megs is not really big for an uncompressed wav.

未压缩格式的Wav将不可避免地占用大量空间。对于未压缩的wav,8 Megs并不是很大。

You should consider an alternate, compressed format such as mp3 or aac. You might need to link in a decoding library though.

你应该考虑一种替代的压缩格式,如mp3或aac。您可能需要链接到解码库中。

Check out this link on including mp3 files in your iphone app:

在我的iPhone应用程序中查看包含mp3文件的链接:

#4


If your WAV files are stereo, you could try making them mono. This would basically half the file size. The disadvantage would obviously be that your sound is now mono.

如果您的WAV文件是立体声,您可以尝试将它们设为单声道。这基本上是文件大小的一半。显而易见的缺点是你的声音现在是单音。

#5


I wouldn't use WAV. Take a look at ffmpegx. It's free, runs on the mac and will convert your waves files to MP3 or a host of other formats.

我不会使用WAV。看看ffmpegx。它是免费的,在Mac上运行,并将您的wave文件转换为MP3或许多其他格式。

#1


If you're only playing one sound file at a time, just use mp3 or aac. That way you also get hardware decoding, for improved performance and battery life.

如果你一次只播放一个声音文件,只需使用mp3或aac。这样您就可以获得硬件解码,从而提高性能和延长电池寿命。

Unfortunately, the iPhone can only play one hardware decoded sound file at a time. So if you're looking to ever play more than one at once, you'll need to do your own decoding of the second file; IMA 4:1 is recommended, though you'll have to find or implement your own decoder, Apple doesn't give you one.

不幸的是,iPhone一次只能播放一个硬件解码的声音文件。因此,如果您希望一次播放多个,您需要自己解码第二个文件;建议使用IMA 4:1,但是你必须找到或实现自己的解码器,Apple不会给你一个。

This is all based off of this blog post, which goes into a bit more detail.

这完全基于这篇博文,更详细。

#2


Actually .WAV is a container. The contents can be compressed or uncompressed, it all depends on the WAVEFORMATEX structure contained in the first "fmt " tag in the .WAV file.

实际上.WAV是一个容器。内容可以压缩或解压缩,这完全取决于.WAV文件中第一个“fmt”标记中包含的WAVEFORMATEX结构。

For instance, in Windows 7 all of the built-in sounds are .WAV files that contain MP3 data.

例如,在Windows 7中,所有内置声音都是包含MP3数据的.WAV文件。

You can just author your .WAV files as MP3 files and (assuming that the iPhone correctly handles the .WAV container) they should work.

您可以将.WAV文件创建为MP3文件,并且(假设iPhone正确处理.WAV容器)它们应该可以工作。

#3


Wav in a uncompressed format will inevitably take up tons of space. 8 Megs is not really big for an uncompressed wav.

未压缩格式的Wav将不可避免地占用大量空间。对于未压缩的wav,8 Megs并不是很大。

You should consider an alternate, compressed format such as mp3 or aac. You might need to link in a decoding library though.

你应该考虑一种替代的压缩格式,如mp3或aac。您可能需要链接到解码库中。

Check out this link on including mp3 files in your iphone app:

在我的iPhone应用程序中查看包含mp3文件的链接:

#4


If your WAV files are stereo, you could try making them mono. This would basically half the file size. The disadvantage would obviously be that your sound is now mono.

如果您的WAV文件是立体声,您可以尝试将它们设为单声道。这基本上是文件大小的一半。显而易见的缺点是你的声音现在是单音。

#5


I wouldn't use WAV. Take a look at ffmpegx. It's free, runs on the mac and will convert your waves files to MP3 or a host of other formats.

我不会使用WAV。看看ffmpegx。它是免费的,在Mac上运行,并将您的wave文件转换为MP3或许多其他格式。