Converting sounds

Member
Posts: 34
Joined: 2009.01
Post: #1
Hello this is my first post here.

I'm playing a wav file using the same code as in the oalTouch project. It plays fine.
Now I would like to reduce the file size of this sound, so I'm looking for a simple way to do that.
I tried using iTunes and "convert to AAC", it gives me a '.M4A' file that I add to my project, but then it seems the format is wrong.
The program exits in the MyGetOpenALAudioData ( ... ) function, when testing :
if ((theFileFormat.mFormatID != kAudioFormatLinearPCM) || (!TestAudioFormatNativeEndian(theFileFormat))) {
printf("MyGetOpenALAudioData - Unsupported Format, must be little-endian PCM\n"); goto Exit;
}

What's happening ? How do I convert wav to m4a ?
Thank you
Quote this message in a reply
Moderator
Posts: 623
Joined: 2007.09
Post: #2
Do you have a reason for using m4a over mp3?

I have no idea what you're using, but I find that mp3 is more widely supported.
But I could be wrong. Smile

- Lincoln Green
http://www.binkworks.com/
Quote this message in a reply
Member
Posts: 34
Joined: 2009.01
Post: #3
Hairball183 Wrote:Do you have a reason for using m4a over mp3?

I have no idea what you're using, but I find that mp3 is more widely supported.
But I could be wrong. Smile

I just follow what the Programming Guide says under "Best practices for iPhone audio", because I need to play a background music and a few sounds at the same time.
Well, I tried to play a MP3 file and have the same error.
Actually the AudioStreamBasicDescription data returned by AudioFileGetProperty doesn't seem to have the same informations and I have to change the code to handle it.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #4
As the error says, the OpenAL stuff needs to be little-endian PCM (i.e. uncompressed audio). I use little-endian wav files myself. For background music, use AVAudioPlayer with something compressed like mp3 or m4a. You can play multiple OpenAL sounds at once, but do not attempt to play multiple compressed music tracks at the same time because the iPhone audio hardware can only handle one at a time. I have frozen the device doing that by accident.
Quote this message in a reply
Member
Posts: 34
Joined: 2009.01
Post: #5
AnotherJake Wrote:For background music, use AVAudioPlayer with something compressed like mp3 or m4a. You can play multiple OpenAL sounds at once, but do not attempt to play multiple compressed music tracks at the same time because the iPhone audio hardware can only handle one at a time. I have frozen the device doing that by accident.

Thank you. It's ok with the AVAudioPlayer for the m4a file Smile.
Since this is for a main music the gain on the file size is important.
This music is played only on the game menu, along with small sounds, so I have to stop it before going into the game. I would like to mention that if I use a [audioPlayer stop] then I have no more sound in the game. So I just use [audioPlayer pause]. It seems the stop command really stops every other way of making sound.
I did the conversion with iTunes, is there a way to change the quality of the M4A output ? Or do I need another program ?
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #6
Fred9000 Wrote:I would like to mention that if I use a [audioPlayer stop] then I have no more sound in the game. So I just use [audioPlayer pause]. It seems the stop command really stops every other way of making sound.

Interesting, I haven't used stop or pause. I don't think stop should affect OpenAL. If it does, then that sounds like a bug in the OS. Maybe when you call stop, it deactivates the audio session? I don't know, just a wild guess. Music/audio on iPhone is still notoriously buggy, so I wouldn't be surprised.

When I go from the main menu to the game I just release the audio player and then alloc a new one for the game music, and same thing when going back to the main menu.

The way I modify audio file quality is importing into GarageBand, then changing volume/eq/etc., then exporting and re-converting in Quicktime. It's a major pain in the butt, but I don't know any other easy way with the tools I have.
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2009.01
Post: #7
Fred9000 Wrote:I did the conversion with iTunes, is there a way to change the quality of the M4A output ? Or do I need another program ?
If you go to the itunes preferences and click Import Settings you'll be able to change the encoding formats and quality levels.

If you want to make other changes Audacity is a good free option to go with.
Quote this message in a reply
Member
Posts: 34
Joined: 2009.01
Post: #8
AnotherJake Wrote:Interesting, I haven't used stop or pause. I don't think stop should affect OpenAL. If it does, then that sounds like a bug in the OS. Maybe when you call stop, it deactivates the audio session? I don't know, just a wild guess. Music/audio on iPhone is still notoriously buggy, so I wouldn't be surprised.

When I go from the main menu to the game I just release the audio player and then alloc a new one for the game music, and same thing when going back to the main menu.

The way I modify audio file quality is importing into GarageBand, then changing volume/eq/etc., then exporting and re-converting in Quicktime. It's a major pain in the butt, but I don't know any other easy way with the tools I have.

Well I'm using AVaudioPlayer for music and OpenAl for sounds. And stopping the AVplayer also stops the OpenAl. Maybe I'm doing something wrong elsewhere, but when I just pause the Avplayer, OpenAl can still play sounds.
Reconverting with Quicktime means you have a Pro version and, for the moment, I don't have it Smile
Quote this message in a reply
Member
Posts: 34
Joined: 2009.01
Post: #9
wootwootsound Wrote:If you go to the itunes preferences and click Import Settings you'll be able to change the encoding formats and quality levels.

If you want to make other changes Audacity is a good free option to go with.

Thank you. I'm new to iTunes and didn't find the Import Settings Sad though it's on the first page...

I'll give a try at Audacity.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #10
Fred9000 Wrote:Well I'm using AVaudioPlayer for music and OpenAl for sounds. And stopping the AVplayer also stops the OpenAl. Maybe I'm doing something wrong elsewhere, but when I just pause the Avplayer, OpenAl can still play sounds.
That doesn't sound like proper behavior to me. Be sure you initialize an audio session and set your session category. That *might* have something to do with it. I've run across all kinds of little issues relating to neglecting to do so myself. After that, if you can reproduce that then I'd consider filing a bug with Apple.

Like I mentioned, I just release the player without stopping or pausing it first and it doesn't affect OpenAL.

Fred9000 Wrote:Reconverting with Quicktime means you have a Pro version and, for the moment, I don't have it Smile
Ah, yes, forgot about that. I do indeed have the pro version.

There is also a command line tool, called afconvert, which you might try. On a glance, it looks kinda tricky to use.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Converting SQL into xcdatamodelid format Toontingy 1 3,924 Mar 14, 2011 10:43 AM
Last Post: SethWillits