Go Back   iPhone Dev SDK Forum > Development Forums > iPhone SDK Development

Notices

Featured Member Applications

x01 Score ($0.99)

TanZen ($0.99)

Endless Walls ($1.99)

Hiqup ($1.99)

XyPhone ($0.99)

Monkey Slap ($0.99)

Air Hockey ($0.99)

MyMemory ($1.99)

Folders ($1.99)

Under Pressure Football ($1.99)

iJuggles Nanimals ($0.99)

SUPER STRIKE - Motion Bowl ($0.99)

Want your application to be advertised here?

» Advertisements


Visit our friends over at The App Show! Steve and Dave produce a weekly show shining a light on the iPhone 2.0 software and the applications being developed by the amazing development community for the iPhone SDK!
» Online Users: 86
13 members and 73 guests
fladnag, ghost, jeff_lamarche, Kenrik, kwigbo, lapse, mozo, nerdhappy, noobAppDeveloper, odbc2000, PhoneyDeveloper, skinrock, zjuyxy
Most users ever online was 181, 09-23-2008 at 02:20 PM.
» Stats
Members: 2,742
Threads: 3,688
Posts: 15,102
Top Poster: scottiphone (594)
Welcome to our newest member, mozo
Reply
 
LinkBack Thread Tools Display Modes
Old 07-23-2008, 09:52 AM   #1 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 8
Rep Power: 0 StrAbZ is on a distinguished road
Default Mp3 Playback

I everybody.

I have question about the mp3 playback with the audio queue services.
I've take the SpeakHere Sample, and I just kept the AudioPlayer part since I don't need to record audio.

With it I've been able to play wav files without problem, but that don't work with mp3 or aac files. The playbackCallback function is only called when the setupAudioQueueBuffers is called and never again...

So is their anything I need to change this sample in order to play mp3 files...?

Thanks
StrAbZ is offline   Reply With Quote
Old 07-24-2008, 08:33 AM   #2 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 8
Rep Power: 0 StrAbZ is on a distinguished road
Default

Any body with an idea? ...
StrAbZ is offline   Reply With Quote
Old 07-24-2008, 11:00 AM   #3 (permalink)
Senior Member
 
MaCeXpErTo's Avatar
 
Join Date: Jul 2008
Posts: 91
Rep Power: 1 MaCeXpErTo is on a distinguished road
Smile Well...

Quote:
Originally Posted by StrAbZ View Post
I everybody.

I have question about the mp3 playback with the audio queue services.
I've take the SpeakHere Sample, and I just kept the AudioPlayer part since I don't need to record audio.

With it I've been able to play wav files without problem, but that don't work with mp3 or aac files. The playbackCallback function is only called when the setupAudioQueueBuffers is called and never again...

So is their anything I need to change this sample in order to play mp3 files...?

Thanks
I wouldn't recommend using mp3 period. I don't think the iphone likes mp3 files very well. I would use .caf files for sound only. Just convert your mp3 to caf. It's the best bet since you only can play 5 sec files anyway. Hope this helps.
MaCeXpErTo is offline   Reply With Quote
Old 07-24-2008, 11:30 AM   #4 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 8
Rep Power: 0 StrAbZ is on a distinguished road
Default

The fact is that I need to play mp3 since, the user of the application downloads the files before they are played, and mp3 are still one of the smallest audio files.

Maybe I didn't used the right word, by using "sound", since, that's audio files from about 5 to 10 min that I need to play...

You said that I only can play 5 sec files... but AudioQueueServices can play longer files... (the wav I play is about 40s). So I don't understand what you meaned...

thank u
StrAbZ is offline   Reply With Quote
Old 07-24-2008, 11:31 AM   #5 (permalink)
Member
 
Join Date: Jul 2008
Posts: 85
Rep Power: 0 mellomike
Default

Quote:
Originally Posted by MaCeXpErTo View Post
I wouldn't recommend using mp3 period. I don't think the iphone likes mp3 files very well. I would use .caf files for sound only. Just convert your mp3 to caf. It's the best bet since you only can play 5 sec files anyway. Hope this helps.
StrAbZ is using the Audio Queue services which can play sounds without a time limit....

Starbz I had the same problem as you... and the answer couldn't even be answered on the apple support forums. I decided to go with aif.. MP3 or AAC would be better for me since I can make the file sizes very small.

