并再次的Soundpool关于内存的问题 [英] and again about memory issues with SoundPool

查看:1128
本文介绍了并再次的Soundpool关于内存的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道的Soundpool旨在处理小FX一样的声音,我确信,我想一定顺序播放一个个都足够小我4声音剪辑。

I am aware that SoundPool was intended to handle small fx like sounds and I made sure my 4 sound clips which I want to play one by one in some sequence are small enough.

我用OGG质量0和剪辑是35KB,14KB,21KB和23KB共计COM pressed音频92KB。我不知道如何来估计uncom pressed大小会是什么,但它不应该有很多吧?

I used ogg quality 0 and clips are 35kb, 14kb, 21kb and 23kb totaling 92kb of compressed audio. I have no idea how to estimate what the uncompressed size would be, but it should not be a lot, right?

所以,当我按顺序播放4的声音,它可以很好地用于第9次(9序列×4的声音),但开始引起对声音的一个花枝招展序列内存问题。它始终是序列9时,我开始看到错误。

So when I play 4 sounds in sequence, it works well for first 9 times (9 sequences x 4 sounds) but starts to cause memory issues on the nines sequence for one of the sounds. It is always sequence 9 when I start to see error.

什么是处理,最好的方法是什么?我有几个想法:

What is the best way to handle that? I have a few ideas:

1)COM preSS的声音就更(OGG质量-1和单声道,而不是立体声)

1) compress sounds even more (ogg quality -1 and mono instead of stereo)

2)卸载和装载声音不断采用SoundPool.load和SoundPool.unload

2) unload and load sounds constantly using SoundPool.load and SoundPool.unload

3)释放和不时重建的Soundpool实例时

3) release and recreate soundPool instance time from time

还有什么我能做什么?这是令人尴尬的是Android的API无法处理这么小的片段。我不知道人们如何创造了很多的声音效果游戏...

Is there anything else I can do? It is embarrassing that android api cannot handle so small clips. I wonder how people create games with a lot of sound effects...

错误看起来像:

ERROR / AudioFlinger(35):没有足够的内存AudioTrack大小= 1048640
DEBUG / MemoryDe​​aler(35):AudioTrack(0x25018,大小= 1048576)

ERROR/AudioFlinger(35): not enough memory for AudioTrack size=1048640 DEBUG/MemoryDealer(35): AudioTrack (0x25018,size=1048576)

推荐答案

看来我还是能后解决我的问题:

It seems I was able to resolve my issue after:

1)下采样我的声音剪辑,从44到22kHz的。 Uncom pressed大小减少了一半(我想通了如何估算uncom pressed声音大小 - 您的剪辑导出到uncom pressed WAV)。我用漂亮的开源工具无畏

1) downsampled my sound clips from 44 to 22khz. Uncompressed size was cut in half (I figured how to estimate uncompressed sound size - export your clip to uncompressed wav). I used nice open source tool Audacity

2)修剪声音更加减少持续时间

2) trim the sounds more to reduce duration

3)把try /周围追赶()以防万一(它捕获错误时,尝试播放声音,但不能)

3) put try/catch around play() just in case (it does catch errors when it try to play the sound but cannot)

这篇关于并再次的Soundpool关于内存的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