Volume (Balance) Control for XP/Vista - c++

Is there a method for controlling the Balance of the Wave output that will work on both XP and Vista?

Vista has a new api for everything related to mixers and audio, per process legacy api's should still work, but to change global volume, you would have to look at the new COM interfaces added to Vista
This should get you started

have you looked at this?
waveOutSetVolume
The waveOutSetVolume function sets the
volume level of the specified
waveform-audio output device.
It uses Winmm.lib.
http://msdn.microsoft.com/en-us/library/ms713762.aspx

Related

How to get a list of all attached virtual disks in Windows?

Is there a way to retrieve a list of all virtual disks attached on a Windows machine? I mean all paths to VHD/VHDX mounted by disk manager.
There is an undocumented function GetAllAttachedVirtualDiskPhysicalPaths that does exactly that, however it's not available in Windows 8 (only in 8.1). I need Win 8 support.
Thanks
I don't know of direct c++ calls, assuming you don't know the VD handles but want to get all mounted disks not created or handled by your own code. There is a rough way to do it by running a
diskpart
list vdisk
script and pipe the result into a text file, which you can then parse with c++ to get the list.
Thanks to #Stacking For Heap for the hint - with API monitoring I figured that Diskpart uses VDS API for that purpose, namely IVdsVdProvider. Just built and tested the code - it works fine.
Similar approach is used here, with code samples:
Retrieving virtual disk file name from disk number

Adjust volume / mute from my Qt C++ programm

Under Windows (7,8) I can mute / adjust volume as per application and per output device.
I wonder how I can set / query these values from my C++ Qt application. Basically I need to figure out / accomplish (use cases):
Is the global mute set (per device)? Set global mute from my application.
Is the application's mixer mute set? Set mixer mute.
Set mixer volume, set global volume.
Query mixer volume, set mixer volume?
Wherever possible I am looking for the Qt-ish way to accomplish things, keeping code as platform independent as possible. I can imagine to query the global mute via an OS-independent API, but using a Windows only class for the mixer.
From the C# question Get Master Sound Volume in c# I understand IAudioMeterInformation, IMMDeviceCollection, IMMDevice are the MSDN documentation entry points for Windows specific handling.
How do I tell if the master volume is muted? shows how commands can be send via WM_APPCOMMAND . Again, windows specific, also not allowing to query values but only to set them.
Is there something for Qt encapsulating these things? Is it Phonon I need to use? Checking Phonon briefly I did not see any methods for what I need, but I might have missed it.

Dim screen on Windows with C++

I've been looking into dimming a screen on a Windows platform from my program. I know that there's a SetMonitorBrightness API that allows this, but the issue for me is that it would be nice to be able to dim the screen on Windows XP as well (which that API does not support) and also dim screens on desktop computers.
So I did some research and found this utility that seems to dim my screen on a Windows XP desktop without a problem. I tried to contact the author to find out how they implemented the dimmer but I did not hear back from them.
So I was curious to hear from developers on this site, how do you think they managed to dim the screen when the SetMonitorBrightness API is not supported?
PS. I am a newbie developer myself trying to write an energy saving program for our small business. It is a nonprofit organization and we don't have funds to hire a Windows developer to do this for us. Most of our computers are Windows XP desktops, so as you can see I can't use SetMonitorBrightness API as it is widely documented on the web.
Thanks in advance.
In the case that you cite, have a look at the screensaver with Dependancy Walker. My guess is that they create a full screen window and use SetLayeredWindowAttributes() to set a semi-opaque setting for the window, thus making the screen appear dimmed. I doubt it would save you much money.
You might want to look into the DDC protocol which allows you to control aspects of some monitors. The MS API that allows you to do this can be found roundabout here: http://msdn.microsoft.com/en-us/library/windows/hardware/ff570290%28v=vs.85%29.aspx and you should look at the I2C functions too.
Alternatively you could look for a ready made library to do the DDC stuff for you, such as http://www.nicomsoft.com/products/i2c/. They too have a dimmer application that is free for personal use and non-free for commercial use. They may even allow you to use it for free if you contact them and explain it's for a non-profit organisation.
If you are trying to do this as an energy saving program why not use a screensaver setting that turns the monitor off after a certain period of idleness? In any case
Forgive me if this information is outdated, but I have done this in the past using SetDeviceGammaRamp. The 'Get' version is available too for state saving and restore. I have seen it used in C# programs through, so it might still be relevant albeit not too common anymore.

How to control application volume in WinXP

I would like to programatically control the volume of a particular application in WinXP.
I came to know abt one API waveOutSetVolume(), but it controls the application volume in Win Vista & Above, for XP it just affect the entire system volume.
Please advise how can we achieve this in XP?
Moreover how to Uncheck/Check the SYstem volume Mute check box as well.
As you said, application-level audio levels are available from Vista OS, so XP has no ability to control it.
More info here: http://msdn.microsoft.com/en-us/library/bb945061.aspx
Your second question related to mute, you simply call waveOutSetVolume:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd743874%28v=vs.85%29.aspx

How can I notify my application that the default sound playback device has changed?

I have two sound cards on my Win XP SP3 computer, and I've written a C++ app, with which I change the default playback device by editing the following Registry entry:
regKey = Registry.CurrentUser.OpenSubKey(#"Software\Microsoft\Multimedia\Sound Mapper", true);
My app changes the "Playback" key value for the purposes of using the first or second sound card as the default playback device.
The problem is when I change the default device, the application still uses the old one (which was set as the default when the program starts). If after change, I launch the application again, everything works fine and I can use the "new" default playback device.
How can I "tell" for my application that I have changed the default device? By what way does the application read and store the variable on starting up which sound device is default in Windows? Is there any solution for my problem?
The Registry is essentially a database that stores the default settings. Modifying the values in the registry does not cause any application, nor Windows itself, to re-initialize its settings with the new, updated values. Raymond Chen discusses this very thing with reference to user interface settings.
Also consider that things like this are very likely to change in later versions of Windows. If you ever decide to update to Windows Vista or 7, you'll be back here again asking more questions because your sound-switcher application won't work anymore. The later versions handle audio devices very differently than they were handled in XP; for starters, they're now based around the Core Audio APIs.
Therefore, for reasons that should be obvious, modifying registry values is not the preferred way to modify your computer's configuration.
But if you're just trying to make a particular application notice that you've changed the value in the registry, the simple solution is the RegNotifyChangeKeyValue function. This essentially subscribes the application to receive notifications each time the value of a particular registry key changes.
The correct solution for Windows Vista and later is available here.