Page 1 of 1

Sync Sound channel on iOs

Posted: Tue Jun 11, 2013 9:42 am
by fnajmanBUSNPJd
Hello

Do you know if there is any way to sync few channel on mobile ios/android ? I am working on a music game and i need to play 6 channel in once . When i run 6x times the command " mobilePlaySoundOnChannel tPath, tChannelName, tType" with different music file there is a delay . any idea to solve this issue to start and mix all the channel in once ?

thanks a lot
fred

Re: Sync Sound channel on iOs

Posted: Sat Jun 15, 2013 5:37 am
by Simon
Hi Fred,
I'm thinking you should try mobilePausePlayingOnChannel immediately after mobilePlaySoundOnChannel. The dictionary notes that there could be a delay in fetching the file:
"This allows the sound to be prepared in advance of it being needed." from the "next" type.
Once you have all 6 sounds paused, try 6 mobileResumePlayingOnChannel (1 for each channel). At least that "...prepare in advance..." should be done by then.

Yes, there will still be a delay, but will it be noticeable?

Simon

Re: Sync Sound channel on iOs

Posted: Sat Jun 15, 2013 10:05 am
by fnajmanBUSNPJd
Hi Simon and thanks for your answer but unfortunatly i've still tried to do that and the delay still there it's doesn't work well.
i've made a try with native function of Phonegap and it's work well i don't understand why it's doesn't work under livecode.

Re: Sync Sound channel on iOs

Posted: Mon Jun 17, 2013 3:58 pm
by strongbow
What you need to do is "prepare" the channels + sounds for playing... i.e. preload them by playing them already once with channel volume 0 (perhaps on openstack or preOpenCard or somewhere else). Then the channels are open already and the sounds preloaded, so there should be no delay in playing them one after another (after you've reset the vol to your desired level).

Syncing them totally exactly is perhaps another story - if you need extremely fine-grained syncing then you might need another solution. What is the resolution you require?

HTH

Alan

Re: Sync Sound channel on iOs

Posted: Mon Jun 17, 2013 6:54 pm
by fnajmanBUSNPJd
Hi Alan thanks for answer
i don't need an extrem sync but in all my test i have a pretty big delay to make it sound good

Re: Sync Sound channel on iOs

Posted: Mon Jun 17, 2013 9:23 pm
by strongbow
Well, definitely pre-load the sounds on separate channels and then "play" them one after another at vol 0 - and they'll all play at the same time - or close enough to it. The key is pre-loading them. I use something like this on openstack to preload some sounds:

repeat with tChannel = kNumSoundChannels down to 1
mobileSetSoundChannelVolume tChannel, 0
mobilePlaySoundOnChannel (tSndPath & "S" & tChannel & kMobSoundType), tChannel, "now"
end repeat

HTH

cheers,
Alan

Re: Sync Sound channel on iOs

Posted: Wed Jun 19, 2013 10:23 am
by fnajmanBUSNPJd
Hi Alan thanks a lot for your answer.
how long are your sound file ? mine around 4 minutes .

Re: Sync Sound channel on iOs

Posted: Wed Jun 19, 2013 10:51 am
by strongbow
Nothing like as long as that. But investigate these options - I'm not sure that you actually have to play the whole sound - it may be enough to just make the call to play it so that it preloads it. Good luck!