Page 2 of 2

Re: Error -9997 Invalid sample rate (not what it seems)

Posted: Mon Mar 02, 2020 9:50 pm
by PrettyCantRap
steve wrote:
Mon Mar 02, 2020 9:39 pm
Which "host" setting is selected in the Device Toolbar (https://manual.audacityteam.org/man/device_toolbar.html)
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.

Re: Error -9997 Invalid sample rate (not what it seems)

Posted: Mon Mar 02, 2020 10:15 pm
by steve
PrettyCantRap wrote:
Mon Mar 02, 2020 9:50 pm
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)"
:D 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?

Re: Error -9997 Invalid sample rate (not what it seems)

Posted: Tue Mar 03, 2020 2:31 am
by PrettyCantRap
steve wrote:
Mon Mar 02, 2020 10:15 pm
:D 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 :P 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.

Re: Error -9997 Invalid sample rate (not what it seems)

Posted: Tue Mar 03, 2020 10:30 am
by steve
PrettyCantRap wrote:
Tue Mar 03, 2020 2:31 am
I’m just trying to record my computer’s internal audio.
Internal audio only - that's good :)

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).

PrettyCantRap wrote:
Tue Mar 03, 2020 2:31 am
I find it better to record audio from online directly into Audacity, rather than download it at a potentially lower quality.
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
PrettyCantRap wrote:
Tue Mar 03, 2020 2:31 am
I’m able to record my instrument inputs just fine, that’s what that other focusrite input present on all the hosts can do.
That's good to know. I'll be coming back to that if you're willing to test something.
PrettyCantRap wrote:
Tue Mar 03, 2020 2:31 am
To me, it doesn’t make any sense really.
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).

Re: Error -9997 Invalid sample rate (not what it seems)

Posted: Tue Mar 03, 2020 1:20 pm
by Robert2
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."

Re: Error -9997 Invalid sample rate (not what it seems)

Posted: Wed Mar 04, 2020 4:01 pm
by PrettyCantRap
steve wrote:
Tue Mar 03, 2020 10:30 am
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).
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.
steve wrote:
Tue Mar 03, 2020 10:30 am
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.
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.
steve wrote:
Tue Mar 03, 2020 10:30 am
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).
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.

Re: Error -9997 Invalid sample rate (not what it seems)

Posted: Wed Mar 04, 2020 4:20 pm
by PrettyCantRap
Robert2 wrote:
Tue Mar 03, 2020 1:20 pm
Just brainstorming…
Have you tried enabling Stereo Mix? Is there a reason why it is disabled?
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.
Robert2 wrote:
Tue Mar 03, 2020 1:20 pm
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?
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.
Robert2 wrote:
Tue Mar 03, 2020 1:20 pm
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."
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.

Re: Error -9997 Invalid sample rate (not what it seems)

Posted: Wed Mar 04, 2020 5:45 pm
by PrettyCantRap
steve wrote:
Tue Mar 03, 2020 10:30 am
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).
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 :lol:

viewtopic.php?f=46&t=105890&start=10

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 :shock: :shock:

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.

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

Posted: Wed Mar 04, 2020 6:25 pm
by steve
PrettyCantRap wrote:
Wed Mar 04, 2020 5:45 pm
HALLELUJAH!!!
Indeed :D
PrettyCantRap wrote:
Wed Mar 04, 2020 5:45 pm
Also just for what it's worth, I never changed these settings myself... it must have happened automatically as a glitch.
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.