Doubts on WASAPI exclusive mode

Greetings.

I’ve got an issue that is not really an issue so I call it a doubt.

In order to digitise some analogue audio I’ve set up an A/D converter with usb output into my Windows 10 PC. In the sound devices configuration the quality is set to 24 bit 96kHz and it is set to exclusive.
So now in Audacity when I select this recording device and select WASAPI I should be able to record with Audacity automatically locking onto the sampling rate value and bit depth of the input device. But this doesn’t seem to happen - I can change bit depth and sampling rate values in Audacity, hit record and it will proceed using these values, not the ones to which the input device is configured. This suggests to me that some resampling is still occuring.

If I can’t make Audacity pull and lock onto bit depth and sampling rate values from the input device how do I make sure the quality of the recording I get is exactly as I’ve set for the device?

Oh and I’m using Audacity 2.3.2.

Stop using Windows? There was a note a while back that Windows doesn’t support higher data rates. That’s probably worth a check.

Koz

WASAPI does support high res.
I would kindly ask for help from someone with actual knowledge on the topic. And with suggestions that don’t involve throwing all of my hardware out of the window.

No, Audacity does not lock onto the sample rate / bit depth of the input device.
An example of why that wouldn’t work:

Say that you have an audio track with a sample rate of 44100 Hz.
Audio tracks in Audacity support only one sample rate per track, so in this case, samples are placed at intervals of 1/44100th second.
Now say that you append the recording, but the recording device is set to 88200 Hz.
If Audacity locked onto the sample rate of the device, then Audacity would have to write 88200 samples per second to the track, but the track sample rate is 44100, so for each second of audio from the device, Audacity would have to write 2 seconds of audio (88200 samples @ 44100 samples per second).

The way that Audacity works, is that you set the “Project Rate” that you want to work with (bottom left corner of the main Audacity window), and Audacity requests audio data at that sample rate. It is then down to the sound system to supply audio data at the requested rate, or throw an error.

It is actually very unusual for a sound system to throw a meaningful error - if the sound system can’t provide audio data at the required rate, what usually happens is either:
The sound system does not send any data
or
The sound system sends data at another sample rate (causing the recording to be at the wrong speed).

If you wish to use WASAPI exclusive mode, then you should set Audacity’s Project Rate, and the device sample rate the same. If you also intend to append record any tracks, you should ensure that the tracks have the same sample rate as the project rate (Use Audacity’s Resample function if necessary).

Continuing from my previous post.
Re. Sample Format:

Keep Audacity at the default “32-bit float” format. If the sample format from the audio input device is lower than this, Audacity will losslessly convert the samples to 32-bit float on the fly.

set up an A/D converter with usb output into my Windows 10 PC.

So from the original posting, there’s no way to get bit-perfect transfers. If the converter bitrate and the computer bitrate are slightly different, the difference will show up as a performance speed change.

Koz

when I select this recording device and select WASAPI I should be able to record with Audacity automatically locking onto the sampling rate value and bit depth of the input device.

I’ve read the same thing… That Exclusive Mode doesn’t resample… But, I’ve never found a good reference/resource. I’m pretty sure that doesn’t apply to bit-depth because you wouldn’t be able to play a 16-bit file on an 24-bit soundcard/interface, etc.

As a practical matter it’s not a big deal. Re-sampling is normally transparent as long as you stay at-or-above “CD quality”. Most sound-quality issues are on the analog-side. (That’s assuming no glitches/dropouts or other digital defects.)

I believe that [u]ASIO[/u] will NOT resample, but you need ASIO hardware/drivers and an ASIO application. Audacity does not support ASIO.* (And again, this is sample-rate not bit-depth.)

There is something called ASIO4ALL that works along with the regular Windows drivers to make regular Windows hardware compatible with an ASIO application. But, it doesn’t work the other way around… ASIO4ALL requires an ASIO application so it won’t work with Audacity. I call it “Half-ASIO”… :wink: Real ASIO drivers come from the hardware manufacturer.