I hope you find the answer ... if you do, please share with us. I'll be researching it also.
mellomike is offline   Reply With Quote
Old 07-24-2008, 11:50 AM   #6 (permalink)
Senior Member
 
MaCeXpErTo's Avatar
 
Join Date: Jul 2008
Posts: 91
Rep Power: 1 MaCeXpErTo is on a distinguished road
Arrow Oh...

Quote:
Originally Posted by StrAbZ View Post
The fact is that I need to play mp3 since, the user of the application downloads the files before they are played, and mp3 are still one of the smallest audio files.

Maybe I didn't used the right word, by using "sound", since, that's audio files from about 5 to 10 min that I need to play...

You said that I only can play 5 sec files... but AudioQueueServices can play longer files... (the wav I play is about 40s). So I don't understand what you meaned...

thank u
Oh... Sorry, I missed the part of (AudioQueueServices) lol... Yea, you should be able to use mp3 in it. I've always been told to stay away from mp3 on the iphone. So that's why I convert everything but in your case you said you need it because of file size. I don't see why you couldn't use AAC? AAC isn't that far off from mp3 in size.

Anyways, have a look at this link. It should help you.

iPhone Audio (7 Parts)
MaCeXpErTo is offline   Reply With Quote
Old 07-24-2008, 12:45 PM   #7 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 8
Rep Power: 0 StrAbZ is on a distinguished road
Default

I'll be really happy to use AAC, but as the mp3 they don't play

I'll try your link, it's look like the code I already have, but maybe I miss something.

I'll be back soon
StrAbZ is offline   Reply With Quote
Old 07-24-2008, 12:48 PM   #8 (permalink)
Member
 
Join Date: Jul 2008
Posts: 85
Rep Power: 0 mellomike
Default

Quote:
Originally Posted by MaCeXpErTo View Post
Oh... Sorry, I missed the part of (AudioQueueServices) lol... Yea, you should be able to use mp3 in it. I've always been told to stay away from mp3 on the iphone. So that's why I convert everything but in your case you said you need it because of file size. I don't see why you couldn't use AAC? AAC isn't that far off from mp3 in size.

Anyways, have a look at this link. It should help you.

iPhone Audio (7 Parts)
That article was great... but sadly.. it doesn't explain how to use mp3 format or aac format.
mellomike is offline   Reply With Quote
Old 07-25-2008, 04:08 AM   #9 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 8
Rep Power: 0 StrAbZ is on a distinguished road
Default

So, I took a look at this link, but without success... I'm still getting the same thing... no sound

Just to be sure, for all my mp3 the "numPacketsToRead" calcuted is 19... is that good?

What's kills me , is that the code seems to work. It gives me the right audiofiles length, bitrate etc...
StrAbZ is offline   Reply With Quote
Old 08-20-2008, 12:08 PM   #10 (permalink)
Code Monkey
 
Join Date: Aug 2008
Location: San Jose
Posts: 7
Rep Power: 0 PKMousie is on a distinguished road
Default

I know the answer for you, I think! But I can only get you so far... since even though I can now play MP3 files perfectly on the simulator, I'm still having trouble getting them to behave correctly on the phone. But I CAN get at least one to play on the phone itself... so I know I'm 99% of the way there.

The SpeakHere sample (which I used as well, leading to much frustration) leaves out a hugely important piece of code. You need to manually allocate the package decriptions for VBR content... and AAC/MP3 files are always considered VBR even if they're encoded CBR!!! Here's the test and allocation:

Code:
// Test for VBR format files, which need extra initialization

if (audioFormat.mBytesPerPacket == 0 || audioFormat.mFramesPerPacket == 0) { 
    packetDescriptions = (AudioStreamPacketDescription*)malloc(
        numPacketsToRead * sizeof(AudioStreamPacketDescription) 
    ); 
} else { 
    packetDescriptions = NULL; 
}
Just stick a version of this somewhere in your code, after you've loaded the audio format information and calculated your packets to read and buffer sizes, but before you read and enqueue the data. It's all spelled out in the documentation, but it's easy to miss or think you don't need it (like I did). Once I added this allocation step, MP3s play just fine in the simulator! Woo!

Audio Queue Services Guide - Set Sizes for a Playback Audio Queue

I hope this helps, or helps anyone else who stumbles across your post when trying to figure this stuff out like I did!

And maybe now someone else can help me with my problem!
PKMousie is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Powered by vBadvanced CMPS v3.0.1

All times are GMT -5. The time now is 11:12 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0