本文介绍了多么糟糕的是Android的Soundpool?使用什么样的选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我一直在寻找Android的的Soundpool 以实现在我的通用游戏开发库的声音效果的机制。它的似乎的理想。I was looking at Android's SoundPool as a mechanism to implement sound effects in my generic game development library. It seemed ideal.不过,研究一点点表示有所有 种 of 虫子的Soundpool 。在的Soundpool 的错误还有用吗?But a little bit of research indicates that there all kinds of bugs in SoundPool. Are the bugs in SoundPool still relevant?由于我正在开发一个库,在的Soundpool 任何错误成为了我的图书馆的错误,我想从我的隔离用户。Because I'm developing a library, any bugs in SoundPool become bugs in my library, and I want to insulate my users from that.所以我的问题基本上是:我应该使用什么样的音频API So my question is basically: what API should I use for audio?使用 AudioTrack ,写我自己的调音台是不是出了问题。但很明显,这将是preferable避免这样做。而且没有任何的API,提供解码好吗?Using AudioTrack and writing my own mixer is not out of the question. But obviously it would be preferable to avoid doing that. And is there any API to provide decoding for me?我需要能够播放同步音效合理数量(至少16个,让我们说),并有更加开放。声音需要先从低延时播放。 WAV 文件需要支持(MP3 / OGG并不重要)。声音效果需要支持无缝循环和动态,个人音量调节。 Android应用程序的生命周期需要适当的支持。I need to be able to play a reasonable number of simultaneous sound effects (at least 16, let's say), and have even more open. Sounds need to start playing with low latency. WAV files need to be supported (MP3/Ogg is unimportant). Sound effects need to support seamless looping and dynamic, individual volume adjustment. The Android app lifecycle needs to be properly supported.我听说有一个1MB的限制某处的Soundpool ,这可能是可以接受每一个人的声音效果,但并非适用于所有的缓冲区/声音。谁可以告诉我的极限是什么?I have heard there is a 1MB limit somewhere for SoundPool, this is probably acceptable for each individual sound effect but not for all buffers/sounds. Can someone tell me exactly what the limit is on?最后,我需要能够播放背景音乐,以及在COM pressed格式,具有低CPU负载。我认为的MediaPlayer 是理想的这一点。它可以用于并联另一个API?Finally, I need to be able to play background music as well, in compressed formats, with low CPU load. I assume MediaPlayer is ideal for this. Can it be used in parallel with another API?我知道有不少人一直在使用的MediaPlayer 填写的的Soundpool 。但这是否支持我需要的功能?I know a few people have been using MediaPlayer to fill in for SoundPool. But does it support the features that I need?是否有任何其他的音频API的我已经错过了?Are there any other audio APIs I've missed?推荐答案我想补充在这个问题上最近的一些反馈。我一直在使用的Soundpool一段时间在一个应用程序与键preSS的声音相当大的用户群。我们的用例:Just to add some more recent feedback on this issue. I've been using SoundPool for some time in an app with a fairly large user base for key press sounds. Our use case:必须立即播放最多3+声音并行我们使用的 setRate 过它的全系列 [0.5F-2.0f] Must be played immediatelyUp to 3+ sounds in parallelWe make use of the setRate across it's full range [0.5f-2.0f]我现在已经经历了两次大的设备特定问题,并已决定把我的损失,从切换的Soundpool离开I've now experienced two major device specific issue and have decided to cut my losses and switch away from SoundPool在大量的4.4 LG电子器件(主要是LG的G2 / G3系)具有实施的Soundpool土生土长的崩溃。这是固定在一个更新(最终),但是我们仍然有很多用户使用未升级的设备在索尼Xperia设备目前有各种各样的问题与的Soundpool作为的报告的其他。就我而言,我发现,如果使用 setRate 与率> 1.0F 与抛出异常,直到您的应用程序退出的Soundpool(和烧透的过程中一堆电池)。A large number of 4.4 LG devices (mostly the LG G2/G3 line) were having a native crash with their implementation of SoundPool. This was fixed in an update (eventually) but we still have a lot of users with un-upgraded devicesSony Xperia devices currently have all sorts of issue with SoundPool as reported by others. In my case, I've discovered that if you use setRate with rate > 1.0f the SoundPool with start throwing exceptions until your app quits (and burn through a bunch of battery in the process). TL; DR;我不再认为这是值得的危险/调试的Soundpool的麻烦TL;DR; I no longer think it's worth the danger/hassle of debugging SoundPool 这篇关于多么糟糕的是Android的Soundpool?使用什么样的选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-20 20:04