The apps weak spots on all devices seem to be when 2 sounds seem to play on top of each other on the same track. For the last 16 hours I've been trying to find ways to make my audio code a little more android friendly, so I post here hoping that some of you more experienced livecoders could nudge me in the right direction.
The first app uses some 120 .mp3 sounds throughout, so I made a function for simplicitys sake. Sometimes sounds are played mid- animation loops etc. but nothing seems intensive or too tight for messages. Is a function the best way to accomplish this? My other thought after reading various threads was to add a little breathing room between sounds played for os/livecode communication hence the "wait for 0 millisecs with messages". Any thoughts for increased stability?
In a button:
Code: Select all
do playSound(dolphin)
do playSound(ocean, channel3, looping)
--> ? or should it be ?
return playSound(ocean, channel3, looping)
Code: Select all
function playSound whatSound, whatChannel, whatType
if whatChannel is empty then
put "channel1" into whatChannel
end if
if whatType is empty then
if mobileSoundChannelStatus(whatChannel) is "playing" then
mobileStopPlayingOnChannel whatChannel
wait 0 millisecs with messages
end if
put "now" into whatType
end if
if the environment is not "mobile" then
put "audio/"&whatsound&".wav" into tSndpath
if whattype is "looping" then
play tSndPath looping
else
play tSndPath
end if
else
put specialFolderPath("engine")&"/maudio/"&whatsound&".mp3" into tSndpath
mobilePlaySoundOnChannel tSndpath, whatChannel, whatType
end if
return empty
end playsound