Preview: New Audio Engine Powered by OpenAL

Share on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0

We’ve been working diligently on a brand new audio engine for Corona which we will hope you will love. Our new engine is built from the ground-up, on top of the industry standard, OpenAL, which is designed for low-latency, high performance mixing, and a darling technology of the video game industry.

We have many features planned for our new audio engine, but here is a tiny taste of it.

In our prior sound engine, you could only play one “streaming” sample at a time. Our new engine no longer arbitrarily limits you to the number of streams you can play. So if you had large files like background music and speech you needed to play at the same time, you would have a hard time. We fixed that and more…

[cc lang=”lua”]mySpeech = audio.loadStream( ‘speechFile.wav’ )
backgroundMusic = audio.loadStream( ‘backgroundMusic.mp3’ )

audio.play( mySpeech )
audio.play( backgroundMusic, {fadein=5000} )[/cc]

We’ve also added a bunch of new parameters like “fadein” which tells Corona to slowly fade-in the background music over 5 seconds.

Share on Facebook0Share on Google+0Tweet about this on TwitterShare on LinkedIn0
ewing

This entry has 31 replies

  1. Garet says:

    Is this in the current build? Or a future feature. Cause a quick test of the audio.loadStream in the current corona game engine returns a bunch of errors.

  2. ewing says:

    This is a future feature which we hope to deliver soon.

  3. Garet says:

    Cool. Looking forward to it. Although I’m curious when you’ll ever need to be playing two audio files simultaneously. I suppose if you’re using multiple files to make dynamic tracks. Or you plan to have long alert sounds.

  4. ewing says:

    Actually, the need comes up quite often, particularly in games. You need one streaming track for background music, and another streaming track for speech (e.g. in-game characters talking, narrator, etc.).

  5. David Fox says:

    This is awesome! Exactly what I’m looking for. Hopefully you’ll also have the ability to pan each sound dynamically (maybe with the transition.to command?), as well as change levels (also with transition.to — we might want to bring up the background music at full, then when the voice starts, fade the background music to 50%).

  6. Freaking amazing. Can’t wait! I have an app idea that needs this. 🙂

  7. Omni_Coder says:

    Can the fade-in time be adjustable? If not, it’s okay, but it would be nice to have that fine-level of control.

  8. cmontesino says:

    Great. I just can’t wait! Releaseee

  9. Adam Bucketz says:

    Sounds spectacular… but can I tack on a feature request? Volume control for event sounds! Or at least a global volume. Hopefully this can make it into the new engine, we’d use it all the time. Thanks for your hard work!

  10. Wow this was on my request list I posted to my blog. Great decision to go with OpenAL!

    With all these “preview” posts, I really can’t wait until the next Game Edition release comes out.

  11. Garet says:

    Sorry to bug you guys again, but will this make it possible to play an ogg audio file? The one thing that suffers in my game is the file size (due to large audio files) while those same music loops go down to under a meg using the ogg compression.

  12. Chris says:

    Oh yeh.. perfect for what I have in mind.. Thanks alot.

    Chris

  13. That’s VERY interesting! Can’t wait for the next Corona version!

  14. ewing says:

    David: We do intend to include other fading features. Something related to panning is on our radar, but it will probably have to wait for a later iteration release.

  15. ewing says:

    Omni_Coder: Yes, the fade times are adjustable. From the above teaser, notice the number 5000. That means the fade in occurs over 5000 milliseconds (or 5 seconds).

  16. ewing says:

    Adam Bucketz: Yes, volume control is something we are focused on improving. The whole “event sound” vs. “non-event” sound is something we are trying to improve. Before, we wrapped two completely different audio APIs on iOS, and the “event sound” API on iOS is really only intended as an alert API. That’s why it had so many limitations.

    This new API tries to create ‘one audio API to play them all’. So instead of using two separate incompatible APIs, there is only one distinction you need to make in how you load the file. audio.loadStream() is what’s demonstrated here for dealing with large files like music and speech. audio.loadSound() is the counterpart API which will load a sound file completely into memory for maximum performance (best for short sound effects).

  17. ewing says:

    Garet: The answer about Ogg Vorbis is no and yes. For iOS devices, the answer is no. The reason is that Ogg Vorbis is a CPU intensive format to decode and may suck up battery life and performance on actual devices. We use Core Audio to decode highly compressed formats on iOS which potentially gives us access to a hardware decoder built into iOS devices. Core Audio supports hardware decoding of AAC/MP4, MP3, and ALAC, but not Ogg Vorbis. Also, the Ogg Vorbis is kind of a large dependency (large binary size) we don’t really want to impose on iOS devices.

    For Android, our intention is to support Ogg Vorbis because that is one of the official formats Android natively supports.

    And for the simulator, we intend to support Ogg Vorbis to make your development life a little easier, particularly when you are focusing on Android.

    I can’t say if Ogg Vorbis will make our first release, but it is important to us.

  18. Garet says:

    Ah I see. Did you just change your API? I swear I just checked there a little while ago and didn’t indicate that audio files supported MP3 on the iPhone. I was able to compress my audio files a ton, so it helps!

  19. jmp909 says:

    great…pan and pitch? 🙂

  20. Is there any release date yet? The sound features currently implemented are simply too limited to create decent games, so I am really, really looking forward to this release.

  21. carlos says:

    Yes. We are expecting to release openAl first week of December.

  22. Awesome! 🙂 🙂

  23. Neil says:

    How can I delay playing an audio clip using audio.play() ? I can see there’s a fade-in, but I need something to delay the start of the clip. Thanks, this is my first day using Corona!

  24. ewing says:

    Corona also provides a more general function called timer.performWithDelay(). You should use that to delay the start-playing a clip.

  25. Craig says:

    Does AL support any kind of audio streaming similar to the video method or will only support playback after it’s been downloaded?

  26. ewing says:

    Right now we only support playback from local files (after its downloaded). However, you may be able to use the existing video APIs to play audio files over a network connection.

  27. Jake says:

    Is there support for streaming remote audio files from a server?

  28. ewing says:

    This new API does not currently support remote audio files. However, you may be able to use the existing movie player APIs to stream audio.