Sound Keeper v1.3.3 [2023/08/19]

Prevents SPDIF/HDMI/Bluetooth digital audio playback devices from sleeping. Uses WASAPI, requires Windows 7+. It doesn't have GUI and starts to do its job right after the program is started. To make it autorun, copy the soundkeeper.exe into the startup directory that you can access by pressing Win+R and entering shell:startup. To close the program, run the soundkeeper.exe kill command or just kill its process.

Download: soundkeeper.7z (23KB). Source code →

The archive contains two versions:

  • SoundKeeper32.exe is for x86-32 versions of Windows.
  • SoundKeeper64.exe is for x86-64 versions of Windows. The most popular variant.
  • I could make a native ARM64 version, but I need somebody with such machine for testing it before releasing.

There is also a debug version that outputs all debug logs into a console window. Please show the logs when you report issues.

Features

  • Sound Keeper is fully automatic and doesn't require any user interaction.
  • Supports keeping on multiple sound outputs (e.g. an SPDIF and an HDMI).
  • Detects new sound outputs on the fly (e.g. when you connected a TV via HDMI).
  • Supports various stream types that should help in all possible cases.

Settings

Default behavior can be changed by changing file name of the Sound Keeper executable (just add desired settings to the Sound Keeper file name) or by passing them as command line arguments. All settings are case insensitive.

Primary audio output is used by default. If current primary audio output has changed, the Sound Keeper detects this and switches to the new output automatically. If you want to run Sound Keeper on all enabled audio outputs, just add All to executable file name to enable Sound Keeper on all outputs.

All supported audio output type modes:

  • Primary keeps on primary audio output only. It is used by default.
  • All keeps on all enabled audio outputs.
  • Digital keeps on all enabled SPDIF and HDMI audio outputs (like it was in Sound Keeper v1.0).
  • Analog keeps on all enabled audio outputs except SPDIF and HDMI.

Inaudible stream of zeroes with infrequent smallest possible non-zero samples (fluctuations) is used by default. Add Zero to executable file name to use stream of zeroes only.

All supported stream types:

  • OpenOnly opens audio output, but doesn't stream anything. Sometimes it helps if it's a driver only issue.
  • Zero plays stream of zeroes. It may be not enough for some hardware.
  • Fluctuate plays stream of zeroes with the smallest non-zero samples once in a second. Used by default.
  • Sine plays 1Hz sine wave at 1% volume. The frequency and amplitude can be changed. Useful for analog outputs.
  • White, Brown, or Pink play named noise, with the same parameters as the sine (except frequency).

If the default inaudible stream doesn't help, try the new Sine stream type. It generates a sine wave, and can be customized. There are two parameters: F (frequency) and A (amplitude). The value goes right after the parameter character. For example, add SineF10A5 to executable file name to generate 10Hz sine wave with 5% amplitude. Low frequencies (below 20Hz) and high frequencies (above 20000Hz) with low amplitude (up to 10%) are inaudible.

Stream parameters:

  • F is frequency. Default: 1Hz for Sine and 50Hz for Fluctuate. Applicable for: Fluctuate, Sine.
  • A is amplitude (i.e. volume). Default: 1%. If you want to use inaudible noise, set it to 0.1%. Applicable for: Sine, Noise.
  • L is length of sound (in seconds). Default: infinite.
  • W is waiting time between sounds if L is set. Use to enable periodic sound.
  • T is transition or fading time. Default: 0.1 second. Applicable for: Sine, Noise.

Examples:

  • SoundKeeperAll.exe generates default inaudible stream on all enabled audio outputs.
  • SoundKeeperZero.exe generates zero stream on primary audio output.
  • SoundKeeperAllZero.exe generates zero amplitude stream on all enabled audio outputs.
  • SoundKeeperSineF10A5.exe generates 10Hz sine wave with 5% amplitude on primary audio output. It is inaudible.
  • SoundKeeperSineF1000A100.exe generates 1000Hz sine wave with 100% amplitude. It is audible! Use it for testing.
  • SoundKeeper.exe sine -f 1000 -a 100 is command line version of the previous example.
  • SoundKeeper.exe brown -a 0.1 generates brown noise with 0.1% amplitude.

What's new in v1.3.3

  • Fixed arguments parsing bug: All or Analog after specifying stream type led to amplitude set to 0.

What's new in v1.3.2

  • Fluctuate treats 32-bit PCM output format as 24-bit since WASAPI reports 24-bit as 32-bit for some reason.
  • Fluctuate generates 50 fluctuations per second by default. It helps in many more cases.
  • Sound Keeper doesn't exit when it is muted.

