views:

8157

answers:

11

Somehow my iPhone Simulator is unable to play sounds. First an app I'm working on using AudioServicesPlaySystemSound() stopped working.. I spent a while debugging this but sound is still working on the iPhone when I run the app on the device. I get the same results with other iPhone apps such as the sample Crash Landing app.

I can't find a sound setting anywhere in the simulator or Xcode preferences. I've tried resetting the simulator through "Reset Content and Settings" menu item to no avail.

A: 

I haven't found sound either, so I'm afraid there is no sound in the simulator. However I sure wish I was wrong!

Robert Gould
Hmm, I could swear it worked a few days ago. Maybe I'm just going crazy.
pix0r
Yeah, confirmed that sound IS supposed to work in the simulator. Have you tried Crash Landing or any other sample apps that use sound?
pix0r
+3  A: 

I've found sound to be very inconsistent in the simulator (2.1 SDK). Sometimes it works, sometimes it doesn't. Even when it does work, it's usually very choppy and distorted (when playing audio files such as mp3).

A few things to remember:

  • call AudioSessionInitialize as soon as your app finishes launching
  • set the kAudioSessionProperty_AudioCategory property for the session via AudioSessionSetProperty (with a value such as kAudioSessionCategory_MediaPlayback)
  • call AudioSessionSetActive(YES)

Of course when all else fails, just run it on your hardware!

EDIT: Now that the 2.2 SDK has been released, I haven't had any problems with sound in the simulator. They must have fixed the bugs! I highly recommend you upgrade to the 2.2 SDK.

Marc Novakowski
+1 thanks for this!
Robert Gould
+2  A: 

OpenAL not working on the simulator was fixed with the 2.1 SDK. Make sure Active SDK and Active Executable are set to 2.1.

By the way, make sure you're using the last version of CrashLanding (v1.8). Some nasty leaks in SoundEngine were fixed recently.

Steph Thirion
+13  A: 

You need to re-activate your system sounds, see the end of that page http://discussions.apple.com/thread.jspa?messageID=8883401

Thanks -- this worked for me. Go to System Preferences > Sound > Sound Effects and then uncheck and recheck "Play user interface sound effects". The iPhone Simulator suddenly started playing sound again after this.
NickD
thanks it works for me too! :) with iPhone SDK 3.2 and OSX 10.6
Sadat
A: 

System sound didn't work at all for me in the sim through 2.0, 2.1 and 2.2 SDKs. However, a few days ago it started magically working! This is with the 2.2.1 SDK, but building against 2.0 targets. I was really pleased!

Then yesterday I tried again and it no longer works. Same code, same machine, same build settings - same everything (different day). I tried all possible combinations of SDK version, exe version, config (debug/ release). I searched around again (hence hitting this thread), and tried a few other things (such as Marc's suggestion from Nov 19th of initialising the audio services API, even thought that shouldn't be required for system sounds AFAICS). All to no avail. It really does just seem to decide to play only when it wants to.

It's all very annoying because I'm trying to try out a lot of different sounds, and doing manipulations of them in wave editors and the dev cycle is much longer than it needs to be.

If anyone has any more ideas, I for one will still be monitoring this thread.

Phil Nash
A: 

I have the same problem, but my iPhone Simulator isn't playing the wav uncompressed files (it's playing mp3 background music however...).

This began to happens after I've installed and test ScreenFlow application (to capture the simulator screen and make a video). Sometimes I reboot the machine and the sounds came back, but it's like if the simulator load some kind of external plugin or configuration.

I tried to reinstall my XCode, but still the same problem. Now the sounds won't play even if I restart the machine :P

Leonardo Kasperavicius
A: 

Has anyone figured out why this is happening? I'm having the exact same issue as the previous poster here.

Sound worked perfectly using OpenAL with the SoundEngine then stopped working in the simulator for seemingly no reason. mp3 background tracks work, but trying to play .caf or .wav sound effects will not work. I get no console errors, tried running in various settings of debug/release/versions to no avail.

+1  A: 

[Fixed!!]

I've seen this problem after my update from OSX10.5.7 to 10.6.2

And I make the following changes to make the simulater sings again: Goto Applications/Utilities and run Audio MIDI Setup, Change midi format from 48000 to 44100.

my skype is [email protected], if your Simulator still has problems, please contact me, and I think we can discuss together.

Thanks.

Xie Wei
Thanks for the tip - my sound is still working in 10.6.2, but it's good to know that this fixed your issue.
pix0r
+1  A: 

if reactivating system sounds didn't work for you try this: launch audio-midi-setup, then configure your "built in output" to use 44.100Hz, 2 channels, 24 bits. (from http://www.cocos2d-iphone.org/forum/topic/4159)

somehow after a few days, my iphone simulator now wants 48.000Hz, 2 channels, 24 bits. just play with it for a bit and be warned that it might change randomly when plugging in headphones, going to standby, restarting, etc.

and here's a an off-topic hint: when you plug headphones into your iphone/ipad the buffer size might double (e.g. from 512bytes to 1024 bytes), make sure you don't rely on the buffersize you requested!

kritzikratzi
+3  A: 

[FIXED!]

I had no sound in the simulator, so I tested it with mobile safari and tried playing an mp3: No sound!

All the above tips didn't help. Eventually, I changed my INPUT source from the virtual soundflower device to Line-In, and the Simulator worked!!!

So, even if the app wasn't using input, it didn't work well with Soundflower.

Hope this helps.

auco
this worked for me as well. Xcode 3.2.3. OSX 10.63
John Ballinger
worked for me too -- I'd switched input to a USB headset and needed to switch back to Line-In. +1.
jstevenco
A: 

perfect.. solution worked on my end. thanks. John

John Bond
@John: First, welcome to Stack Overflow. We ask that you please use upvotes and comments (once you're able) to thank people. This is posted in the Answer section, but it isn't really an answer.
Bill the Lizard