Sync Sound channel on iOs
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 10
- Joined: Mon Jan 14, 2013 11:11 am
Sync Sound channel on iOs
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
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
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Sync Sound channel on iOs
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
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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
- VIP Livecode Opensource Backer
- Posts: 10
- Joined: Mon Jan 14, 2013 11:11 am
Re: Sync Sound channel on iOs
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.
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.
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Mon Jul 31, 2006 1:39 am
- Location: New Zealand, Australia, Germany, Japan
- Contact:
Re: Sync Sound channel on iOs
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
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
-
- VIP Livecode Opensource Backer
- Posts: 10
- Joined: Mon Jan 14, 2013 11:11 am
Re: Sync Sound channel on iOs
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
i don't need an extrem sync but in all my test i have a pretty big delay to make it sound good
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Mon Jul 31, 2006 1:39 am
- Location: New Zealand, Australia, Germany, Japan
- Contact:
Re: Sync Sound channel on iOs
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
repeat with tChannel = kNumSoundChannels down to 1
mobileSetSoundChannelVolume tChannel, 0
mobilePlaySoundOnChannel (tSndPath & "S" & tChannel & kMobSoundType), tChannel, "now"
end repeat
HTH
cheers,
Alan
-
- VIP Livecode Opensource Backer
- Posts: 10
- Joined: Mon Jan 14, 2013 11:11 am
Re: Sync Sound channel on iOs
Hi Alan thanks a lot for your answer.
how long are your sound file ? mine around 4 minutes .
how long are your sound file ? mine around 4 minutes .
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Mon Jul 31, 2006 1:39 am
- Location: New Zealand, Australia, Germany, Japan
- Contact:
Re: Sync Sound channel on iOs
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!