Starting All Audio At The Same Moment

Hello,

I have more than 10 audio channels which should start playing at the same time.

How can I start all channels start playing at the same time?

Thanks.

Hi, again.

I see that there is a function in openAL, “allSourcePlayv”, which plays a set of sources.

Is there a way to use this function.

Thanks.

No idea?

All the available, undocumented OpenAL functions in Corona can be found here.  Anything additional would probably require someone creating a Gluon plug-in, or done directly with Objective-C and implemented through Corona Enterprise.

http://www.coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/

Hi, again.

I see that there is a function in openAL, “allSourcePlayv”, which plays a set of sources.

Is there a way to use this function.

Thanks.

No idea?

All the available, undocumented OpenAL functions in Corona can be found here.  Anything additional would probably require someone creating a Gluon plug-in, or done directly with Objective-C and implemented through Corona Enterprise.

http://www.coronalabs.com/blog/2011/07/27/the-secretundocumented-audio-apis-in-corona-sdk/

Hi, i’m developing a drum machine and i face your same problem. if you do audio.play(sound1) audio.play(sound2) etc… they will start with an unimportant delay. Try it!

Hi @ilparola,

I assume you’ve loaded all of these sounds in advance and stored them somewhere easily accessible to Lua and the audio system? If so, how about “playing” them in advance, pausing/rewinding them, then in a quick loop unpause them all?

Brent

Enlgish is not my language and it was a mistake writing “i face your problem” i meant that i resolved the problem.

here’s my “setsound” function (there is something that doesn’t fit in the topic)

function setSounds(event)     self=event.target     if myList~=nil then         if myList.isVisible==true then             myList.isVisible=false         end     end     local doc\_path = system.pathForFile( nil, system.ResourceDirectory )     local doc\_path= doc\_path.."/kits/"..dataKits[self.id]     local rel\_path = "kits/"..dataKits[self.id]     kitText.text=dataKits[self.id]     kitText:setReferencePoint(display.CenterLeftReferencePoint)     kitText.x=1260      local i=1     for file in lfs.dir(doc\_path) do            if file ~= "." and file ~= ".." then             if string.find(file,".mp3") then                 sounds[i]=audio.loadSound( rel\_path.."/"..i..".mp3" )                 print (rel\_path.."/"..i..".mp3 -\> Caricato")                 i=i+1             else                 sounds[i]=audio.loadSound( rel\_path.."/"..i..".aif" )                 print (rel\_path.."/"..i..".aif -\> Caricato")                 i=i+1             end            end         end     for a=1,10 do         for b=1,16 do              pins[a][b].sound=sounds[a]         end     end end  

and here’s my playback function:

function playBack(colonna)     local step=colonna%16+1     for a=1,10 do         --print (step)         if pins[a][step].isOn==1 then             leds[a].alpha=1             pins[a][step]:playClip("pulse")             canale=audio.findFreeChannel()             audio.setVolume(pins[a].volume,{channel=canale})             if pins[a].isMute==1 then                 audio.setVolume(0,{channel=canale})             end             local mysource = audio.getSourceFromChannel(canale)             al.Source(mysource, al.PITCH, pins[a].pitch)             audio.play(pins[a][step].sound,{channel=canale})             transition.to(graphEq[a], {time=100, yScale=pins[a].volume\*20,onComplete=eqGoDown})         end         indicatore.x=pins[1][step].x         transition.to( leds[a], { time=250, alpha=0.2} )     end end  

Hi,

I do as you say, audio.play(music1), audio.play(music2),…

But I want to start for eg. 10 music. If I start these one after other, the unimportant delay is:

10 * unimportant delay, and I think it may cause a little problem.

Btw, all are looping about every 10 seconds.

Anyway, I think it will stay like this I think.

Hi, i’m developing a drum machine and i face your same problem. if you do audio.play(sound1) audio.play(sound2) etc… they will start with an unimportant delay. Try it!

Hi @ilparola,

I assume you’ve loaded all of these sounds in advance and stored them somewhere easily accessible to Lua and the audio system? If so, how about “playing” them in advance, pausing/rewinding them, then in a quick loop unpause them all?

Brent

Enlgish is not my language and it was a mistake writing “i face your problem” i meant that i resolved the problem.

here’s my “setsound” function (there is something that doesn’t fit in the topic)

function setSounds(event)     self=event.target     if myList~=nil then         if myList.isVisible==true then             myList.isVisible=false         end     end     local doc\_path = system.pathForFile( nil, system.ResourceDirectory )     local doc\_path= doc\_path.."/kits/"..dataKits[self.id]     local rel\_path = "kits/"..dataKits[self.id]     kitText.text=dataKits[self.id]     kitText:setReferencePoint(display.CenterLeftReferencePoint)     kitText.x=1260      local i=1     for file in lfs.dir(doc\_path) do            if file ~= "." and file ~= ".." then             if string.find(file,".mp3") then                 sounds[i]=audio.loadSound( rel\_path.."/"..i..".mp3" )                 print (rel\_path.."/"..i..".mp3 -\> Caricato")                 i=i+1             else                 sounds[i]=audio.loadSound( rel\_path.."/"..i..".aif" )                 print (rel\_path.."/"..i..".aif -\> Caricato")                 i=i+1             end            end         end     for a=1,10 do         for b=1,16 do              pins[a][b].sound=sounds[a]         end     end end  

and here’s my playback function:

function playBack(colonna)     local step=colonna%16+1     for a=1,10 do         --print (step)         if pins[a][step].isOn==1 then             leds[a].alpha=1             pins[a][step]:playClip("pulse")             canale=audio.findFreeChannel()             audio.setVolume(pins[a].volume,{channel=canale})             if pins[a].isMute==1 then                 audio.setVolume(0,{channel=canale})             end             local mysource = audio.getSourceFromChannel(canale)             al.Source(mysource, al.PITCH, pins[a].pitch)             audio.play(pins[a][step].sound,{channel=canale})             transition.to(graphEq[a], {time=100, yScale=pins[a].volume\*20,onComplete=eqGoDown})         end         indicatore.x=pins[1][step].x         transition.to( leds[a], { time=250, alpha=0.2} )     end end  

Hi,

I do as you say, audio.play(music1), audio.play(music2),…

But I want to start for eg. 10 music. If I start these one after other, the unimportant delay is:

10 * unimportant delay, and I think it may cause a little problem.

Btw, all are looping about every 10 seconds.

Anyway, I think it will stay like this I think.