emj365 / as3wavsound

Automatically exported from code.google.com/p/as3wavsound
Other
0 stars 0 forks source link

synchronizing #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1. I'm trying to synchronize two sounds - an MP3 song and a recorded microphone 
output. But when I play the recorded microphone output  through 
WavSoundChannel, it starts with a short delay of about a second(I assume this 
delay is different on different computers).

I tried to use the position of the soundchannel to catch the start of the real 
sound through the speakers, thinking that if the position is greater than 0, it 
should mean that the sound has started playing. But the position is greater 
than 0 and I don't hear the sound yet. I think it returns the right position 
but there is some kind of latency due to encoding. So I cannot use the position 
method to catch the start of the real sound through the speakers.

Is there a listener that I can use to get the actual sound start of the output, 
so i can play both sounds(the recorded output and the MP3) synchronized?

I'm using version 0.8 on Windows 7

Thanks

Kiril

Original issue reported on code.google.com by bouncing...@gmail.com on 23 Jun 2011 at 7:23

GoogleCodeExporter commented 9 years ago
Please excuse me if I've posted in the wrong section. I don't consider it a 
defect. I'm sure the delay cannot be avoided because of the encoding. Just 
looking for workaround.

Kiril

Original comment by bouncing...@gmail.com on 23 Jun 2011 at 7:25

GoogleCodeExporter commented 9 years ago
I'm not sure where a delay might come from, since the position directly 
reflects the samples within the .wav file. I would have to conduct some tests 
of my own.

I can tell you this though, the position is calculated as follows:

wav length in ms, LEN = number of samples / sample rate * 1000
current position, POS = current sample * LEN / number of samples

Original comment by b.bottema on 8 Jul 2011 at 8:39

GoogleCodeExporter commented 9 years ago
I have also noticed a delay that persists throughout the playback. I have a 
SoundComplete event that is supposed to reset some buttons in my app, but the 
buttons reset about a second before the playback finishes. I also notice that 
it cuts off the first second of the recording (because it started recording 
about 1 second after I start talking in my tests). Is there a workaround or a 
way to make the events match what comes out of the speakers?

Original comment by justin.s...@gmail.com on 9 Jan 2012 at 9:26

GoogleCodeExporter commented 9 years ago
Sorry. I should mention I am on a mac, using Flash CS5 and Snow Leopard 10.6.7.

Original comment by justin.s...@gmail.com on 9 Jan 2012 at 9:27

GoogleCodeExporter commented 9 years ago
I'm also on a mac using Flash Builder CS5.5 and building a Flex App. I'm having 
the exact same problem. The position starts to move roughly a second before the 
sound is audible and the Event.SOUND_COMPLETE gets fired the same amount of 
time too late.

By the way this problem appeared in version 0.6 and 0.8

A fix for this would be greatly appreciated. A workaround would be to start a 
timer each time and thus delay the actions one wants to synchronize ... but 
then again it would be good to know if we all really experience the same amount 
of delay or if it varies from computer to computer

Original comment by konstant...@gmail.com on 13 Jan 2012 at 12:55

GoogleCodeExporter commented 9 years ago
Sorry for the double email, I meant to say that the SOUND_COMPLETE gets fired 
too early, not too late.

Also ... I don't know if this is related to the problem but the 
WavSoundChannel.position progresses very jumpy. Traced at 30 FPS the position 
stays the same for about 5-6 frames, jumps forward (about 200ms) and stays 
again for 5-6 frames.

Original comment by konstant...@gmail.com on 13 Jan 2012 at 1:03

GoogleCodeExporter commented 9 years ago
I'm also having the issue of the SOUND_COMPLETE firing too early.

I think the problem is that 8192 bytes are buffered, *then* SOUND_COMPLETE gets 
fired, and only *then* is the audio actually played (WavSoundPlayer's 
onSamplesCallback function calls playingWavSound.buffer which buffers through 
8192 bytes in the array and, if "finished", fires the event. I think it might 
be better to have the event fire *after* the sound is played.

Original comment by jordanth...@gmail.com on 1 Jun 2012 at 9:34

GoogleCodeExporter commented 9 years ago
Looking over various documentation, it looks like the SoundChannel object is 
actually supposed to trigger the SOUND_COMPLETE so it should definitely be 
happening in the WavSoundChannel file... only question is how we set it up so 
that it triggers *after* the audio has actually played.

Original comment by jordanth...@gmail.com on 1 Jun 2012 at 9:47

GoogleCodeExporter commented 9 years ago
I'm open to any ideas.

Original comment by b.bottema on 14 Aug 2012 at 1:47

GoogleCodeExporter commented 9 years ago

Original comment by b.bottema on 29 Aug 2012 at 9:35

GoogleCodeExporter commented 9 years ago
i just posted a near identical issue as well, perhaps we can compare to see if 
we experience the same thing and get this nuance fixed!

Original comment by gunuse.t...@gmail.com on 5 Sep 2012 at 11:44