Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-25-2004, 03:16 PM   #1
_marabout_
member
 
Join Date: Apr 2003
Location: France
Posts: 77
Default onSoundComplete doesn't fire immediately...

Hi,

I want to launch a sound as soon as an another one stops. Since my two sounds are two loops, two variants of the same musical theme, the second sound should start exactly at the end of the first one, otherwise you can ear a silence between the two.

I have tryed to do so using the onSoundComplete method, but it doesn't start -exactly- as the first sound stops, so I can ear a horrible (although brief) silence between the two loops.

Other people in this forum report using this method without mentionning this little delay problem, so is there something I ignore ?

Thanks for any help,
_marabout_
_marabout_ is offline   Reply With Quote
Old 06-25-2004, 03:26 PM   #2
oldnewbie
Banned by AS.org Staff
 
Join Date: Mar 2002
Posts: 10,533
Default

Are these mp3 loops?
And since they're loops, looping I suppose, when does the first one actually end? After so many loops?

Also mp3 loops rarely loop as seamlessly as .wav loops... Isn't there a brief silence when each loop, loops itself?
oldnewbie is offline   Reply With Quote
Old 06-25-2004, 03:53 PM   #3
_marabout_
member
 
Join Date: Apr 2003
Location: France
Posts: 77
Default

I started attaching mp3 from the library, but true, it looks like the mp3 files always start and end with a short silence (I tryed to edit and remove the sound but it always came back).

So I end up attaching to my sounds imported wavs (I tested them outside Flash and they loop together perfectly).


Quote:
And since they're loops, looping I suppose, when does the first one actually end? After so many loops?
What do you mean ?
_marabout_ is offline   Reply With Quote
Old 06-25-2004, 04:18 PM   #4
oldnewbie
Banned by AS.org Staff
 
Join Date: Mar 2002
Posts: 10,533
Default

I want to launch a sound as soon as an another one stops...

When does the other one stop?

You in fact want both sounds to be running in sync (looping) and to be able to switch from one to the other?
oldnewbie is offline   Reply With Quote
Old 06-25-2004, 04:54 PM   #5
_marabout_
member
 
Join Date: Apr 2003
Location: France
Posts: 77
Default

Quote:
Originally Posted by oldnewbie
I want to launch a sound as soon as an another one stops...

When does the other one stop?
... when it reaches its end! Sorry but I still don't understand the point of your question

Quote:
You in fact want both sounds to be running in sync (looping) and to be able to switch from one to the other?
Exactly.
_marabout_ is offline   Reply With Quote
Old 06-25-2004, 05:08 PM   #6
oldnewbie
Banned by AS.org Staff
 
Join Date: Mar 2002
Posts: 10,533
Default

Je ne comprends tout simplement pas la tienne!

Assuming both tracks are exactly the same, you should have two soundObjects, run them in sync, and just switch volume (0 or 100) from one to other, rather than stopping one and starting the other.
oldnewbie is offline   Reply With Quote
Old 06-26-2004, 06:49 AM   #7
_marabout_
member
 
Join Date: Apr 2003
Location: France
Posts: 77
Default

If I go further on you, how do you know the -exact- time when you should switch volumes from one to another ?

This is what I mean with "at the end of the first sound".

Wether you will want to stop the first sound or switch the volumes, you should do it at the exact end of the first sound.

Je ne comprends pas non plus ce que tu veux dire avec "Assuming both tracks are exactly the same".

My "tracks" are not exactly the same : the two sound objects carry two different wav file, and I want that the second one to fit exactly at the end of the first in order to play the two sounds in sequence.
_marabout_ is offline   Reply With Quote
Old 06-26-2004, 04:02 PM   #8
oldnewbie
Banned by AS.org Staff
 
Join Date: Mar 2002
Posts: 10,533
Default

Pourquoi alors ne pas combiner les deux sons ensemble dans un nouveau .wav (sans pause entre les deux), et ne pas utiliser un soundObject, mais simplement insérer ce nouveau son "event" sur le timeline, et le faire looper indéfiniment?
oldnewbie is offline   Reply With Quote
Old 06-27-2004, 08:28 AM   #9
_marabout_
member
 
Join Date: Apr 2003
Location: France
Posts: 77
Default

Je reprends en anglais si ça ne t'ennuie pas ... even though it may be a pain for some readers

The goal of all this is precisely not to create a file that will loop for ever following the same cycle. With 3 or 4 loops I want to build a piece of several minutes and be able to change the current loop whenever I want, with code only.

What I want to do is more or less the same as the solution in this thread :
http://www.actionscript.org/forums/s...d.php3?t=32921

BUT : onSoundComplete doesn't fire immediately, so when I switch from one loop to another, there is a short silence that ruins my plans.

I've found a workaround, using setInterval : when the loop starts, I start waiting with the setInterval method a little less than the loop duration :
ActionScript Code:
waitFirstLoop = setInterval(function() {      clearInterval(waitFirstLoop );      firstLoop.stop();      secondLoop.start(); }, firstLoop.duration-50);
This way, I'm sure that there won't be a short silence, since the second loop starts 50 milliseconds before the end of the first one. In most of the cases, you won't notice that the second sound starts too soon, firstly because 50 ms is short, secondly, because this lap seems to compensate a short delay before the secondLoop actually starts : in most of the cases, the secondLoop starts at the right moment.

But : this 50ms delay is not a garantuee, sometimes it's too long and you really ear that the secondLoop starts too soon. If you set a shorter delay, you may ear a silence.

So I am still wondering how did they make it work in the above thread with the onSoundComplete method, since to me it does the same : the second loop doesn't starts at the exact time the first one stops.
_marabout_ is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:23 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.