W3C home > Mailing lists > Public > public-audio@w3.org > July to September 2013

Sync lost when seeking

From: Eduardo Bouças <mail@eduardoboucas.com>
Date: Fri, 9 Aug 2013 21:59:01 +0100
Message-ID: <CAGTW=VHPb4RSMDJVGFLYb=KUsL-kq6Va2c3SiPSRZep8P1hWiQ@mail.gmail.com>
To: public-audio@w3.org
Hi everyone,

As a final project for my masters degree in Web Development, I'm developing
a collaborative audio recording platform for musicians (something like a
cloud DAW married with GitHub).
In a nutshell, a session (song) is made of a series of audio tracks,
encoded in AAC and played through HTML5 <audio> elements. Each track is
connected to the Web Audio API through a MediaElementAudioSourceNode and
routed through a series of nodes (gain and pan, at the moment) until the
destination. So far so good. I am able to play them in sync, pause, stop
and seek with no problems at all, and successfully implemented the usual
mute, solo functionalities of the common DAW, as well as waveform
visualization and navigation. This is the playback part.

As for the recording part, I connected the output from getUserMedia() to
a MediaStreamAudioSourceNode, which is then routed to a ScriptProcessorNode
that writes the recorded buffer to an array, using a web worker — I had to
come up with a sort of delay compensation mechanism, because I was getting
a slight latency when playing back the recorded audio.
When the recording process ends, the recorded buffer is written into a PCM
wave file and uploaded to the server, but at the same time hooked up to a
<audio> element for immediate playback (otherwise I would have to wait for
the wav file to be uploaded to the server to be available). Here is the
problem: I can play the recorded track in perfect sync with the previous
ones, but I can't seek properly. If I change the currentTime property of
the newly recorded track, it becomes messy and terribly out of sync.

Does anyone have any idea of what may be causing this? Is there any other
useful information I can provide?

Thank you in advance and congratulations for your wonderful effort of
bringing audio to the web.

--
Eduardo Bouças
Received on Sunday, 11 August 2013 20:56:28 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:03:23 UTC