soundpool

How bad is Android SoundPool? What alternative to use?

天大地大妈咪最大 提交于 2019-11-27 05:11:24
问题 I was looking at Android's SoundPool as a mechanism to implement sound effects in my generic game development library. It seemed ideal. But a little bit of research indicates that there all kinds of bugs in SoundPool . Are the bugs in SoundPool still relevant? Because I'm developing a library, any bugs in SoundPool become bugs in my library, and I want to insulate my users from that. So my question is basically: what API should I use for audio? Using AudioTrack and writing my own mixer is not

Playing multiple sounds using SoundManager

主宰稳场 提交于 2019-11-27 04:04:45
问题 If I play a single sound, it runs fine. Adding a second sound causes it to crash. Anyone know what is causing the problem? private SoundManager mSoundManager; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sos); mSoundManager = new SoundManager(); mSoundManager.initSounds(getBaseContext()); mSoundManager.addSound(1,R.raw.dit); mSoundManager.addSound(1,R.raw.dah); Button

Soundpool sample not ready

谁说我不能喝 提交于 2019-11-27 02:33:49
问题 I have a .wav file that I'd like to use across my game, currently I am loading the sound in onCreate() of each activity in the game. soundCount = soundpool.load(this,R.raw.count, 1); The sound will be played once the activity starts. soundpool.play(soundCount, 0.9f, 0.9f, 1, -1, 1f); Problem is at times I will hit the error "sample x not ready" . Is it possible to load the .wav file once upon starting the game and keep it in memory and use it later across the game? Or is it possible to wait

Play sound with SoundPool

断了今生、忘了曾经 提交于 2019-11-27 02:24:54
问题 I need to play a short sound in my application. I wrote the following code but I have no sound and strange vibration appeared on my Samsung phone. But in the same time this code works well on my android simulator. My code is: package com.samplers; import android.app.Activity; import android.media.SoundPool; import android.media.AudioManager; import android.os.Bundle; import android.view.View; import android.widget.Button; public class FixVibroActivity extends Activity { /** Called when the

AudioFlinger could not create track. status: -12

萝らか妹 提交于 2019-11-27 01:13:57
问题 I am programming for android 2.2 and am trying to using the SoundPool class to play several sounds simultaneously but at what feel like random times sound will stop coming out of the speakers. for each sound that would have been played this is printed in the logcat: AudioFlinger could not create track. status: -12 Error creating AudioTrack Audio track delete No exception is thrown and the program continues to execute without any changes except for the lack of volume. I've had a really hard

Android SoundPool.play() sometimes lags

依然范特西╮ 提交于 2019-11-26 23:23:51
问题 I'm currently facing an issue with my android game. Normally when calling SoundPool.play() the function needs about 0.003 seconds to finish, but sometimes it takes 0.2 seconds which makes my game stutter. where could his anomaly come from? 回答1: thanks to Tim, using a Thread for playing seemed to workaround the problem successfully. Thread package org.racenet.racesow.threads; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import org.racenet.racesow

How to properly use SoundPool on a game?

大城市里の小女人 提交于 2019-11-26 21:30:21
问题 I'm having performance issues while using SoundPool. Everytime I play a sound, the frame rate drops. I added some logs and I can see on logcat that the "play" function sometimes takes 8ms. I'm using *.ogg files and the SoundPool initialization is done on the app startup: mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); mSoundPool = new SoundPool(size, AudioManager.STREAM_MUSIC, 0); mSoundPoolMap = new HashMap<Integer, Integer>(); mSoundPoolMap.put(index,

Soundpool plays only first 5 secs of file. Why?

不想你离开。 提交于 2019-11-26 20:24:24
问题 I use Soundpool in my app, so far it works good, but I do have a wav file which is 10 secs. Unfortunately, soundpool plays only the first 5 secs. How to make soundpool to play the whole track? I have converted wav to -- ogg and mp3 still the same issue. It plays only the first 5 secs. Any help would be much appreciated. //set up audio player mSoundPool = new SoundPool(20, AudioManager.STREAM_MUSIC, 0); //load fx mSoundPoolMap.put(RAW_1_1, mSoundPool.load(this, R.raw.loop1, 1)); //playing

Play sound using soundpool example

本秂侑毒 提交于 2019-11-26 19:55:08
I would like to learn how to use soundpool method. I would like you to show me a very simple example that run 2 sounds. TheFlash Create a folder named as raw under your_app/res/ . Then paste your ringtone in this folder, for example your_app/res/ringtone.mp3 . Now use the following code: SoundPool soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0); int soundId = soundPool.load(context, R.raw.ringtone, 1); // soundId for reuse later on soundPool.play(soundId, 1, 1, 0, 0, 1); Be sure to release the SoundPool resources after use: soundPool.release(); soundPool = null; user3833732 Yes. i

Playing audio file from Sdcard

你。 提交于 2019-11-26 17:22:20
问题 I would like to play an audio file from the sdcard. How can I read the audio file and play it? Below is my code to play audio file: int sound1; sound1 = mSoundPool.load(this, R.raw.om, 1); mSoundPool.play(sound1, 1, 1, 1, time - 1, 1); Here in the above code i am using soundpool to play the audio file from raw folder but i need to play the audio file from sdcard using soundpool. Right now interested to play audio from sdcard. How to acheive this? please help i need to fix this as soon as