Author Topic: LOADSOUND problem with iPhone  (Read 3641 times)

Offline Alex_R

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
    • Axro Digital
LOADSOUND problem with iPhone
« on: 2012-Sep-18 »
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.

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2702
    • View Profile
Re: LOADSOUND problem with iPhone
« Reply #1 on: 2012-Sep-18 »
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)

Offline Alex_R

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
    • Axro Digital
Re: LOADSOUND problem with iPhone
« Reply #2 on: 2012-Sep-18 »
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
« Last Edit: 2012-Sep-18 by Alex_R »

MrTAToad

  • Guest
Re: LOADSOUND problem with iPhone
« Reply #3 on: 2012-Sep-18 »
Its quite possible on the iPhone that only one sample is allowed to play (unlike, say, music)

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1545
    • View Profile
Re: LOADSOUND problem with iPhone
« Reply #4 on: 2012-Sep-18 »
Multiple sounds on iOS works fine with me. I suggest using GENSOUND() and channel% = PLAYSOUND() for debugging.

Offline Alex_R

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
    • Axro Digital
Re: LOADSOUND problem with iPhone
« Reply #5 on: 2012-Sep-19 »
In SUB LEVEL 2, if I remove the line "LOADSOUND "newSound.wav", 4, 2"  I can hear all sounds in the iPhone.

MrTAToad

  • Guest
Re: LOADSOUND problem with iPhone
« Reply #6 on: 2012-Sep-19 »
Is it in a different format that the others ?

Offline Alex_R

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
    • Axro Digital
Re: LOADSOUND problem with iPhone
« Reply #7 on: 2012-Sep-19 »
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.

Offline Alex_R

  • Mr. Polyvector
  • ***
  • Posts: 238
    • View Profile
    • Axro Digital
Re: LOADSOUND problem with iPhone
« Reply #8 on: 2012-Sep-19 »
I have changed the buffer number to all options with the same result.

MrTAToad

  • Guest
Re: LOADSOUND problem with iPhone
« Reply #9 on: 2012-Sep-19 »
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

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1545
    • View Profile
Re: LOADSOUND problem with iPhone
« Reply #10 on: 2012-Sep-20 »
What is the value GENSOUND() is returning?

MrTAToad

  • Guest
Re: LOADSOUND problem with iPhone
« Reply #11 on: 2012-Sep-20 »
Actually it could another case where by using "",xxx to unload something doesn't free the ID for use again