What's new in v1.3.1

  • A potential deadlock when audio devices are being added or removed has been fixed.
  • Fluctuate treats non-PCM output formats (like Dolby Atmos) as 24-bit instead of 16-bit.
  • Frequency parameter F is limited by half of current sample rate to avoid generation of unexpected noise.
  • More detailed logs in debug build. Debug output is flushed immediately, so it can be redirected to a file.

What's new in v1.3.0

  • Fluctuate is 1 fluctuation per second by default. Frequency can be changed using the F parameter.
  • Periodic playing of a sound (parameters L and W) with optional fading (parameter T).
  • New White, Brown, and Pink noise signal types.
  • Self kill command is added. Run soundkeeper kill to stop running Sound Keeper instance.
  • Analog switch was added. It works as the opposite of Digital.
  • Ignores remote desktop audio device (this feature can be disabled using the Remote switch).
  • New OpenOnly mode that just opens audio output, but doesn't stream anything.
  • New NoSleep switch which disables PC sleep detection (Windows 7-10).
  • Work as a dummy when no suitable devices found.
  • Sound Keeper shouldn't prevent PC from automatic going into sleep mode on Windows 10.
  • The program is not confused anymore when PC auto sleep is disabled on Windows 10.
  • The workaround that allowed PC to auto sleep had to be disabled on Windows 11.

Sound Keeper vs. SPDIF Keep Alive vs. SPDIF-KA

Sound Keeper v1.3 SPDIF Keep Alive v1.2 SPDIF-KA v1.4
Fully automatic: Yes No No
Multiple outputs: Yes No No
Stream types: 7 2 2
Periodicity: Yes No No
GUI: No Yes Yes
Requires .NET: No Yes Yes
Executable size: 20KB 668KB 163KB
CPU usage (on Intel Core i5 4460): 0.004% 0.06% 0.06%
RAM usage (Private Working Set): 1636KB 13704KB 10600KB

Known issue: streaming audio prevents automatic sleep mode

