some great document

24
Blog / Lua / The secret/undocumented audio APIs in Corona SDK The secret/undocumented audio APIs in Corona SDK Posted on July 27, 2011 by ewing A few months ago, the developers from Yobonja (who made hits like Blast Monkeys) posted they discovered a ‘Hidden Audio Module’ in the Corona SDK. Since Daily Builds have been temporarily suspended until Aug 2, this seemed like a good time to talk about the secret/undocumented audio APIs in Corona to give you something to play with in the meantime. But before I go on, let me set up the disclaimer and ground rules. Disclaimer The features I talk about in this article are untested, unsupported, and we reserve the right to remove these APIs at any time. Use at your own risk. We do not want these features to be support issues for us, so do not send us bug reports with code using any of these features. We also do not want to see complaints and griping about these features. Intelligent discussion and constructive criticism are welcome provided that everything is clearly marked so we can easily filter things out when we need to focus on our official supported paths. Finally, do not make us regret publicly talking about these secret features. If this is a negative experience for us, we will never do anything like this again. Forum users should police each other. With that out of the way… Introduction to Corona audio, ALmixer, and OpenAL As many of you know, our new audio engine in Corona is powered by OpenAL. However, the API we provide in Corona does not look like OpenAL because we tried to make things easier to use. The API is actually inherited from ALmixer which is a LOOKING FOR PREMIUM MONETIZATION OPTIONS? BUY PRO … or test out Corona SDK Starter for free. STARTING BUILDING A… Game Business app Educational app The possibilities are endless! CATEGORIES Select Category Download Sign-in Start Building Products Pricing Resources Blog Easily create high-quality PDFs from your web pages - get a business license!

Upload: muhammad-naffah-amin

Post on 20-Nov-2015

27 views

Category:

Documents


1 download

DESCRIPTION

WOW what a document!

