At the beginning of my game I load 10 differents sounds with 0 to 9 IDs. The sound at the first level runs fine. At the second level I change just the ID #2 sound (only one sound) for other new but keeping intact the rest. The new sound has the same frequency and properties than the old one.
In my PC all sounds play fine but in my iPhone something happens (I think a bug). The new sound plays but not the rest. It seems like these sounds are not in the memory any more . If I want to play them again I have to load every sound at the beginning of every level, even if I need change only one.
Could you provide a minimal example piece of code, showing the problem?
My code is too long but basically the main program has this structure:
GLOBAL level%=1
//Load resorces:
LOADSOUND "Sound1.wav", 0, 2
LOADSOUND "Sound2.wav", 1, 2
LOADSOUND "Sound3.wav", 2, 2
LOADSOUND "Sound4.wav", 3, 2
LOADSOUND "Sound5.wav", 4, 2
WHILE TRUE
SELECT level%
CASE 1
GOSUB LEVEL1
CASE 2
GOSUB LEVEL2
ENDSELECT
PRINT "Push space bar",10,10,1
SHOWSCREEN
WEND
SUB LEVEL1
WHILE TRUE
// Do level 1 stuff
IF KEY(57) = 1
PLAYSOUND (0,1,1) //Here plays fine
PLAYSOUND (1,1,1) //Here plays fine
PLAYSOUND (2,1,1) //Here plays fine
PLAYSOUND (3,1,1) //Here plays fine
PLAYSOUND (4,1,1)//Here plays fine
level%=2
RETURN
ENDIF
WEND
PRINT "Push space bar to level 2",10,10,1
SHOWSCREEN
ENDSUB
SUB LEVEL2
LOADSOUND "newSound.wav", 4, 2
WHILE TRUE
// Do level 2 stuff
IF KEY(57) = 1
PLAYSOUND (0,1,1) //Doesn't play in iPhone. Yes in PC version
PLAYSOUND (1,1,1) //Doesn't play in iPhone. Yes in PC version
PLAYSOUND (2,1,1) //Doesn't play in iPhone. Yes in PC version
PLAYSOUND (3,1,1) //Doesn't play in iPhone. Yes in PC version
PLAYSOUND (4,1,1)//Here plays fine the new sound.
level%=2
RETURN
ENDIF
PRINT "Push space bar to level 1",10,10,1
SHOWSCREEN
WEND
ENDSUB
Its quite possible on the iPhone that only one sample is allowed to play (unlike, say, music)
Multiple sounds on iOS works fine with me. I suggest using GENSOUND() and channel% = PLAYSOUND() for debugging.
In SUB LEVEL 2, if I remove the line "LOADSOUND "newSound.wav", 4, 2" I can hear all sounds in the iPhone.
Is it in a different format that the others ?
No, the format is the same. I have tested with several sounds. I can hear all of them at level 1 in my example. I think the problems comes when I replace a sound for another.
I have changed the buffer number to all options with the same result.
I wonder if its a loading bug - you would be using the same ID number twice, and I wonder if its removing the old one incorrectly or something
What is the value GENSOUND() is returning?
Actually it could another case where by using "",xxx to unload something doesn't free the ID for use again