Skip to content

Commit 932d9a6

Browse files
committed
change back naudio and add a system tray control
1 parent 21e4109 commit 932d9a6

File tree

4 files changed

+69
-37
lines changed

4 files changed

+69
-37
lines changed

README.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,65 @@
44

55
## Overview
66

7-
The Silent Sound Generator is a small utility designed to address issues with wireless headsets, specifically Jabra devices, which tend to automatically turn off due to inactivity. This application helps prevent such devices from powering down by simulating continuous audio playback, ensuring they remain active and ready for use.
7+
The Silent Sound Generator is a utility designed to solve an issue with wireless headsets, specifically Jabra and similar devices, which tend to turn off automatically due to inactivity. This application simulates continuous audio playback in the background, ensuring the headset stays active.
88

99
## Purpose
1010

11-
Many wireless headsets, especially Jabra models, have a feature that turns them off automatically when they detect inactivity or when no audio is being played. This can be problematic if you need to keep the headset active for extended periods, as it might not turn back on promptly when needed. The Silent Sound Generator solves this problem by continuously simulating audio playback, keeping the headset active and ready.
11+
Many wireless headsets, like Jabra devices, power down automatically when there is no audio being played. This behavior can be inconvenient when you need the headset to remain active. The Silent Sound Generator ensures that headsets stay connected and ready by simulating silent audio playback in the background, effectively "tricking" the headset into staying on.
1212

1313
## Features
1414

15-
- **Simulated Continuous Audio Playback**: Plays a silent audio file in an endless loop.
16-
- **Resource Embedded**: The silent audio file is embedded within the executable, so no external files are required.
17-
- **Simple Operation**: Runs as a background process, ensuring minimal impact on system performance.
18-
- **Autostart Support**: Can be configured to start automatically with Windows.
15+
- **Continuous Silent Audio Playback**: Uses NAudio to play an infinite loop of silence.
16+
- **Minimizes to System Tray**: Runs silently in the background and minimizes to the system tray, showing a small icon for easy access.
17+
- **Embedded Silent Playback**: No external audio files are needed, as the silent audio is generated programmatically.
18+
- **Minimal Resource Usage**: The application is lightweight and designed to have minimal impact on system performance.
19+
- **Autostart Support**: Can be configured to launch automatically when Windows starts.
1920

2021
## Installation
2122

22-
1. **[Download](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) and install** dotnet 8 runtime
23+
1. **[Install .NET 8 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)**: Make sure you have the .NET 8 runtime installed on your machine.
2324