TRANSCRIPT

  • Blog / Lua / The secret/undocumented audio APIs in Corona SDK

    The secret/undocumented audio APIs in CoronaSDKPosted on July 27, 2011 by ewing

    A few months ago, the developers from Yobonja (who made hits like Blast Monkeys)posted they discovered a Hidden Audio Module in the Corona SDK. Since DailyBuilds have been temporarily suspended until Aug 2, this seemed like a good time totalk about the secret/undocumented audio APIs in Corona to give you something toplay with in the meantime. But before I go on, let me set up the disclaimer andground rules.

    Disclaimer

    The features I talk about in this article are untested, unsupported, and wereserve the right to remove these APIs at any time. Use at your own risk. We donot want these features to be support issues for us, so do not send us bug reportswith code using any of these features. We also do not want to see complaintsand griping about these features. Intelligent discussion and constructivecriticism are welcome provided that everything is clearly marked so we caneasily filter things out when we need to focus on our official supported paths.Finally, do not make us regret publicly talking about these secret features. If thisis a negative experience for us, we will never do anything like this again. Forumusers should police each other.

    With that out of the way

    Introduction to Corona audio, ALmixer, and OpenAL

    As many of you know, our new audio engine in Corona is powered by OpenAL.However, the API we provide in Corona does not look like OpenAL because we tried tomake things easier to use. The API is actually inherited from ALmixer which is a

    LOOKING FORPREMIUMMONETIZATIONOPTIONS?

    BUY PRO

    or test out CoronaSDK Starter for free.

    STARTING BUILDINGA

    GameBusiness appEducational app

    The possibilities areendless!

    CATEGORIES

    Select Category

    DownloadSign-inStart Building Products Pricing Resources Blog

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/https://developer.coronalabs.com/downloads/coronasdkhttps://developer.coronalabs.com/user/loginhttp://coronalabs.com/start-building/http://coronalabs.com/products/http://coronalabs.com/pricing/http://coronalabs.com/resources/http://coronalabs.com/blog/http://fusepowered.comhttp://coronalabs.com/blog/http://coronalabs.com/blog/topics/lua/http://coronalabs.com/blog/author/ewing/http://www.yobonja.com/http://blog.anscamobile.com/2011/07/blast-monkeys-top-3-million-downloads-still-1/http://www.yobonja.com/journal/2011/5/25/hidden-audio-module-in-corona-sdk.htmlhttp://blog.anscamobile.com/2011/07/halting-daily-builds-and-other-tidbits/http://coronalabs.com/storehttps://developer.coronalabs.com/downloads/corona-sdkhttp://coronalabs.com/i-want-to-build/games/http://coronalabs.com/i-want-to-build/business-apps/http://coronalabs.com/i-want-to-build/education-kid-apps/http://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • wrapper library around OpenAL which we use in Corona. The API of ALmixer itselfwas influenced by another library called SDL_mixer. Part of the design of ALmixerwas to make OpenAL easier to use while still being able to allow access to OpenALfeatures. Coronas first goal of adopting ALmixer was to pass on the ease of use ofusing OpenAL to our users. But we are also interested in passing on the power ofOpenALs features to our users as well. The secret audio APIs in Corona are our initialthoughts/groundwork in making this happen.

    So thus far in Corona, we have hidden the details of how OpenAL works and we letusers just think of it as a sound playing engine. But to really appreciate what OpenALcan do, how it works, and how the secret APIs apply to you, it is worth describing thehigh level design of OpenAL.

    The Design of OpenAL in a Nutshell

    OpenAL has three fundamental object types: buffers, sources, and the listener.

    Buffers are essentially your audio data. We hide all those details from you. In Corona,all you ever see is loadSound and loadStream which hides lots of complex code fromyou.

    Sources are things that emit sounds. You might think of them as your game objects,like a missile which has a rocket sound or an exploding ship that has a boom sound.

    The listener is essentially where your head & ears are in the game. Do not confusethis with the Corona notion of a listener which is a callback function. In OpenAL, thelistener is literally the object that is listening to (hearing) all sounds in yourapplication.

    In Corona, thus far, youve been using the notion of channels to control differentsimultaneously playing sounds. But channels as you know them in Corona dontreally exist in OpenAL; we made them up. In OpenAL, each sound emitting object is asource. A source has multiple properties like gain (volume), position, velocity, etc. Sothe secret formula in Corona is that, every channel maps to a different OpenALsource object. And conversely, every OpenAL source maps to a Corona channel.Understanding this will let you exploit a backdoor API we exposed in Corona toOpenAL directly. This is where the fun begins.

    Secret Audio APIs Part 1: luaal (Lua/OpenAL bindings)

    We wrote a partial direct interface between Lua and OpenAL. This will let you call anassortment of OpenAL functions directly in Lua. There are several families offunctions in OpenAL. The ones of interest to you are the functions that set properties

    CASE STUDY: PANDAMATH

    Learn how tinytapps built aportfolio of early educationapps using Corona SDK.

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/case-study/redbyes-creates-mobile-apps-for-early-childhood-education/http://coronalabs.com/case-study/redbyes-creates-mobile-apps-for-early-childhood-education/http://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • on sources and the listener.

    So for example, OpenAL has a function (in C) called alSourcef(ALuint source_id, ALenumparam, ALfloat value); You might use this to set the pitch on a source, e.g.

    alSourcef(source_id, AL_PITCH, 2.0);

    The value 2.0 shifts the pitch up by one octave for the source you designate.

    Another example is to set the position on a source with the alSource3f function:

    alSource3f(source_id, AL_POSITION, 5.0, 0.0, 0.0);

    This would set that sources position to the coordinate in your world.

    Similarly, there are functions that control the listener which is where your head/earsare in the world. Similar to sources, the listener also has its own properties such asposition, velocity, etc. Once you define properties on your sources and the listener,OpenAL automatically computes how the final audio output is supposed to soundand plays this output to your speakers.

    alListener3f(AL_POSITION, 0.0, 0.0, 0.0);

    This would set the listener (your ears in the game) position to in your world( also happens to be the OpenAL default). So if you play the above sound(source) at , the sound will come out of the right speaker because the sourceis to the right of the listener.

    With our Lua bindings, you could call the above like:

    al.Source(source_id, al.PITCH, 2.0)al.Source(source_id, al.POSITION, 5.0, 0.0, 0.0)al.Listener(al.POSITION, 0.0, 0.0, 0.0)

    See the bottom of this page for a list of more OpenAL functions and constants weexposed.

    Secret Audio APIs Part 2: Mapping between Corona channels and OpenAL sources

    But now the question is, How do I get a source id? Well, this is the other half of to thesecret audio APIs in Corona. Well, as I stated earlier, every Corona channel maps toan OpenAL source. So you just need a way of converting a channel to a source.

    Easily create high-quality PDFs from your web pages - get a business license!

    http://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • an OpenAL source. So you just need a way of converting a channel to a source.Well, we have two undocumented functions that do the mapping.

    local mysource = audio.getSourceFromChannel(1)local mychannel = audio.getChannelFromSource(mysource)

    This is good, but we have even something better. Unbeknownst to everybody, we didsomething clever and took advantage of Luas multiple return arguments feature. Soevery public audio function in Corona that returns a channel, also secretly returns asource id as a second parameter.

    local mychannel, mysource = audio.play( mySound )

    Similarly, every public audio function in Corona that takes a channel=} tableparameter, also takes an alternative source= table parameter:

    audio.setVolume(0.5, {source= mysource})

    With pride, I can say that this was all designed/planned in advance and not somehorrible kludge. And all of this (including luaal) has been in Corona since the veryfirst release of our new audio engine way back in Build 222!

    OpenAL is stateful

    One important ground rule to understand is that OpenAL is stateful, meaning, if youchange a property, it stays that way until you change it again later. Some of you havenoticed already in Corona that when you change a volume on a channel includingusing fade-in/fade-out, the volume is persistent until you change it again. This is thereason. So remember that when you change a property in OpenAL, it stays that wayuntil you change it again.

    The Long Term Goal

    We want to expose OpenAL features to Corona, but we want to find the correctbalance of ease of use and power. However, as some of you know, Google hascompletely dropped the ball on audio and most of our engineering resources havebeen diverted to improving the basics on Android instead of working on newfeatures. So in revealing these secret APIs, we are interested in seeing what youcome up with and how you use them. Intelligent feedback on the forums is welcome,but be aware we may be slow to respond if at all. And who knows, maybe, one of youwill write something so good that we will ask to incorporate directly in Corona.

    Easily create high-quality PDFs from your web pages - get a business license!

    http://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • Final thoughts:

    Please use with care. Again, none of this stuff is supported or even necessarilytested. We do reserve the right to change the APIs or remove them entirely, so dontcomplain if we break you. Please dont make us regret discussing these secret APIs.

    Additional Information:

    The OpenAL ProgrammersGuide: http://connect.creativelabs.com/openal/Documentation/OpenAL_Programmers_Guide.pdf This is the official online guide for OpenAL.

    Beginning iPhones Game Development: http://playcontrol.net/iphonegamebook Iwrote the worlds first and only book that attempts to cover OpenALcomprehensively. Chapter 11 covers all the OpenAL 3D features in detail.

    ALmixer: http://playcontrol.net/opensource/ALmixer/ open source

    luaal http://www.assembla.com/code/almixer_isolated/mercurial/nodes/Isolated/luaal/luaal.c?rev=c07dbd386ded62c8c832585c2c1d2e74eb44c34c open source

    ALexplorer: http://developer.anscamobile.com/code/alexplorer A Corona exampleprogram from our very own Alix, showing off some of these features

    Appendix A: Examples Summary

    -- We secretly returned two values for functions that return channelslocal mychannel, mysource = audio.play(mySound)

    -- 1.0 is normal, 2.0 is up one octave, 0.5 is down one octaveal.Source(mysource, al.PITCH, 2.0);

    -- moves the source position to left-of-center (x-axis) by 5 units-- number values are x-axis, y-axis, z-axisal.Source(mysource, al.POSITION, -5.0, 0.0, 0.0)

    -- Note that all the audio APIs support "source" as a key name where we've documented"channel" as a key name, e.g.audio.setVolume(0.5, {source=mysource})

    -- Also, we have two functions that get convert one to the othermysource = audio.getSourceFromChannel(1)mychannel = audio.getChannelFromSource(mysource)

    Easily create high-quality PDFs from your web pages - get a business license!

    http://connect.creativelabs.com/openal/Documentation/OpenAL_Programmers_Guide.pdfhttp://playcontrol.net/iphonegamebookhttp://playcontrol.net/opensource/ALmixer/http://www.assembla.com/code/almixer_isolated/mercurial/nodes/Isolated/luaal/luaal.c?rev=c07dbd386ded62c8c832585c2c1d2e74eb44c34chttp://developer.anscamobile.com/code/alexplorerhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • Appendix B: Non-comprehensive list of OpenAL functions and constants weexposed (via luaal)

    Here are some other functions we exposed:

    al.Enableal.Disableal.IsEnabledal.Getal.GetErroral.GetEnumValueal.Listeneral.GetListeneral.Sourceal.GetSourceal.DopplerFactoral.DopplerVelocityal.SpeedOfSoundal.DistanceModel

    Here is the mapping of some of the constants we exposed. Lua is on the left, C is onthe right. In Corona, you need to prefix al. to everything, e.g. PITCH is al.PITCH.

    { "NONE", AL_NONE },{ "FALSE", AL_FALSE },{ "TRUE", AL_TRUE },{ "SOURCE_RELATIVE", AL_SOURCE_RELATIVE },{ "CONE_INNER_ANGLE", AL_CONE_INNER_ANGLE },{ "CONE_OUTER_ANGLE", AL_CONE_OUTER_ANGLE },{ "PITCH", AL_PITCH },{ "POSITION", AL_POSITION },{ "DIRECTION", AL_DIRECTION },{ "VELOCITY", AL_VELOCITY },{ "ORIENTATION", AL_ORIENTATION },

    { "REFERENCE_DISTANCE", AL_REFERENCE_DISTANCE },{ "ROLLOFF_FACTOR", AL_ROLLOFF_FACTOR },{ "CONE_OUTER_GAIN", AL_CONE_OUTER_GAIN },{ "MAX_DISTANCE", AL_MAX_DISTANCE },

    Easily create high-quality PDFs from your web pages - get a business license!

    http://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • { "DOPPLER_FACTOR", AL_DOPPLER_FACTOR },{ "DOPPLER_VELOCITY", AL_DOPPLER_VELOCITY },{ "SPEED_OF_SOUND", AL_SPEED_OF_SOUND },{ "DISTANCE_MODEL", AL_DISTANCE_MODEL },{ "INVERSE_DISTANCE", AL_INVERSE_DISTANCE },{ "INVERSE_DISTANCE_CLAMPED", AL_INVERSE_DISTANCE_CLAMPED },{ "LINEAR_DISTANCE", AL_LINEAR_DISTANCE },{ "LINEAR_DISTANCE_CLAMPED", AL_LINEAR_DISTANCE_CLAMPED },{ "EXPONENT_DISTANCE", AL_EXPONENT_DISTANCE },{ "EXPONENT_DISTANCE_CLAMPED", AL_EXPONENT_DISTANCE_CLAMPED },

    For a comprehensive list and understanding of whats exposed, you can look at thesource code of luaal.c.

    This entry was posted in Lua, Tutorials, Tips and Demos and tagged ALmixer, luaal, OpenAL, secretAPIs. Bookmark the permalink.

    47 comments on Thesecret/undocumented audio APIs inCorona SDK

    Carlos Icaza says:July 27, 2011 at 9:48 am

    Gotta love the disclaimer Got it? Cool.

    Reply

    Chris says:

    Easily create high-quality PDFs from your web pages - get a business license!

    javascript:void(0);http://coronalabs.com/blog/topics/lua/http://coronalabs.com/blog/topics/tutorials-tips-demos/http://coronalabs.com/blog/tags/almixer/http://coronalabs.com/blog/tags/luaal/http://coronalabs.com/blog/tags/openal/http://coronalabs.com/blog/tags/secret-apis/http://developer.anscamobile.comhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=624#respondhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • July 27, 2011 at 10:38 am

    Very nice!So now I could actually make a panning effect and simulatehelicopter flights

    Reply

    Paul Osburn says:July 27, 2011 at 11:00 am

    Thanks for trusting us with this info.

    Reply

    Taka says:July 27, 2011 at 11:06 am

    Google has completely dropped the ball on audio what exactly doyou mean by this? I was just informed a few days ago that Android isterrible with precise audio because of latency issues within thedriver I never knew this since I have been workin my currentlyproject, which is a productivity app that does not use audio. Haventmoved onto game-making yet!Could you elaborate on what is known about this? Thanks!

    Reply

    ewing says:July 27, 2011 at 11:20 am

    Please note: I just added a new link to an example program by our

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=625#respondhttp://www.sparklefishapp.comhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=626#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=627#respondhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • very own Alix that shows off some of these hidden features.

    See ALexplorer at:http://developer.anscamobile.com/code/alexplorer

    Reply

    ewing says:July 27, 2011 at 11:27 am

    Androids audio problems are no secret. Here are some links I foundsearching with Google.

    http://code.google.com/p/android/issues/detail?id=3434http://kile.stravaganza.org/blog/post/android-audio-api-suckshttp://www.badlogicgames.com/wordpress/?p=1315http://groups.google.com/group/android-ndk/browse_thread/thread/29f88a99dc954c71http://mindtherobot.com/blog/555/android-audio-problems-hidden-limitations-and-opensl-es/http://music.columbia.edu/pipermail/portaudio/2010-December/011146.html

    Reply

    Taka says:July 27, 2011 at 11:51 am

    So Gingerbread (2.3) NDK r5 has 45ms latency? Thats terrible Itseems a reasonable latency is ~10ms? Whats the latestplan/update from Google on improving this?Its funny since just a few days ago, I had tried out about 4 or 5virtual piano apps on my sons Tegra2-based Android tablet and Iwas totally not impressed with the key response times compared tomy mother-in-laws iPad1 I guess this is why

    Easily create high-quality PDFs from your web pages - get a business license!

    http://developer.anscamobile.com/code/alexplorerhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=628#respondhttp://code.google.com/p/android/issues/detail?id=3434http://kile.stravaganza.org/blog/post/android-audio-api-suckshttp://www.badlogicgames.com/wordpress/?p=1315http://groups.google.com/group/android-ndk/browse_thread/thread/29f88a99dc954c71http://mindtherobot.com/blog/555/android-audio-problems-hidden-limitations-and-opensl-es/http://music.columbia.edu/pipermail/portaudio/2010-December/011146.htmlhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=629#respondhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • It sounds like theyve been concentrating on Graphics acceleration inthe NDK last I heard, Android does not even use GPU-accelerationfor the UI one of the reason why its UI is not as smooth as iOS. Itssuch a bummer

    Reply

    ewing says:July 27, 2011 at 12:01 pm

    As I have been told, Androids audio problems are system-wide andthere is no time table on when things will be fixed. Some problemsare in the kernel itself so these are probably not issues that areeasily fixed. In addition, because device manufacturers are free to doanything, it is also very hard to improve audio performance. Finally,their old audio API was terrible. Their new OpenSL ES based APIseems to be a big improvement, but it is still a work in progress anddoesnt get around the fundamental latency problems. OpenSL ESmay solve other problems we have with Android audio though andwould like to move to it, but it requires us to move beyond/dropAndroid 2.2. But getting people and manufacturers to upgrade theirAndroid version is another Google failing that is also no secret.

    Reply

    Paul Allan Harrington says:July 27, 2011 at 12:15 pm

    Thanks for sharing this.

    Im hopeful that this info will allow the Corona community to dig intothe audio API and provide intelligent discussion and constructivecriticism as well as the testing that will advance the Corona SDK.

    -Cheers!

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=630#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=631#respondhttp://pahgroup.comhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • Paul Allan HarringtonVisuals Work: { visualswork.com }Consulting Group: { pahgroup.com }

    Reply

    chris martone says:July 27, 2011 at 2:26 pm

    OMG thank you so much Carlos and the rest of the Corona staff! Ihave been waiting for something like this for so long and as ithappens im in the middle of creating a music app right now! I amgoing to start playing around with this ASAP. Again thank you, hope ican manage some cool uses. Maybe i can finally port my app I madewith GameSalad(yuck!) to Corona!

    Reply

    Alberto says:July 27, 2011 at 5:22 pm

    Great post, and to give some feedback I love this approach. Provide asimple to use interface that developers can quickly get going withand then provide additional functionality via access to the lower levellibrary for developers that want more control Win/Win!

    Reply

    chris martone says:July 27, 2011 at 7:17 pm

    Has anyone been able to get the al.VELOCITY to work? I would like to

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=632#respondhttp://www.apphappystudios.comhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=633#respondhttp://adventureworksstudios.comhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=634#respondhttp://www.apphappystudios.comhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • increase the speed at which a sound is played, is this the rightfeature to manipulate? If you have achieved what im trying to doplease post an example. Thanks so much! And thanks again to all youCorona folk, my birthday came early this year!

    Reply

    ewing says:July 27, 2011 at 7:45 pm

    OpenAL velocity is not what you think. Velocity represents the speedof a sound source (object) moving through space. Think of a missiletraveling across the screen. Velocity values work in conjunction withthe Doppler Effect to pitch shift the sound effect.

    To change the playback speed of a source, you can change theal.PITCH which happens to change the speed at which a sound isplayed back at. But be aware that OpenAL does not support pitchcorrected speed scaling.

    Reply

    chris martone says:July 28, 2011 at 2:42 pm

    thanks so much for the info, whats funny is I already implementedal.PITCH but failed to notice that it changed the playback speed.Much appreciated!

    Reply

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=635#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=636#respondhttp://www.apphappystudios.comhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=637#respondhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • popo says:August 2, 2011 at 9:50 am

    and I was so hoping these would allow advanced envelope/pitchediting

    Still cool though

    Reply

    Jason says:March 15, 2013 at 4:47 am

    I was thinking the exact same thing!

    Reply

    Adrian Harris Crowne says:August 2, 2011 at 10:06 am

    One of the things that makes Corona superior to almost any othermobile development environment is the access to up-to-the-minutechanges. Publishing this secret API is in the same spirit, and I hopethat it is a positive experience for Ansca. As a developer, it is great tobe able to see where things are going and try out new ideas even ifthey are just experiments. Thanks for trusting us with theinformation!

    Reply

    Philipp Lenssen says:August 2, 2011 at 10:09 am

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=638#respondhttp://www.jasonnoxon.comhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=16047#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=639#respondhttp://versuspad.comhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • Just to add: Thanks for disclosing this stuff here. I am really lookingforward to play around with more real-time audio creation features,especially for the use of creating music generation toys, or just moreinteresting dynamic music in a game.

    Reply

    bob says:December 9, 2011 at 12:25 am

    Hooray!

    Reply

    Alberto says:January 17, 2012 at 9:02 am

    Its not possible an echo effect with this API, isnt it?It seems only adding EFX extension to openAL (with effect objects)could be, and i figure out this is not possible in Corona yet.

    Reply

    Eric Wing says:January 17, 2012 at 11:26 am

    No EFX is currently not directly exposed. I am not opposed to the ideaof taking patches to luaal. However, EFX may not be not available onall platforms so a patch needs to take this into consideration. ForAndroid and Windows, we use OpenAL Soft. For iOS and Mac, we useApples implementation which promote their own effects (ASA).

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=640#respondhttp://www.gieson.comhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=641#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=642#respondhttp://playcontrol.net/http://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • Reply

    Alberto says:January 18, 2012 at 8:46 am

    Thanks for your reply, Eric!Sorry to tell you, I dont know what ASA is. Could you tell me, please?Is not possible an echo effect in a Corona app?

    Reply

    ewing says:January 18, 2012 at 12:41 pm

    ASA: Apple Spatial Audio ExtensionNote that ASA was only first introduced to iOS in 5.0.

    I dont think dynamic echo is currently possible through the soundAPIs (I dont think we exposed enough paths through luaal yet.) Ifyour echo requirements are static, you could simply bundle twoversions of the sound, one normal and one with echo alreadyapplied.

    Reply

    Alberto says:January 19, 2012 at 8:39 am

    Thanks ewing!

    Reply

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=643#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=644#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=645#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=646#respondhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • peter says:February 22, 2012 at 2:10 pm

    So could you post a corona example on this? How is this called toCorona?

    Reply

    ewing says:February 23, 2012 at 2:22 pm

    There is already an example. See ALexplorer mentioned at the end ofthe post.

    Reply

    John says:March 18, 2012 at 5:44 pm

    Are these undocumented apis working in the simulator in Windowsor on Android devices? Using this code:

    local ch, src = audio.play(playbackSoundHandle, {onComplete=onCompleteSound })al.Listener( al.POSITION, xl, yl, zl )al.Source( src, al.POSITION, x, y, z )

    The sound always plays at the same volume on both channels (L andR), no matter how I set the position.

    Reply

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=647#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=648#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=649#respondhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • ewing says:March 18, 2012 at 6:50 pm

    They should work, though its not horribly tested. But thecode paths for this are identical on all platforms. Makesure your audio is mono.

    Reply

    John says:March 18, 2012 at 9:46 pm

    Thanks for your quick reply. I hadnt considered making sure theaudio files were mono. However, Im still having no luck. I evenexplicitly set al.ROLLOFF_FACTOR to make sure it wasnt set to 0somehow. I also tried running ALExplorer with no luck (I had to installCorona Build 591 to get it to run). The sound would play, but equallythrough both channels no matter how I set the sliders. Here are mysystem details, if it might make a difference:

    Windows: Vista SP1Android: HTC Desire Android 2.2Corona: build 591 and 731

    Reply

    ewing says:March 18, 2012 at 10:23 pm

    Does pitch work for you? I have seen it work successfully on Android.

    Reply

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=650#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=651#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=652#respondhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • John says:March 19, 2012 at 12:53 am

    Yes. Pitch works fine.

    Reply

    Eric Wing says:March 20, 2012 at 11:01 am

    John, you should search/post on the forums. You might get more helpthere.

    Reply

    John says:March 20, 2012 at 8:37 pm

    Will do! Thanks again for your responses.

    Reply

    ewing says:March 25, 2012 at 12:19 pm

    Everybody: I also wanted to note that audio onComplete callbacksalso pass back event.source as a convenience.

    Reply

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=653#respondhttp://playcontrol.net/http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=654#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=655#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=656#respondhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • Alan says:July 30, 2012 at 6:33 am

    Im having the same problem that John had, in that no matter whatvalues I set for the position of the sound and listener I get the samesound through both the left and right channels. Ive tried stereo andmono sounds, but no luck.

    Has anyone ever actually got this to work in Corona? I had noproblems changing the pitch of a sound, so thought the positionwould be just as simple.

    Reply

    Eric Wing says:July 30, 2012 at 1:07 pm

    Check out OpenAL Explorer by Plaino LLC. This was written in Corona.http://itunes.apple.com/us/app/openal-explorer/id504578957?mt=8

    I thought he posted the source code GitHub.

    Reply

    Alan says:July 31, 2012 at 3:11 am

    Turns out that using mono files DID work, the problem was thevalues I was setting to reposition the sound. I assumed it would usegame world values, i.e. -screenWidth for left and +screenWidth forthe right. Changing the values to -1 for left and +1 for right fixed it.

    Reply

    Easily create high-quality PDFs from your web pages - get a business license!

    http://plantpot.cohttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=6064#respondhttp://itunes.apple.com/us/app/openal-explorer/id504578957?mt=8http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=6066#respondhttp://plantpot.cohttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=6078#respondhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • Alan says:July 31, 2012 at 3:35 am

    Also, I can now ONLY have exactly 50/50 left/right, 100% left or 100%right. Even a tiny adjustment (0.0001) to the right makes the soundentirely shift to the right channel. This is still better than I hadbefore, but I wouldve preferred an 80/20 split.

    Eric Wing: Thank you, I just downloaded the app and can see howchanging the values affects the sound but if I use the xyz values formy source and listener I dont get quite the same effect. Ive triedsearching for the source code for OpenAL Explorer but have had noluck.

    Reply

    mike says:August 7, 2012 at 11:55 am

    This bit-o-code shows how to pan and set pitch:

    http://developer.coronalabs.com/code/super-audio

    Reply

    Greg says:August 27, 2012 at 5:14 pm

    Is there a good example available that plays a continuous soundeffect of an engines increasing revs but that uses both:A) swapping between audio files andB) for minor changes on each audio file a pitch change

    In particular how to transparently handle item a) above. This is whentoo much use of pitch change makes it sound non realistic.

    Easily create high-quality PDFs from your web pages - get a business license!

    http://plantpot.cohttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=6079#respondhttp://www.gieson.comhttp://developer.coronalabs.com/code/super-audiohttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=6191#respondhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • Reply

    Eric Wing says:August 28, 2012 at 11:14 am

    Greg: I recommend you move this to the forums.I suggest for two files, you might try using two separate channels(one for each sound) and pause/resume each as necessary. You canalso manipulate each channel volume as necessary to maybe helpblending the two.

    Reply

    Don says:January 13, 2013 at 7:49 pm

    I tried to study the SuperAudio class, but have not yet made sense ofit. I dont need 3-d spacial effects, but just the ability to pan a sound,slowly, from left to right while it is playing. My higher math skillsarent what they were in grade eleven. Ive tried simply adjusting thelistener X-axis value, to no avail. I can make a sound come out on theleft, center or right, but not change it while it plays. Does anyonehave a simple example of panning left to right on the fly that workson IOS 6? Thanks in advance

    Reply

    monta says:February 7, 2013 at 9:41 am

    Can we get rid of background noises, using this api? If so how.

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=6358#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=6361#respondhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=10876#respondhttp://google.pthttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • thanks

    Reply

    kumar ks says:September 27, 2013 at 5:06 am

    Hi ,I am new to corona, I am developing an app , where i am using lot ofmp3 files for narration purpose.I am here using audio.loadStream() and audio.play() along withaudio.pause(). What actually happens is my app is running for 9 to 12times properly, after that it just stuck and i have to re launch the app. Whats the problem here , am i using the api properly , or anything ihave to modify . pls tell me as soon as possible .

    Reply

    Danijel says:January 10, 2014 at 2:35 am

    Hi, thanks for sharing.

    We at Little Endian have developed some cool sound effect SDKs, justlooking into possibilities of adding them to Corona. Not sure if gamedevs would like it in Corona? Any feedback most welcome

    Reply

    Terry says:February 19, 2014 at 9:59 am

    Danijel:

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=11814#respondhttp://www.coronalabs.com/blog/2012/07/03/properly-removing-objects-and-variables/http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=42251#respondhttp://www.littleendian.com/developershttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=67936#respondhttp://fatredcouch.comhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • I would love to see more audio effect functionality. Werebuilding childrens apps which would definitely benefitfrom functionality akin to OpenAL EFX or iOS ASA. Tell usmore about what youre thinking. ^_^

    Reply

    Wim Coosemans says:July 31, 2014 at 4:39 pm

    In case anyone else is wondering, here are good pitch values tomatch all notes on an octave.For example, if your sound is at a Do on pitch 1, then you can make itsound like a Sol by changing its pitch to 1.498.

    Do: 1Re: 1.122Mi: 1.259Fa: 1.335Sol: 1.498La: 1.682Si: 1.888Do: 2

    The numbers are not linear, between each semitone you have1.05946309436 pitch difference but there are 12 semitones in anoctave.

    Reply

    Leave a ReplyYour email address will not be published. Required fields are marked *

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=72117#respondhttp://kuub.smallworldbigsmile.comhttp://coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/?replytocom=254592#respondhttp://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com

  • Name *

    Email *

    Website

    Start typing...

    You may use these HTML tags and attributes:

    Post Comment

    Corona SDKEnterpriseCoronaCardsSupport & Training

    ProductsForumDocumentationCorona UniversityCorona Plugin Directory

    ResourcesStarter: Publish FreeBuy ProBuy EnterpriseBuy CoronaCards

    Get CoronaJobsContact

    About Social

    Copyright 2009-2014 Corona Labs. A Fuse Powered Company. All rights reserved.Privacy Policy Terms and Conditions

    Easily create high-quality PDFs from your web pages - get a business license!

    http://coronalabs.com/products/corona-sdk/http://coronalabs.com/products/corona-sdk/http://coronalabs.com/products/enterprise/http://coronacards.comhttp://coronalabs.com/products/support-training/http://coronalabs.com/resources/http://forums.coronalabs.comhttp://docs.coronalabs.comhttp://coronalabs.com/resources/tutorials/getting-started-with-corona/http://coronalabs.com/resources/plugins/http://coronalabs.com/pricinghttps://developer.coronalabs.com/downloads/coronasdkhttp://coronalabs.com/pricing/http://coronalabs.com/pricing/http://coronacards.com/pricinghttp://coronalabs.com/about/http://coronalabs.com/about/jobs/http://coronalabs.com/about/contact/https://twitter.com/coronalabshttps://www.facebook.com/CoronaLabshttps://www.youtube.com/user/CoronaLabshttp://fusepowered.comhttp://coronalabs.com/privacy-policy/http://coronalabs.com/terms-and-conditions/http://pdfmyurl.com/plans?ref=pdfhttp://pdfmyurl.com