Captured audio becomes garbled after several hours

37 posts / 0 new
Last post
lavoiedo
Offline
Last seen: 1 year 3 months ago
Joined: 18 Apr 2011 - 20:46
Captured audio becomes garbled after several hours

On windows using DirectSound. The captured audio is fine for approximately 5 hours. After that, it suddenly becomes garbled. We experience this behaviour on several Windows XP desktops, on various sound cards.

Once the the audio becomes garbled, our Juce application needs to be restarted. Audio is then fine for another 5 hours approx.

Any idea what could be causing this ?

jules
Offline
Last seen: 2 hours 19 min ago
Joined: 29 Apr 2013 - 18:37
Re: Captured audio becomes garbled after several hours

Well, it sounds like a number is overflowing somewhere, though I really can't imagine where that could be happening... There should be no problems in the audio i/o classes, which don't care how many samples have gone by. And the stuff that writes to the wav file uses 64-bit numbers for all its positions. When you say it becomes garbled, have you any way of knowing whether it's the incoming data that's broken, or the act of writing it to the file?

lavoiedo
Offline
Last seen: 1 year 3 months ago
Joined: 18 Apr 2011 - 20:46
Re: Captured audio becomes garbled after several hours

We write the audio to a .wav using libsndfile, not Juce. But I know for sure that the problem is not in libsndfile because of the way we noticed the problem : our application streams the audio to a speech recognizer through a socket and accuracy suddenly drops dramatically.

After we observed that accuracy drop, we noticed that the audio recorded to file was also bad. We then instrumented the application to record the audio upon entering audioDeviceIOCallback() : same thing, audio is garbled. We also code reviewed our implementation of audioDeviceIOCallback() to be sure that minimal work is done inside and that we don't block.

Bottomline : audio is corrupted before being delivered to the application.

jules
Offline
Last seen: 2 hours 19 min ago
Joined: 29 Apr 2013 - 18:37
Re: Captured audio becomes garbled after several hours

I can't see any counters in the DSound code that could be overflowing.. Does it recover after it becomes garbled, or does it just stay mixed up? (There's a chance with Dsound devices that the input and outputs could gradually drift apart and it'll need to re-sync itself, but that should just be a temporary glitch).

Does sound very odd though... I guess it could also be the actual DSound driver itself messing up, you might want to try with a different soundcard to rule that out?

lavoiedo
Offline
Last seen: 1 year 3 months ago
Joined: 18 Apr 2011 - 20:46
Re: Captured audio becomes garbled after several hours

When the audio becomes garbled, it never recovers. We've observed this behaviour on several desktops, with different sound cards.

jules
Offline
Last seen: 2 hours 19 min ago
Joined: 29 Apr 2013 - 18:37
Re: Captured audio becomes garbled after several hours

Really very odd. It does sound like a numeric overflow problem, but I really can't see any places in the code that look like a candidate.

Do you know if it always happens at exactly the same time, or maybe it's just something that's random but which is likely to happen within roughly 5 hours?

jrlanglois
Offline
Last seen: 1 day 17 hours ago
Joined: 12 Aug 2011 - 17:54
Re: Captured audio becomes garbled after several hours

Is this only a DirectSound problem, or does this same issue occur with other APIs like WASAPI (Vista and above only) and ASIO?

[Visual Studio 2012] [Xcode 5.1.1]
[latest JUCE tip] [C++ File Tools] [FriendlyBinaryBuilder]

lavoiedo
Offline
Last seen: 1 year 3 months ago
Joined: 18 Apr 2011 - 20:46
Re: Captured audio becomes garbled after several hours

The garbled audio occurs at any time of the day, roughly 5 hours after application start().

So far we have observed the problem with DirectSound, on Windows XP and Windows 7.

We have not yet tried to replicate the issue with Windows Audio.

jules
Offline
Last seen: 2 hours 19 min ago
Joined: 29 Apr 2013 - 18:37
Re: Captured audio becomes garbled after several hours

Well, I'm normally very good at spotting problems with things like this, and there really isn't anything dodgy about the DSound code - it simply doesn't use any counters that could overrun. Assuming that the underlying OS drivers continue working, it should all just keep chugging along forever.

...but I'm assuming you're using the latest juce code, right?

If I was debugging this in my own app, the first thing I'd try would be to remove all the other audio processing code, and do nothing in your audioCallback except to stream the audio to a file. That would rule out the possibility that an overflow somewhere else is overwriting memory and just screwing the program up more generally. (Or just run the juce demo app on the target machine, and leave its audio record demo running, to see if that has the same problem)

I'd also put a breakpoint or logging in DSoundAudioIODevice::resync, just to see if a loss of sync is happening.

And check that you've got juce assertions turned on, to catch anything strange in the Dsound code.

lavoiedo
Offline
Last seen: 1 year 3 months ago
Joined: 18 Apr 2011 - 20:46
Re: Captured audio becomes garbled after several hours

We'll try all these suggestions and let you know what we find out. Thanks.

jules
Offline
Last seen: 2 hours 19 min ago
Joined: 29 Apr 2013 - 18:37
Re: Captured audio becomes garbled after several hours

I've currently left the jucedemo audio page running, so will report back in about 5 hours whether it's still ok on my machine!

Other ideas:
- memory leaks? If your app is 32-bit it might be running out of memory.
- are you also playing output? If so, does that also break?

Pages