When a program streams any audio (even silence), the system doesn't go into sleep mode automatically after specified time of inactivity. Sound Keeper uses the NtPowerInformation(SystemPowerInformation, ...) function to retrieve time when system is going to sleep, and disables itself right before this time. On Windows 7, it works perfectly. Windows 10 waits for 2 minutes more after any sound was streamed, so the PC goes into sleep mode after 2 minutes when Sound Keeper disabled itself. For some reason, Windows 11 always reports that the system is going to sleep in 0 seconds. So, the workaround had to be disabled on this OS until a better solution is found. You can try to use the powercfg to workaround this issue at the system level. Details →

  1. #401
    Stuart Lee

    SoundKeeperSineF1000A0.1L1W10
    SoundKeeperbrownA0.1L1W10

    Strangely, two command line above in the filename didn't prevent it to go to sleep/off.

    😅

  2. #402
    VEG Author

    But does any loud noise like SineF1000A10 prevent it from sleeping? Maybe it ignores any sounds and just sleeps based on a timer?

  3. #403
    Stuart Lee

    I now tries higher Sine Wave, starting from 24000

    SoundKeeperSineF24000A0.1LW10

    Will update here on what i found works.

  4. #404
    Stuart Lee

    it's been more than 20 minutes, and i can see that it still have the white dot on the display , meaning it's staying alive/on.

    I guess it works?

    I want to ask that if SoundKeeperSineF24000A0.1LW10 , correct? especially the last part of W

  5. #405
    VEG Author

    LW10 part makes no sense because L does not have a value here. You should either specify both L and W, or remove both of them. L is length of a sound, and W is wait time between sounds (both in seconds). I would recommend to use something like L1W300 that will make a 1-second sound every 5 minutes (300 seconds).

    I definitely need to finish GUI part of this app to reduce amount of questions how to configure it =)

  6. #406
    Stuart Lee

    L 's default is infinite, does that mean I don't need to put L in the file name for it to go Infinite?

  7. #407
    VEG Author

    Yeah, it's the default.

  8. #408
    Stuart Lee

    Now i found one settings that finally worked, does the Soundbar volume level effect the program?

  9. #409
    VEG Author

    Stuart Lee,

    Now i found one settings that finally worked

    It would be nice if you share name of your soundbar and settings that work for you.

    does the Soundbar volume level effect the program?

    It depends on how your soundbar works. If changing soundbar volume on the soundbar is not reflected in Windows anyhow, it can't affect Sound Keeper in any way. But the soundbar itself can take current volume into account when it tries to detect silence.

  10. #410
    Stuart Lee

    it worked yesterday, now it doesn't. Not sure what went wrong, haha... had to look into it..

    My soundbar was ' EDIFIER B700 Dolby Atmost Soundbar '

  11. #411
    Stuart Lee

    By now it doesn't work , is when i first switch on the pc. I put the program in Startup folder though.

    Still monitoring the soundbar. I switched off the pc, turn off the wall socket switch, wait for 15 seconds and turn back on the pc. The program was running in Task Manager ( startup programs ).

    Will report here if the soundbar stays on or off.

  12. #412
    Stuart Lee

    I found the issue, it was i checked the option of the program's properties to ' run as administrator ' and that prevented it from running on start up properly.

    Now i am trying to put my pc to sleep and let the soundbar goes to standby/off and wake my pc again to see the program works after pc wakes up.

  13. #413
    Stuart Lee

    I've tested for over 10 days since last post at 15 March. My soundbar now stays awake as long as my pc stays awake ( had to sacrifice sleep for pc ) .

    Thanks , author.

    Soundbar is Edifier B700 5.1.2 Dolby Atmos Soundbar.

  14. #414
    David

    So after testing on my Surface Laptop Studio 2 for quite a while, persistent audio doesn't prevent a machine from entering Modern Standby like it does with S3 sleep. I've also confirmed this by exiting SoundKeeper and simply playing music, my machine will enter Modern Standby after a while with music playing and this can be confirmed with Event Viewer as it can when just using SoundKeeper with default settings. This is great for users with newer hardware that supports Modern Standby as there is essentially no compromises when using SoundKeeper on these devices.

  15. #415
    TaTa

    Hi Evgeny, thank you for making this excellent tool.

    I've just purchased a couple of Xiaomi Sound Pocket Bluetooth 5.4 speakers to use with my Windows 11 laptop which has an Intel BE200 WiFi card with Bluetooth 5.4 and noticed that the speakers shutdown after 15 minutes of inactivity. I've tried every option in Sound Keeper, even white/brown noise and sine waves at audible frequencies and amplitudes (confirmed to be playing through the speakers), but nothing seems to keep the speakers awake.

    The really confusing thing is music on Spotify or 50Hz/100Hz test tones on YouTube both keep the speakers awake, even when set to 1% or lower (inaudible) volume levels.

    Do you have any idea what the issue could be, or anything I could try?

  16. #416
    VEG Author

    TaTa, so you tried SineF100A100 and it also couldn't stop the speakers from auto shutdown even though you could clearly hear the sound all the time? It might mean that the detection when the speakers should go into sleep mode is done somewhere in the drivers, and it has some kind of white list of software that is respected. But it sounds crazy for me.

  17. #417
    TaTa

    Correct, I'm running the latest Intel Bluetooth drivers (23.60.0.1) and latest Windows 11 build (24H2 26100.1150).

    Last night I tried downloading the same 50Hz test tone from YouTube which is proven to keep the speakers awake and played it in a loop using a few different programs - ffplay, LoopDropz and MPC-HC. All failed to keep the speakers awake.

    I then tried Microsoft Media Player with the same file and the speakers stayed awake! So I think you might be on the right track with the white listed applications but this also seems absolutely crazy to me.

    You gave me an idea though - I renamed SoundKeeper.exe to Microsoft.Media.Player.exe, chrome.exe and Spotify.exe and ran with various switches but no luck. I even tried with the exe in the appropriate application folders. If it is a white list it must be checking against some other criteria.

  18. #418
    VEG Author

    Looks like it's Intel drivers are trying to be too smart.

    You can try to replace "Audio" to "Pro Audio" or "Playback" on this line and rebuild Sound Keeper (use VS2022 with C++ development components for building). Maybe these thread attributes are used somehow.

    Also, you can try to remove setting of this attribute. Just remove these lines:

    #ifdef ENABLE_MMCSS
    	HANDLE mmcss_handle = NULL;
    	DWORD mmcss_task_index = 0;
    	mmcss_handle = AvSetMmThreadCharacteristics(L"Audio", &mmcss_task_index);
    	if (mmcss_handle == NULL)
    	{
    		DebugLogError("Unable to enable MMCSS on rendering thread: 0x%08X.", GetLastError());
    	}
    #endif

    and

    #ifdef ENABLE_MMCSS
    	if (mmcss_handle != NULL) AvRevertMmThreadCharacteristics(mmcss_handle);
    #endif
  19. #419
    TaTa

    Rebuilt and tested all three variants - no luck unfortunately :(

  20. #420
    TaTa

    I think I've found the issue - WASAPI.

    I've switched a couple of audio players to Direct Sound and the speakers don't go to sleep.

    Is it possible to switch Sound Keeper to Direct Sound?

  21. #421
    VEG Author

    Nope, you need to rewrite most of the code to use Direct Sound instead of WASAPI. In theory, Direct Sound is just a wrapper for WASAPI since Windows Vista, maybe it just uses WASAPI in some specific way that makes the driver satisfied. Also, I hardly believe that modern browsers use legacy Direct Sound (deprecated since 2006) in 2024, I'm quite sure that they rely on WASAPI.

  22. #422
    TaTa

    Interesting, yeah I can see that DirectSound is deprecated.

    The reason I thought this could be the issue - MusicBee lets you switch between DirectSound and WASAPI output. When DirectSound is selected the speakers stay awake, WASAPI they don't.

    I also thought that Foobar2000 used DirectSound by default (using the 'Primary Sound Driver' output) but after doing some more digging I see that it switched to WASAPI in v1.6. Foobar2000 does keep the speakers awake so this definitely invalidates the theory.

    Going back to MMCSS, Chrome sets AvSetMmThreadCharacteristics to "Pro Audio" and also sets AvSetMmThreadPriority to AVRT_PRIORITY_CRITICAL:

    https://github.com/adobe/chromium/blob/master/media/audio/win/audio_low_latency_output_win.cc#L315

    Do you think setting AvSetMmThreadPriority could help?

  23. #423
    TaTa

    I tried setting AvSetMmThreadPriority to AVRT_PRIORITY_CRITICAL, no luck.

  24. #424
    VEG Author

    There are a lot of small things that could be done differently. For example, various flags that can be passed here to IAudioClient::Initialize. Try to replace AUDCLNT_STREAMFLAGS_NOPERSIST | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM to NULL.

    Also, a stream can be timer or event driven. Sound Keeper uses timer as the most robust approach that works for all hardware. You can try to use this sample from Windows 7 SDK to check if event-driven approach affects anything. It shouldn't, but who knows =) There is also a timer-driven sample from Microsoft too.

  25. #425
    TaTa

    Replacing AUDCLNT_STREAMFLAGS_NOPERSIST | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM with NULL didn't help. I'll have a look into other potential flags.

    Built and ran WASAPIRenderSharedEventDriven.exe -f 100 -d 1200 -multimedia, no luck.

    Built and ran WASAPIRenderSharedTimerDriven.exe -f 100 -d 1200 -multimedia, no luck.

  26. #426
    VEG Author

    ¯\_(ツ)_/¯

  27. #427
    TaTa

    I noticed that chromium and foobar2000 both set their rendering thread priority to time critical.

    I tried adding this on line 88: SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);

    But not sure if that's the correct syntax and location (first time using cpp)?

  28. #428
    VEG Author

    It should be inside of the CKeepSession::StartRenderingThread if you want to apply it for the rendering thread.

  29. #429
    TaTa

    I think I'm going to have to admit defeat, just can't get it to work.

    Thank you for all your help!

  30. #430
    Alex LI

    Where is the 1.3.4

  31. #432
    Fudge

    Been using this for years - set to SoundKeeperAll - and it's been fine. Just joined Windows Insider to install the latest update for something, and it stopped working.

    After playing about with it I've got a batch file in my Startup folder set to:

    SoundKeeper.exe brown -a 0.01

    Issues mostly stem from using a soundbar (PC > soundbar > TV) and using FX Configurator to allow DD over HDMI. Even at SoundKeeperAll, I could open the Dolby Home Theatre app and see a line across the EQ, so I knew SoundKeeper was running, it just wasn't working correctly until I output the brown sound.

    Thanks!

  32. #433
    TaTa

    Hi again VEG.

    I think I've figured out the issue of my speakers turning off. There needs to be an active audio app hooked into the Windows global media controls which appear in quick settings and the lock screen: https://www.elevenforum.com/t/enable-or-disable-media-controls-in-windows-11.11505/

    foobar2000 has an advanced option to disable this hook and when I do this the speakers turn off after 15 mins. In the default enabled state they stay awake.

    Not sure how to hook into this but would be awesome if SK could?

Comments are temporarily closed.