I’m really happy with this release because I’ve been able to play with Sound and .NET.
I admit most of the work was done by the great NAudio library, but still, it was great to implement different type of notifications (that can be easily extended in the future) for the users.
I received some time ago in my inbox a request to implement a Sound notification instead of the Windows one. The reason was simple, the basic one on Windows 10 is quite slow to react when you’re switching rapidly the SoundCard; it won’t be able to show directly which one is the last one and the sound is also delayed. Moreover, it can be considered quite intrusive compared to the old “ballontip” used in the previous version of the OS. I thought the problem was real and decided to code a new NotificationSystem for SoundSwitch.
An enum, a factory, an interface and a couple of implementations and I had my architecture done. It’s not really a difficult design. Then came the need to play the audio. I first thought of trying to plug into Windows Audio API, like WASAPI. However, I found it hard to use especially since I would need it in C# and not C++. In my search for an alternative, I found NAudio. This neat library is wrapping all the possible audio API of Windows to provide an easy way to play sound using .NET. The main developer, Mark, made a wonderful blog post on how to implement a fire and forget system for sound. Having everything I needed, I started building the new notification system.
I roamed through FreeSound.org to find the perfect (and free of right) notification sound. Thanks to the work ofĀ Robinhood76 I found it. Simple, short, and not annoying since this one will be played at each soundcard switch.
For now, the sound is in the resources of the Program, but it would be possible later, if asked, to provide a way to personalize it.
Edit of 23rd of January: The request was raised and I added the possibility to set a chosen sound (MP3/WAV) for the notification.
Leave a Reply