Android 手机上音效的适当音频格式(关于效率)
我分析了我的程序,结果发现很大一部分 CPU 都花在了 SoundPool.play()
上。
游戏有大约 10 个声音文件,每个声音文件不到 1 秒。目前它们是 64kbs 可变 MP3。它们在开始时加载到 SoundPool
中,并在整个游戏中频繁播放。
我的问题:什么音频格式(例如mp3、ogg等)对移动设备上的CPU和电池消耗最友好?我仅将它们用于音效,不需要同时播放。
非常感谢。
I profiled my programs, and it turned out a large portion of CPU was spent on SoundPool.play()
.
The game has ~10 sound files, each under 1 second. Currently they are 64kbs variable MP3s. They are loaded to a SoundPool
at the beginning and played frequently throughout the game.
My question: What audio format (e.g. mp3, ogg, etc.) is most friendly to cpu and battery consumption on mobile devices? I use them only for sound effects, and there's no need for simultaneous playbacks.
Many thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,不会有太大区别,因为Android会在将音频文件放入SoundPool之前对其进行解压缩,以便之后能够快速播放它们。
这也是您无法在不耗尽内存的情况下将大量(或大量)声音放入声音池的原因。
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.
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 使用量更高。
I'd expect audio formats with little compression like WAV and MIDI to consume fewer CPU cycles than MP3 or Ogg at the cost of higher RAM usage.