ofmlabs/aurora.js — pull request #22 by Chionsas (2013-03-10 18:07:40+00:00)
Title: When the resampler is in use, match sampleRate to deviceSampleRate

When the resampler is in use, @sampleRate does not match the @deviceSampleRate and
time calculations are off.

This is what happens:
* On file load (when using Player), an AudioDevice is being called with the file's sample rate.
* This in turn creates a WebKitAudioDevice with the file's sample rate.
It uses a resampler if the file's sample rate does not match the system's sample rate,
as Webkit does not allow setting a custom sample rate yet. So, @deviceSampleRate != @sampleRate.
* WebKitAudioDevice's getDeviceTime() method uses @deviceSampleRate to calculate the current time
(webkit.coffee line 59)
* AudioDevice's updateTime() method uses file's sample rate (@sampleRate; device.coffee line 41)
for time calculations. As @deviceSampleRate != @sampleRate, the calculations are off.
For 48000 != 441000 this is a few seconds (up to 10) for a typical song.

Setting @sampleRate = @deviceSampleRate when the resampler is in use fixes the problem.