简体   繁体   English

适当的音频格式可在Android手机上实现音效,并提高效率

[英]Appropriate audio format for sound effects on Android phones regarding efficiency

I profiled my programs, and it turned out a large portion of CPU was spent on SoundPool.play() . 我分析了我的程序,结果发现很大一部分CPU花费在SoundPool.play()

The game has ~10 sound files, each under 1 second. 游戏中有〜10个声音文件,每个文件不到1秒。 Currently they are 64kbs variable MP3s. 目前,它们是64kbs可变MP3。 They are loaded to a SoundPool at the beginning and played frequently throughout the game. 它们在开始时就被加载到SoundPool中,并在整个游戏中经常播放。

My question: What audio format (eg mp3, ogg, etc.) is most friendly to cpu and battery consumption on mobile devices? 我的问题:哪种音频格式(例如mp3,ogg等)最适合移动设备上的cpu和电池消耗? I use them only for sound effects, and there's no need for simultaneous playbacks. 我仅将它们用于声音效果,并且不需要同时播放。

Many thanks. 非常感谢。

As far as I know, there will be not much difference, as Android uncompresses the audio files before putting them into the SoundPool, in order to be able to quickly play them afterwards. 据我所知,两者之间并没有太大区别,因为Android在将音频文件放入SoundPool之前先对其进行解压缩,以便随后能够快速播放它们。 That's also the reason that you cannot put very many (or large) sounds into a sound pool without running out of memory. 这也是为什么您不能在没有内存不足的情况下将太多(或很大)的声音放入声音池的原因。

我希望WAV和MIDI等压缩程度很小的音频格式比MP3或Ogg消耗更少的CPU周期,但会占用更多RAM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM