WAV file playback issue

I am having a strange issue playing back some wav files. These files contain very short (~150ms) of ultrasonic data, and should be inaudible during playback. Based on some basic data gathering, it seems the problem may be JUCE related. When played back in JUCE apps (my current project and AudioPlaybackDemo) they produce a distorted buzzing sound. When played back through Audacity and VLC they seem to playback correctly, in that I do not hear any sound being played back. Any advice on debugging the issue would be appreciated. And JUCE devs (@ed95, @jules, @t0m), I have been given permission to email you one of these files if you would be willing to help with the issue.

1 Like

Does your audio hardware’s sample rate match with the file sample rate? If it doesn’t, are you resampling the audio file with a good enough resampler when playing it back?

edit : It appears the resampling done by JUCE’s AudioTransportSource is not of good enough quality to make loud ultrasonic frequencies output silence. (No anti-alias filtering etc done in that…?)

A test file I did plays back silent in Reaper, VLC and Foobar2000. (40khz sine tone in a 96khz file, played back with hardware set to 44.1khz sample rate.) The JUCE AudioPlaybackDemo outputs a clearly audible sound.

Thanks for looking into the issue. Seems like your tests produce the same results as mine.

To answer your question, no, the samplerate (48k) differs from the playback (44.1k), and I am using the JUCE ResamplingAudioSource to handle resampling. sooo… does anyone have a short list of resampling alternatives? I suppose another alternative is to supply multiple versions of the data for several sample rates.

You can use libresample (used by Audacity) which is a really good one. Check http://src.infinitewave.ca/ to see how it performs against a whole bunch of competitors. Used it flawlessly quite a lot of times.

Cockos’s WDL library has a resampler. (Which Reaper also uses.)

Some people are worried that it may be doing memory allocations during the audio processing, though. I discussed about that with the library author and he said that may be avoided by processing some dummy audio outside the audio thread after initializing the library and before doing the actual audio processing. I have not yet myself investigated the behavior further and whether the proposed fix by Justin would work.

Awesome, I will check that out. This usage just needs to be ‘real timish’, as it 's not a daw like environment

@Xenakios, I’ve integrated the WDL_Resampler, and since I don’t know anything about setting it up, my initial configuration of it produces buzzing as well. Since you seem to have some familiarity with it, is it possible you could help me understand how to determine the best settings for my usage? Currently this is what I have:

    wdlResampler.SetMode (true, 1, false, 0, 0);
    wdlResampler.SetFilterParms ();

I’d have to check but I think I’ve mostly used it with the defaults. (No calls to SetMode or SetFilterParams.)

edit : My largest project at the moment doesn’t fiddle with the WDL resampler mode or filter parameters. I haven’t checked how it performs with ultrasonic sounds, though. I will do that at some point, now that this issue was brought up…

@Xenakios, thanks again for your help. I was able to get things working the the WDL Resampler. Turns out we are using libsamplerate (http://www.mega-nerd.com/SRC/) in some other code, so I am trying that one out as well.