Audio Queues

Apprentice
Posts: 5
Joined: 2008.09
Post: #91
Just a quick update on this, the problem seems to clear itself once you run a different app that also uses AudioQueue music. So with that extra code added to trap the error in the priming process and eliminate the device lockup, the overall problem probably isn't too bad.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #92
Yes, this is a nasty, nasty problem I've known about for some time. Apparently the iPod app sticks around, plugging up hardware, even after it has been quit and says there's no other music playing. I posted some of my solution (workaround) already in this other thread:

http://www.idevgames.com/forum/showthread.php?t=16048

Basically what I do is detect if other audio is playing. If it's not, then I temporarily switch the session to kAudioSessionCategory_MediaPlayback, which seems to kick out any remnants, and then back to ambient to honor the silent switch. So far this seems to work for me, but I think I've still had a few glitches here and there if the user double-clicks the home button to play music during the game.
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2008.09
Post: #93
Ha! Thanks AnotherJake, that pointed me in exactly the direction I needed for the last piece of the puzzle. I'm so happy to have a suitably complete work around for this.

I'd still recommend anyone using this code add some kind of AudioQueuePrime error check in the play function though, because if it does fail and you don't catch it, it gets ugly Annoyed.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #94
Gavin Bowman Wrote:I'd still recommend anyone using this code add some kind of AudioQueuePrime error check in the play function though, because if it does fail and you don't catch it, it gets ugly Annoyed.

Yes, I agree. I updated GBMusicTrack, at the top of this thread, to include your check at play. Thanks.
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2008.12
Post: #95
Has anyone parsed out the metadata information from the file? I am trying to find how it is done. I know there was a post earlier by anotherjake but I can't find any other information on the web about pulling out the song name and the artist name and other attributes of the mp3. Any help would be great. TIA
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #96
Bumping this thread to let everyone know that I recommend using AVAudioPlayer now, which is what I've been using myself, as of iPhone OS 2.2. AVAudioPlayer does pretty much exactly the same thing but it's maintained by Apple, which has obvious benefits. Wink

Again, I'd like to thank all those who've emailed me about it over the last several months. I had no idea it was that badly needed, and according to what you've told me, it has served its purpose. I know of numerous folks who are using it, or parts of it, in products on the App Store. I'm still receiving an email from time to time about it from newcomers and I'd like to remind them that AVAudioPlayer is now the way to go for playing background music on iPhone.
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2009.01
Post: #97
AnotherJake Wrote:Bumping this thread to let everyone know that I recommend using AVAudioPlayer now, which is what I've been using myself, as of iPhone OS 2.2. AVAudioPlayer does pretty much exactly the same thing but it's maintained by Apple, which has obvious benefits. Wink

Again, I'd like to thank all those who've emailed me about it over the last several months. I had no idea it was that badly needed, and according to what you've told me, it has served its purpose. I know of numerous folks who are using it, or parts of it, in products on the App Store. I'm still receiving an email from time to time about it from newcomers and I'd like to remind them that AVAudioPlayer is now the way to go for playing background music on iPhone.

So, I'm not seeing much discussion on the forums / blogs about AVAudioPlayer or AVAudioPlayerDelegate.

Is no one else encountering problems with it? In my app, used alongside openAL, it's crashing about 10 seconds after the played track ends.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #98
That's interesting. I don't have a situation where I'm not looping my music with AVAudioPlayer so I can't say I've seen that myself. If you can reproduce it, please file a bug with Apple Smile
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2008.09
Post: #99
Heh. Figures after all the Audio Queues struggles Apple finally decides to make playing audio less painful. Well, I can't say for sure because I've not tried this stuff yet but anything has to be better. Is there an equivalent package for recording audio? Actually I don't even need to record the audio, I just need to detect the audio levels coming in so it can interact with my new app. Could I just rip out the actual file writing from SpeakHere and do that or would that cause some crazy bug further down the line?
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #100
I don't know about any recording capabilities easier than Audio Queues. You most definitely can use the SpeakHere sample and take out the file recording stuff. As you know, Audio Queues has a meter, which is convenient. What is not so convenient is that there is about a half to one second or so delay between batches of input audio that it sends you (on the Mac for sure, but I haven't tested on a device). It's good enough for recording, but not fast enough for applications demanding real-time input.

For fast real-time input on iPhone you'd have to use RemoteIO. It's not impossible to use but the documentation stinks. It's lower-level so there's a bit more to it than Audio Queues, and there's no built-in meter that I am aware of, although you can certainly make your own if you know anything about basic audio signal processing.

Here's an article on using RemoteIO which is helpful for deciphering how to use it on iPhone. For Mac, the procedure is slightly different but similar, using Audio Units. A decent example to cross-reference with is the RecordAudioToFile sample. That can help you figure out what's happening with RemoteIO on iPhone if you dare attempt the challenge.
Quote this message in a reply
Apprentice
Posts: 11
Joined: 2008.09
Post: #101
Hmmmm...the RemoteIO() stuff certainly seems interesting but audio and I generally don't get along very well (hence my relief at using your GBMusicTrack class) so I'll probably just gut out the SpeakHere sample. Thanks for the tip though. I was just hoping Apple would throw me another bone heh.
Thanks
MoP
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2009.01
Post: #102
RemoteIO is a bear. I don't recommend it.

AVAudioPlayer was unreliable for me - perhaps it conflicted with OpenAL.

AudioQueues still seem to have their role: they can play compressed ima4s and mp3s (good luck going that with RemoteIO).
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #103
kordos Wrote:RemoteIO is a bear. I don't recommend it.

Yes, definitely not for the beginner. Wink

kordos Wrote:AVAudioPlayer was unreliable for me - perhaps it conflicted with OpenAL.

I haven't had any troubles with AVAudioPlayer myself, although I seem to recall a report or two from others having some issues, but I can't remember what they were.

kordos Wrote:AudioQueues still seem to have their role: they can play compressed ima4s and mp3s (good luck going that with RemoteIO).

Yeah, RemoteIO definitely wasn't purposed for easy file playback. I only recommend RemoteIO for real-time needs. AudioQueues/AVAudioPlayer are definitely the way to go for most playback needs.
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2009.01
Post: #104
Jake - is it possible to load an Audio Queue buffer _manually_ (i.e. with memcpy() or somesuch), without using AudioFileReadPackets?

I want to loop short (~400k) sound files with audio queues, but constantly hitting the file in the callback causes some hiccups when looping on the iPhone (not on the simulator) - even for uncompressed files.
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2009.01
Post: #105
Nevermind, I got it - was forgetting to set buffer->mAudioDataByteSize after the memcpy().

Thanks again for your help and guidance for us noobs Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Core Audio mutlichannel audio tachyon 2 6,388 Mar 18, 2005 01:04 AM
Last Post: tachyon