\

  • If you are a programmer there is an option of compiling Audacity with ASIO support, but licensing issues prevent Audacity from being distributed with it.

P.S.
“Googling around”, I found this on the [u]Kodi website[/u]:

WASAPI exclusive mode bypasses the mixing/resampling layers of [Direct Sound], and allows the application to negotiate directly with the audio driver what format it wishes to present the data in. This often involves some back-and-forth depending on the format specified and the device’s capabilities. Once a format is agreed upon, the application decides how it will present the data stream.

I think they are talking about playback but it doesn’t say you (or the operating system) can “force” or “lock-in” a predetermined sample rate.

So based on this (or at least my understanding of it) if my input device is set to 96kHz but in Audacity I set 48kHz and then record in WASAPI exclusive mode the recorded sound should be at half speed.
But that is not what happens. It records fine no matter what sampling rate I set in Audacity. Seems then Audacity is doing resampling on the fly no matter what so that the overall project can have a consistent sampling rate. This is in line what you’ve explained.

So now back to my doubt - I can set recording parameters in Audacity to be the exact same as my input device. Am I now to assume that since these parameters are the same on both sides Audacity will disable any resampling or conversion and record a bit perfect stream? Or is there still no way to be sure of that?

It “may” be half speed.
I’ve seen it happen both ways on different computers :confused:

Although Microsoft’s documentation says that WASAPI exclusive mode is low latency and bypasses mixing, I’ve not found any documentation that guarantees that setting a device to a specified sample rate guarantees that it will actually deliver an audio stream at that sample rate, even when an application requests a different sample rate.

Audacity can certainly do resampling on the fly during playback. I’m not 100% certain, but I’m pretty sure that Audacity does not / can’t do resampling on the fly during recording. Other than digging through some very complex code, I don’t know how to prove this, hence not being 100% certain. There is however another possible explanation:

When Audacity starts recording, it request an audio stream from the computer’s sound system, and the request includes the required sample rate. For example: “Give me 2 audio channels at 48000 samples per second”. Audacity does not care about the sample format (bits per sample) as it will automatically convert that on the fly (lossless when Audacity is set at the default 32-bit float).

Audacity is expecting the sound system to deliver the specified number of audio streams at the requested rate.

What I think is happening on your system (and some other, but not all computers), is that the Windows sound system gets the request: “2 channels at 48 kHz”, and responds with: “OK, switching (temporarily) to 48 kHz”. This makes sense for Exclusive mode as Exclusive mode guarantees that there will be no conflict with other applications requiring a different sample rate. I think this is what “should” happen with well behaved hardware and drivers.

I think what happens in some other systems, is that the hardware or drivers fail to honour the request / are unable to switch to the requested rate - this then produces a recording at the wrong speed.

I believe that in this case, Audacity will record without any resampling.

This is difficult to prove. You need a repeatable way to produce a stream of audio samples, where the stream is exactly the same each time. Playing a WAV file “should” do that, providing that the audio player is bit perfect (you could try “foobar 2000” and ensure that the “WASAPI output support” module is installed (I think this may still be an optional download, so check the docs: foobar2000:Components/WASAPI output support (foo_out_wasapi) - Hydrogenaudio Knowledgebase).

Assuming that you can get Audacity to record from foobar 2000, playing a WAV file, with WASAPI exclusive mode, where the sample rates match throughout (including the sample rate of the file), then you should be able to make multiple recordings of the same file, and each copy will be bit-for-bit identical with the original file.

Checking that two tracks are bit-for-bit identical is quite easy in Audacity. You need to line up the two tracks exactly, then invert one track, then mix the two tracks. If they are bit identical, then the result will be absolute silence. I’m guessing that you know how to do this, but ask if you need more detail.

I think it’ll be enough for me to make this assumption. These are not the lost tapes of The Beatles I’m trying to capture so I shouldn’t be concerned as much about top quality.

Thank you all for help, especially Steve for in-depth and precise answers.