Error -9997 Invalid sample rate (not what it seems) [SOLVED]

Hi all, I am using audacity 2.3.3 on Windows 10, and using a Focusrite Scarlett 2i4 as my audio interface. I have an issue that is perplexing me heavily.

So the #1 reason I use audacity is so that I can record my computer’s internal audio. I’ve had it set up so that I can just launch the program and hit record, and it’s all gravy. I’ve also previously (up until today) been running 2.1.3 just because that version’s been working for me fine.

One day a few months ago though, I had the cursed “error opening sound device” error message that I know many people have gotten before. Somehow I fixed this issue back that first time and was recording my computer audio perfectly fine all over again.

However, today I mysteriously received the same error message, and I cannot for the life of me remember what the fix I used was. Trying many different solutions, I eventually went to download 2.3.3, thinking this latest version would fix my issue. Unfortunately it didn’t, but upon using this newest version, it did give me a NEW error message different from the first one.

This error message is “Error opening recording device. Error code: -9997 Invalid sample rate.”

(notice the message changed from “sound device” to “recording device”, I’m not sure if this is relevant at all or just arbitrary)

So first thing I did was the obvious, which was check the sample rate set in both Audacity and my Scarlett. They are both positively set to 44100 Hz, and just to double check, I also tried setting them both to 48000 Hz, to no avail. I can guarantee that the sample rates are matched up and are at standard rates for recording.

I also tried the other most popular solutions, especially making sure my microphone is enabled for all programs, and also making sure all other recording devices are disabled in the sound menu. Nothing has worked though, and I am incredibly perplexed as to why I’m getting this “invalid sample rate” message.

If anyone could help me, I’d be so, so grateful to you. Please let me know what other possible solutions I can try! Thank you

It is relevant in so far as the error occurred when Audacity attempted to open the “recording” device.

The relevant setting in Audacity is the “Project Rate” (lower left corner of the main Audacity window).

Where are you setting the sample rate for the Scarlett?

Thank you for the quick response. The project rate in the bottom left is indeed how I’m checking/adjusting my sample rate. Right now it’s still at 44100

I’m changing the Scarlett’s settings through the Focusrite settings window, which I can access in the bottom right of my desktop, where active computer processes can be found (next to the computers clock)

Because Audacity uses Windows audio drivers, the sample rate also needs to match in the Windows Sound control panel (both the recording and playback tabs).
Unfortunately, Microsoft keep changing how to get to the Windows Sound control panel. These instructions are believed to be up to date: Windows: accessing the Windows Sound controls - Audacity Manual

Thank you steve, unfortunately it seems like the settings are already as they should be in the windows sound control panel. Still not working though. I have attached a screenshot with all of the relevant windows open, showing their current settings.

It looks like ASIO has grabbed exclusive access to the Scarlett.

Have you tried rebooting the computer?
If the problem still occurs after a reboot, you may need to stop the Focusrite settings app from loading on boot (and then reboot again).

I have tried rebooting before, and just tried again, no luck.

I’m trying to disable the focusrite app from loading on startup, but the oddest thing is happening now. Each time I try to disable it in the “startup apps” menu, click away from that menu, and return to it to see if it’s applied, the setting returns to being ‘on’. All other startup apps are disabling just fine from this settings window, only the focusrite one is giving me this issue. I’ve also tried restarting my computer with my scarlett unplugged, and the focusrite app is still loading on launch.

I’m suspecting this is related to the initial issue, some sort of override happening within my system. So perhaps this is more of a focusrite/ASIO issue than an audacity issue? Does that sound right? Thanks again

Have you tried switching Exclusive Mode off in the Focusrite USB Properties?

Ok so, just turned exclusive mode turned off. It didn’t help disabling the app at first, but I found out I could more effectively disable that app through the task manager. Now it doesn’t run on startup anymore.

So I successfully restarted my computer without the program opening, exclusive mode still off, and despite it not being an active process right now, I’m still getting the same error message, for an invalid sample rate. Are there any other approaches we could take?

