LOADSOUND problem with iPhone

Previous topic - Next topic

Alex_R

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.

bigsofty

Could you provide a minimal example piece of code, showing the problem?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Alex_R

#2
My code is too long but basically the main program has this structure:
Code (glbasic) Select

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


MrTAToad

Its quite possible on the iPhone that only one sample is allowed to play (unlike, say, music)

matchy

Multiple sounds on iOS works fine with me. I suggest using GENSOUND() and channel% = PLAYSOUND() for debugging.

Alex_R

In SUB LEVEL 2, if I remove the line "LOADSOUND "newSound.wav", 4, 2"  I can hear all sounds in the iPhone.

MrTAToad

Is it in a different format that the others ?

Alex_R

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.

Alex_R

I have changed the buffer number to all options with the same result.

MrTAToad

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

matchy

What is the value GENSOUND() is returning?

MrTAToad

Actually it could another case where by using "",xxx to unload something doesn't free the ID for use again