Sound works in simulator but not in device?

Discussion in 'Public Game Developers Forum' started by kohjingyu, Jul 6, 2009.

  1. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    Hey guys,
    So I play a sound when I press a button, and when I run it in the simulator, it works, but when I put it in my device, it doesn't work. The volume was at full, and the silent switch wasn't off. Anyone know what to do?
     
  2. drunknbass

    drunknbass Well-Known Member

    Nov 8, 2008
    128
    0
    0
    if you are using a method to play sounds that depends on it being pre allocated before you play it, sometimes the speed on your computer will make it seem as if its working in simulator when really the code isnt meant to work that way and youre getting 'lucky'.
     
  3. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    Oh...Then how am I supposed to play sounds?
     
  4. drunknbass

    drunknbass Well-Known Member

    Nov 8, 2008
    128
    0
    0
    dont allocates these sound fx right when you play them.. usually you pre allocate them and keep them in mem till you know youll never need it again.. aka beginning of level, etc.
     
  5. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    Oh ok thanks. No wonder it worked in my other app.
     
  6. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    Okay, so I preloaded my sounds in viewDidLoad. They play in the simulator but not in the real device. I don't understand, it works for my other app...Does the file extension .m4a work?
     
  7. monteboyd

    monteboyd Well-Known Member

    Maybe a long shot but check you are loading the exact right case for your sound files, e.g. you are loading "Sound.m4a" and not "sound.m4a" if your file is saved as "Sound.m4a".
    The device has a case-sensitive file system whereas the simulator does not.

    Having said that I can't tell you if m4a works or not.
     
  8. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    Yup I specified the right file. Hmm, anyone knows how to use the terminal conversion thing? I can't get it to work.
     
  9. Stroffolino

    Stroffolino Well-Known Member
    Patreon Silver

    Apr 28, 2009
    1,100
    8
    38
    Software Engineer
    Pennsylvania
    Which APIs are you using to play back the sounds? I've ran into plenty of .wav files that played fine in the simulator, but not on a real device. Reducing their size (by reducing frequency or bytes per sample) was almost always to get them working.
     
  10. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    I'm using <AudioToolbox/AudioServices.h> It's a short sound, about 1 second or so only. I'm pretty sure it's the file type, since I used the same method in another app and it worked. Does anybody know how to convert it to a .caf file? I heard of using terminal, but somehow I can't get it to work.
     
  11. Stroffolino

    Stroffolino Well-Known Member
    Patreon Silver

    Apr 28, 2009
    1,100
    8
    38
    Software Engineer
    Pennsylvania
    It's possible to export sounds as aiffs within itunes. A .caf is simply an aiff with its suffix renamed. That being said, it's possible to play .wavs on both simulator and device.
     
  12. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    Yup, so I got sounds files with a .caf extension. They worked perfectly. :)

    Now...Anyone know of a good free audio editor besides Audacity?
     
  13. Stroffolino

    Stroffolino Well-Known Member
    Patreon Silver

    Apr 28, 2009
    1,100
    8
    38
    Software Engineer
    Pennsylvania
    Audacity is "ok" but I much prefer GoldWave (free, fully functional demo) on PC. With GoldWave it's super easy to export sounds with exactly the bits per sample and frequency you like.
     

Share This Page