Which “host” setting is selected in the Device Toolbar (
The default is “MME”, which is usually the most compatible, but with an oddball problem like this it could be worth trying all options.

Sorry, I should have mentioned this part already. I’m using WASAPI, but that’s the only host that gives me the proper recording input to get my computer audio. The recording input I use under WASAPI is labelled “Focusrite USB (Focusrite USB Audio) (loopback)”

Under all the available hosts, there is another Focusrite input, but it is only recording the input from my instruments plugged in to the interface, e.g. my microphone. This input is labelled “Focusrite USB (Focusrite USB Audio)”, basically same title but without the (loopback) in it

I know I have said thank you a ton already, but you are really going above and beyond to help me here, and I just can’t express how much I appreciate this.

:smiley: Yes, it would have helped if you had mentioned that earlier.

Let me guess - you are trying to record an electric guitar, plugged into the Focusrite, but you want it with the software amp simulator effect.
How close am I?

Haha, not quite :stuck_out_tongue: As I mentioned earlier, I’m just trying to record my computer’s internal audio. I am a sampling musician and I find it better to record audio from online directly into Audacity, rather than download it at a potentially lower quality. Also being able to record the audio in realtime while I listen to it, and then export is incredibly convenient.

I’m able to record my instrument inputs just fine, that’s what that other focusrite input present on all the hosts can do. It’s only when I use this loopback input to record the internal audio, which I’ve used almost every day for years, that I’m getting this sudden error. To me, it doesn’t make any sense really.

Internal audio only - that’s good :slight_smile:

As far as I’m aware, WASAPI loopback recording occurs entirely within Windows, bypassing the sound card’s AD/DA chip. In other words, the sound quality of the recording should be just as good using the computer’s built-in sound card as using a high end external audio device. The built-in sound card has the added advantage that it is probably not competing with ASIO (which I think is what’s causing the problem with the Focusrite.)

See if you can get WASAPI loopback recording to work with the internal sound card. Hopefully that will be much easier.
If that does work, then there’s something else that I’d like you to try, because it’s an exciting and useful feature if it works on Windows (I mostly use Linux, which has a completely different sound system to Windows).

You’re logic may be flawed.

Have you heard of “Adaptive Multi-Rate Audio Streaming”? That’s a streaming server technology that allows the server to automatically adjust the bit-rate of streamed audio according to demand. You could start off recording a 256 kbps audio stream, but if a load more people start streaming it at the same time, then the server can reduce the bit-rate of all streams (including the one that you are recording) so that it can keep up with demand. With Adaptive Multi-Rate Audio Streaming the sound quality that you receive can change mid-way through a recording.

On the other hand, if you download a file, then you get the file as it is on the server.

Other benefits of downloading:

  • Usually much faster
  • Generally more convenient
  • Frequently better quality than streaming
  • Avoids problems with drop-outs caused by the network
  • If the download link is provided by the site, then you are less likely to be breaching copyright law
  • Avoids a number of potential security issues
  • Usually much easier

That’s good to know. I’ll be coming back to that if you’re willing to test something.

WASAPI is very fussy, and unfortunately WASAPI drivers are still sometimes buggy, even though WASAPI has been around for years.
If it was working easily with the same hardware, then the problem now may be due to an update, but with so many things possibly involved (Windows drivers, ASIO drivers, WASAPI, and Windows itself) it could be very difficult to work out exactly what caused it. Also, if it is caused by an update, that update may have been fixing something important (such as preventing the computer from being hacked).

Just brainstorming…
Have you tried enabling Stereo Mix? Is there a reason why it is disabled?
Now WASAPI is meant to be used for actual audio streaming through the computer. You talk both of “internal audio” and “audio from online”. What exactly do you mean by “internal audio” and by “audio from online”? If “audio from online” is streaming audio from a Web site (Web radio for example), how can you expect WASAPI to pick up online audio through a microphone (Focusrite)? The device used by WASAPI should be a device capable of outputting audio, not recording it, i.e. speakers or headset.
Or am I making wrong assumptions?
Note that the WASAPI Playback device needs to be plugged into the computer for WASAPI to work. If my speakers or my headset aren’t plugged into the computer, Audacity cannot record through WASAPI. I get “Error opening recording device. Error code -9996 invalid device."

I had my computer custom built actually, and since I knew I’d be using an external audio interface for sound processing, I never got an internal sound-card for it. So I’m afraid that this plan won’t work.

This is not necessarily the best option for what I choose to do though. Oftentimes, what I want to download does not have a simple way of downloading it at its best quality. Say I wanted to sample a 5 second audio clip from a movie. To download the entire movie, then chop it down to the specific 5 second clip I want, would be an incredibly arduous task, whereas in audacity I can record and export in under 10 seconds.

I can really promise you that this is the best choice for how I’d like to do things, and I’d rather solve this initial issue I came here for, than try to use other workarounds. If that’s fine with you.

So perhaps it is an issue with WASAPI itself then? Should I try to, as an experiment, find another program that can provide loopback recording, and see if it will work in there? I just uninstalled and reinstalled Audacity to no avail, and want to determine once and for all whether it’s an issue with audacity, with my Scarlett, or with WASAPI. I am going to also soon be trying a colleagues Scarlett 2i2 as another device to test this issue with. If neither of these plans work then I will place the blame on WASAPI, but if one of them do then I’d say it’s likely either Audacity or my Scarlett, respectively.

I believe disabling stereo mix was a result of me trying to troubleshoot this issue the first time it had come up a few months ago. If I remember correctly it may have actually helped, because the issue could have been the presence of multiple recording/playback devices, which is a common diagnosis I’ve found from googling this issue. I definitely have tried enabling stereo mix, making it the only enabled device (therefore the active one), and no luck.

By “internal audio” I mean all the actual sounds that my computer is making through the OS. Anything from a video I’m watching, an error message sound, a song I’m playing, etc.

By “audio from online” I simply mean what you guessed, audio coming from my web browser. This is just one of the various examples of “internal audio” that I am using.

I am not expecting WASAPI to pick up online audio through a microphone at all. Every time I’ve used this in the past, it has simply recorded what I just defined as “internal audio” . My Focusrite is both an Input AND Output device, and the audio I am trying to capture is specifically the output. The only thing it wouldn’t record was the audio coming from my DAW, which was fine with me because that wasn’t ever what I was trying to record.

So, just to be clear, you can completely disregard the parts I mentioned about the Focusrite input, and the presence of my mic, because that is not what I’m attempting to use or troubleshoot at all.

My speakers are plugged into my Focusrite perfectly fine, and hearing/recording audio is working perfectly fine in all other situations on my computer. I just unplugged and replugged all of it just to make sure, and nothing changed. Please note that the error you’ve received is not the one I’ve received, so I feel like this not relevant to my issue.

HALLELUJAH!!! I FOUND THE SOLUTION! All thanks to your help Steve!! Let me explain…

So I just spent the last hour trying and failing to find another way to record my computer’s audio, and ended up even crashing my computer a few times in the process. Not good!!

But then I though, well crap, there’s got to have been SOMEONE who had this same problem as me… so I did a very specific google search:

“audacity” “wasapi” “loopback” “9997”

I searched all of those phrases with quotes around each so I could find ONLY discussions revolving these particular details in my issue… and I found a forum post that YOU actually helped troubleshoot last year :laughing:

In this topic, you tell the person to go specifically “Go into the Windows Sounds control panel, and set the recording and playback settings for the Focusrite to “2 channels (stereo), 44100 Hz sample rate”.”

Now, you’re likely thinking “We already went over this part!” and yes!! we did!! And you can see in the screenshots I posted that it was definitely set this way before. But for SOME REASON… contrary to the settings that are shown in my previous screenshots… the settings for input AND output were NO LONGER set to 2 channels, 44100…

The INPUT was just now set to something else (forgetting as I type… d’oh) and the OUTPUT was set to a 6 CHANNEL, 44100 setting!! I changed back to 2 channel, and now that 6 channel option has MYSTERIOUSLY DISAPPEARED ALTOGETHER :open_mouth: :open_mouth:

Anyways, upon verifying that these settings were back in the right place… I hit record… and… IT WORKED!!

I apologize for the frequent caps, I am just sooo excited that this got solved. Thank you so so much for helping out!! I’m incredibly relieved to have fixed this and now I know where I will look again if it happens again, and I forget the solution again.

Also just for what it’s worth, I never changed these settings myself… it must have happened automatically as a glitch. I have no idea what the hell truly happened, and I wish I did, but I’m glad it’s fixed now!!

You are the best!! I would like you venmo you however much money a pint costs where you live, if you’d like one on me! You really went the extra mile to help me and I couldn’t be more grateful.

Indeed :smiley:

My guess would be that a Windows update “reset” it.
Whatever triggered it, glad you found and fixed the issue. I’ll close this topic as “Solved” to make it easier to find.

To those coming across this topic in the future:
The “-9997” error is device-specific, and the fix may be what solved it for this poster (changing the number of channels), or something else. We’re collecting possible fixes here: Error codes - Audacity Support