24-
1. **Download the Latest Release**: Go to the [Releases page](https://github.com/Q-Sharp/SilentSoundGenerator/releases) and download the latest version of the executable.
25+
2. **Download the Latest Release**: Visit the [Releases page](https://github.com/Q-Sharp/SilentSoundGenerator/releases) to download the latest version of the executable.
2526

26-
1. **Run the Application**: Simply run the downloaded `.exe` file. It will start simulating silent audio playback and will continue to do so until it is closed.
27+
3. **Run the Application**: Execute the `.exe` file. The application will begin simulating silent audio playback and will minimize to the system tray.
2728

28-
1. **(Optional) Add to Autostart**: To ensure the application starts automatically with Windows:
29-
- **Manual Method**: Create a shortcut of the `SilentSoundGenerator.exe` file and place it in the Windows Startup folder. You can access this folder by pressing `Win + R`, typing `shell:startup`, and pressing Enter. Paste the shortcut in the opened folder.
30-
- **Automated Method**: You can use third-party tools or scripts to add the application to the startup automatically.
29+
4. **(Optional) Add to Autostart**:
30+
- **Manual Method**: Create a shortcut of the `SilentSoundGenerator.exe` file and place it in the Windows Startup folder. You can access this folder by pressing `Win + R`, typing `shell:startup`, and pressing Enter. Paste the shortcut in the folder.
31+
- **Automated Method**: Use scripts or third-party utilities to add the application to startup.
3132

3233
## Usage
3334

34-
1. **Launch the Application**: Double-click on the executable file to start the Silent Sound Generator.
35+
1. **Launch the Application**: Double-click on the executable file. Once launched, the application will run in the background, visible only via the system tray icon.
3536

36-
1. **Keep Your Headset Active**: The application will continuously play silent audio, preventing your wireless headset from automatically turning off.
37+
2. **Keep Your Headset Active**: The application will continuously play silent audio, ensuring that your wireless headset remains powered on and ready to use.
3738

38-
1. **Stop the Application**: To stop the simulation, close the application window or use the task manager to terminate the process.
39+
3. **Stop the Application**: Right-click the tray icon and select "Exit" to stop the silent sound generation and close the application.
3940

4041
## How It Works
4142

42-
The Silent Sound Generator uses a small, silent `.wav` file that is embedded in the application. It leverages the `System.Media.SoundPlayer` class to play this file in a loop. The application runs indefinitely, simulating audio playback to keep the headset active.
43+
The Silent Sound Generator uses the [NAudio](https://github.com/naudio/NAudio) library to generate and play an infinite loop of silence. The application minimizes to the system tray to ensure a non-intrusive user experience. Silent audio is generated in memory and played through the system's audio hardware to keep the headset active.
4344

4445
## Technical Details
4546

4647
- **Platform**: Windows
4748
- **Framework**: .NET 8.0
48-
- **Embedded Resource**: Silent audio file is embedded within the executable.
49-
- **Deployment**: Built as a self-contained executable, no .NET runtime required on target machines.
49+
- **NAudio**: Used for generating and managing silent audio playback.
50+
- **Deployment**: Distributed as a self-contained executable, so no additional dependencies are required on the target machine.
5051

5152
## Troubleshooting
5253

53-
- **No Sound or Application Not Working**: Ensure that the application is running and check the task manager to verify that it is active.
54-
- **Headset Still Turns Off**: Ensure that the headset is not affected by other power-saving features or settings outside of audio playback.
54+
- **Application Does Not Start**: Ensure that the .NET 8 runtime is installed and up to date.
55+
- **Headset Still Turns Off**: Check your device's power management settings or other related features that may be causing the headset to power down.
56+
- **No System Tray Icon**: Verify that the application is running. If the icon is missing, try restarting the application or your system.
5557

5658
## License
5759

5860
This project is licensed under the [MIT License](LICENSE).
5961

6062
## Contact
6163

62-
If you have any questions or feedback, please feel free to reach out via [GitHub Issues](https://github.com/Q-Sharp/SilentSoundGenerator/issues).
64+
For questions, issues, or feature requests, please open a ticket via [GitHub Issues](https://github.com/Q-Sharp/SilentSoundGenerator/issues).
6365

6466
---
6567

66-
*Silent Sound Generator* is a community-driven project aimed at improving the usability of wireless headsets. Contributions and feedback are always welcome!
68+
*Silent Sound Generator* is a community-driven project that helps improve the usability of wireless headsets by preventing unwanted power-downs during inactivity. Contributions and feedback are always welcome!

SilentSoundGenerator/Program.cs

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,46 @@
1-
using System.Media;
2-
using System.Reflection;
1+
using NAudio.Wave;
32

4-
using var stream = Assembly.GetExecutingAssembly()
5-
.GetManifestResourceStream("SilentSoundGenerator.silent.wav");
3+
ApplicationConfiguration.Initialize();
4+
Application.Run(new SilentSoundApplicationContext());
65

7-
using var player = new SoundPlayer(stream);
8-
player.PlayLooping();
9-
10-
while(true)
6+
public class SilentSoundApplicationContext : ApplicationContext
117
{
12-
await Task.Delay(1000);
13-
}
8+
private readonly NotifyIcon _trayIcon;
9+
private readonly CancellationTokenSource _cts;
10+
private readonly Task _soundTask;
11+
12+
public SilentSoundApplicationContext()
13+
{
14+
_cts = new CancellationTokenSource();
15+
_trayIcon = new NotifyIcon()
16+
{
17+
Icon = new Icon(SystemIcons.Shield, 40, 40),
18+
ContextMenuStrip = new ContextMenuStrip()
19+
{
20+
Items = { new ToolStripMenuItem("Exit", null, Exit) }
21+
},
22+
Visible = true,
23+
Text = "Silent Sound Generator"
24+
};
25+
26+
_soundTask = Task.Run(async () =>
27+
{
28+
var waveOut = new WaveOutEvent();
29+
waveOut.Init(new SilenceProvider(new WaveFormat(44100, 1)).ToSampleProvider());
30+
waveOut.Play();
31+
32+
while(true)
33+
{
34+
await Task.Delay(1000);
35+
}
36+
});
37+
}
38+
39+
void Exit(object? sender, EventArgs e)
40+
{
41+
_cts.Cancel();
42+
_cts.Dispose();
43+
_trayIcon.Visible = false;
44+
Application.Exit();
45+
}
46+
}

SilentSoundGenerator/SilentSoundGenerator.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<SelfContained>false</SelfContained>
1010
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
1111
<PublishReadyToRun>true</PublishReadyToRun>
12+
<UseWindowsForms>true</UseWindowsForms>
1213
<!--<PublishAot>true</PublishAot>-->
1314
</PropertyGroup>
1415

@@ -18,11 +19,7 @@
1819
</PropertyGroup>
1920

2021
<ItemGroup>
21-
<PackageReference Include="System.Windows.Extensions" Version="8.0.0" />
22-
</ItemGroup>
23-
24-
<ItemGroup>
25-
<EmbeddedResource Include="silent.wav" />
22+
<PackageReference Include="NAudio" Version="2.2.1" />
2623
</ItemGroup>
2724

2825
</Project>

SilentSoundGenerator/silent.wav

-172 KB
Binary file not shown.

0 commit comments

Comments
 (0)