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.

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

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

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

  4. 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!

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

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

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

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

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

  10. 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!

  11. 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!

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

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

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>