views:

83

answers:

1

My *.wav's work as expected. But wav files are to big, so I want to play *.mp3 or *.ogg but it doesn't work.

I use this lines of code found in the finch Demo project

engine = [[Finch alloc] init];
sitar = [[Sound alloc] initWithFile:RSRC(@"sitar.wav")];
[sitar play];

So I only change sitar.wav into my .mp3 filename.

Note 1: It mustn't be mp3 or ogg, any file format not as huge as wav should be ok, but which ?

Note 2: I didn't know how to use sound, so I searched and found finch here at stackoverflow. It looks easy, so I would like to use that, but if you know some other easy way to play that sound files (ambient + effects sound with compressed codec) I would also switch to that other technique.

A: 

Unfortunately Finch does not support playing compressed audio (yet?). The decoding system is prepared for compressed audio decoding (see the PCM decoder for example of how to write a decoder), but there is currently no decoder for OGG, MP3 or anything like that. Also please note that if/when the compressed audio support comes, the compressed samples will be completely decompressed into the memory before playing, so that you won’t be able to play very long sounds anyway (because they would not fit into memory).

Finch is only meant to play short samples with low latency. If you want to play a longer compressed background track, simply use AVAudioPlayer.

zoul
Well it's some effects like laughing, a hit sound, a whistle and there is one sound that should be an audio track playin in background all the time
Allisone
That's pretty common scenario. Use AVAudioPlayer for the background track and Finch for the sound effects. Hopefully the effects will be short enough so that you can keep them in WAVs.
zoul