Control speaker volumes with c# - c#

is there any easy way to control the individual speaker volumes in Windows 7 with c#?
I just want to set the volumes to a "preset", because windows likes to reset them randomly...

Start here,
Use IAudioMeterInformation in the CoreAudio APIs in Vista and Win 7.
Managed wrappers are available in NAudio (get at the AudioMeterInformation from the MMDevice).
check this too Get Master Sound Volume in c#

Related

How to detect media playing with C#?

I would like to know how to detect if current windows is playing any kind of media (video, music, etc) similar to what energy settings do to decide if the computer can enter sleep/hibernate mode?
I'm trying to detect how long the computer is idle. I'm currently using the GetLastInputInfo from user32.dll but it just take in consideration the user input, but not if there is any media playing which should not consider the computer idle.
I tried to find C# APIs or native invocations but can't find the information. I'm using latest version of .NET Framework.
Generally speaking, programs don't declare that they are playing media - instead they call SetThreadExecutionState to tell Windows that the computer should not sleep.
That said - Windows 10 recently added support for programs to declare to the OS that they are currently playing media so that they're integrated with Windows' media controls (like how on iOS any program playing video or audio can be controlled from the Control Center).
Here's what appears on my screen when I nudge my volume control:
...however Chrome is being buggy here because I'm not actually playing any media in Chrome but it's telling Windows that it is.
I don't know what Windows API is used to set this - or which API is used to check it - but it isn't very widely used - even Windows' built-in Windows Media Player 12 doesn't use it.

c# beep through system speaker - direct access to sys. speaker

I've used the following code and it expects to sound through the system speaker. The code really sounds but through the sound card (desktop speaker/headphone).
I think it will be possible to make some sound directly using system beep speaker since in device manager it displays the driver for that. Is there any work around for this.
** Not through default speaker / headphone. -- os win7 or 8 **
Console.Beep(i, 100);
EDIT
It is confirmed that win7(at least 64bit or both and newer ver.) dose not use system speaker and instead they routes the call to default sound device.
But my concern is,If the system speaker(hardware) is available and connected, isn't there any other way to access the device directly without using built in APIs to windows. I'd like to do some experiments on this(direct hardware access) and if you can at least provide me some starting point for this.
According to article below, it is not supported in Windows 7 x64.
https://blogs.msdn.microsoft.com/larryosterman/2010/01/04/whats-up-with-the-beep-driver-in-windows-7/
Windows 7 hardware requirements for 64 bit machines didn’t include support for an 8254 PIC chip, which is required for the internal PC speaker beep, so Microsoft changed how this functionality works for Windows 7 and the beep instruction is now re-routed to your Windows audio output instead.
So, it can't be done.
Maybe a configuration of your device is needded. You can try to understand from this: https://superuser.com/a/230167

UWP Real time audio on windows 10

I would like to ask you: In my company I should develop the communication app. Something like Skype etc. We have our custom SIP implementation. Data are encrypted by RSA, or something like that. Now, I'm looking for some solution, how to implement capturing audio on windows 10 (desktop, phone)
I found something about WASAPI, XAudio2. I think, the best option is WASAPI. But It will be working on Windows 10 Mobile? Or would you recommend me any third part libraries like SharpDX, NAudio? I need echo cancellation, and Im not sure, if WASAPI supports echo cancellation.
All advices will be appreciated.
WASAPI is definitely available on windows mobile 10.
but you could capture the audio directly with the "voice capture dsp"
https://msdn.microsoft.com/en-us/library/ff819492(v=VS.85).aspx
i found no info about its availability on win mobile 10, but it's really probable you can use it there too.

Get Device Info using C# in Windows Universal App (Windows 10)

I was wondering how to get device-specific information programmatically using C# in the new Universal Windows app platform. This is to get a simplistic PC Toolbox I have from existing C# code for an old Windows Form project onto the UAP in Windows 10.
I'm looking to get total RAM installed (or available), CPU Architecture and ID/Name (such as 64-bit Intel Core i5-XXXX), Device manufacturer and model number (Dell XPS XXXX), and serial number/service tag.
It's a given that these apps will be using Windows 10 and this app will initially be geared for traditional PCs, but I'd like to expand to Windows Phone/Mobile with limited capabilities (not sure how/if some parts will work on ARM). How would I detect which edition of Windows 10, such as "Home", "Pro", "Enterprise", "Mobile", or "Mobile Enterprise", as well as 32/64 bit, and Language?
I have existing C# code that used a library that doesn't seem to work with Windows Store apps.
I'm pretty rusty with C#, but any help to any classes or references would be greatly appreciated. I realize that getting all the code to store all of these specifications may be a little much (if even possible ATM), but a pointer in the right direction would be very helpful.
You can tap into AnalyticsInfo and AnalyticsVersionInfo to get the information, as noted on the documentation page (https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.analyticsinfo.aspx)
If you want to get the HardwareIdentification information however you will need to look somewhere else as it is not part of the Universal Device Family, it's part of the Desktop and Mobile family (device family specific).
To get this type of device-speficic info available, you have to add the references to the device specific extensions.
Anyways, The APIs that were used to gather these data have changed from 8.x to UWP. I have found one blog post <https://www.suchan.cz/2015/08/uwp-quick-tip-getting-device-os-and-app-info/> for someone who has created a helper class that retrieves the following properties for example from a Windows 10 UWP app
current OS family - phone/desktop/...
current OS build number - 10.0.10240.16413
current OS architecture - x86/x64/ARM
current App Display Name
current App Version - 3.0.2.0
current Device manufacturer - Nokia
current Device model - Lumia 1520
In his post he shows how to get basic data about current device, operating system and application. hope it helps!
Take a look here:
https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.aspx
https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.systemmanufacturers.aspx
These will at least give you the SM Bios Serial Number and possible information about the hardware.

How can we detect system volume in WIndows 8?

If I have an app that plays sounds. It seems like a good idea to indicate why the user isn't hearing the sounds. Is there a way to detect system volume or MUTE?
Yes.
MediaControl.SoundLevel for Windows 8
SystemMediaTransportControls.SoundLevel for Windows 8.1 and later
Music and media capture apps should monitor the SoundLevel to determine whether the audio streams on the app have been Muted.
I think you can use Windows.Media namespace. Also these is SoundLevel enum.
Also
ISimpleAudioVolume interface

Categories

Resources