Posted on by

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.


Posted by . Thanks for reading...

31 Responses to “Preview: New Audio Engine Powered by OpenAL”

  1. Garet

    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.

    Reply
  2. Garet

    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.

    Reply
  3. ewing

    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.).

    Reply
  4. David Fox

    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%).

    Reply
  5. Omni_Coder

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

    Reply
  6. Adam Bucketz

    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!

    Reply
  7. Jonathan Beebe

    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.

    Reply
  8. Garet

    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.

    Reply
  9. ewing

    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.

    Reply
  10. ewing

    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).

    Reply
  11. ewing

    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).

    Reply
  12. ewing

    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.

    Reply
  13. Garet

    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!

    Reply
  14. x-pressive.com

    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.

    Reply
  15. Neil

    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!

    Reply
  16. ewing

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

    Reply
  17. Craig

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

    Reply
  18. ewing

    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.

    Reply
  19. ewing

    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.

    Reply

Leave a Reply

  • (Will Not Be Published)