Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 2.2 - SoundPool sample 0 is not READY

I have searched StackOverflow and cannot find a situtation like mine. I am using four buttons with each button playing a sound file.
I am using SoundPool:
SoundPool sound = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);

I am also using the OnLoadCompleteListener() which uses Log to create an I notification in LogCat.
When I launch the program in the emulator I see all four samples complete loading. During the program three of the sounds will play, however, one will always say:
WARN/SoundPool(4842): sample 0 not READY

Any Ideas.. cause i'm quite flabbergasted. The sound files are 16-bit pcm wave file playing squarewave tones.
Load Code:
sound.setOnLoadCompleteListener(new OnLoadCompleteListener(){

        @Override
        public void onLoadComplete(SoundPool sound, int sampleId, int status) {
            if(status != 0)
                Log.e("SOUND LOAD"," Sound ID: " + sampleId + " Failed to load.");
            else
                Log.i("SOUND LOAD"," Sound ID: " + sampleId + " loaded.");
        }
    });

    soundID[0] = sound.load(this, R.raw.greennote, 1);
    soundID[1] = sound.load(this, R.raw.rednote, 1);
    soundID[2] = sound.load(this, R.raw.yellownote, 1);
    soundID[3] = sound.load(this, R.raw.bluenote, 1);


Play Sound:

streamid.setStreamId(myActivity.sound.play(id, 0.5f, 0.5f, 0, 0, 1));

like image 957
Tchiak Avatar asked Nov 05 '22 12:11

Tchiak


1 Answers

I'm having the same issues. From my experiments, it looks like there's something wrong with the ID handling. SoundPool just doesn't like sound IDs with the number 0.

So I have found a work-around. Start my sample IDs with 1, not 0. Hope this works.

like image 137
SMBiggs Avatar answered Nov 11 '22 11:11

SMBiggs