Author Topic: Sound effects  (Read 2527 times)

tokyotron

  • Member
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Sound effects
« on: Tue, May 15, 2012 »
Anyone know the reason why the sound effects are played using OA and not for instance AV Foundation?

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: Sound effects
« Reply #1 on: Tue, May 15, 2012 »
I don't know for sure, but I believe OpenAL is better performance wise for sounds. You can play multiple sounds at once.

Are you having problems with OpenAL.

There is a line that sets the freq to 22150 that needs to be taken out for it to work.
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

tokyotron

  • Member
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Sound effects
« Reply #2 on: Tue, May 15, 2012 »
Ok well it's possible to play multiple sounds using several AVAudioPlayer:s too, for instance. But I tried your fix from another thread and it works, so all is kind of well.  8)
Anyway I guess OA does not support mp3 etc and other compressed formats. I might have to think of a workaround if I'm gonna use lots of sounds... wanna keep app size down...

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: Sound effects
« Reply #3 on: Wed, May 16, 2012 »
Using CAF's can make the file size pretty big.
It would be awesome to be able to used compressed Mp3s for sound effects.
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

tokyotron

  • Member
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Sound effects
« Reply #4 on: Wed, May 16, 2012 »
I think I found out how I could do it, if I would really need it:

http://developer.apple.com/library/ios/#samplecode/iPhoneExtAudioFileConvertTest/Introduction/Intro.html

This is Apple's sample app - how to convert sounds. I just tried converting an mp3, then used it inside Flixel and it works. I output a PCM of 44100 hz. There's a function in there called DoConvertFile(), that should pretty much be enough to do this. You would need to convert the sound files when the app launches and put in cache or something like that.

Well, converting mp3s on the fly might be enough in some ways...