Microphone plug in event/ Mic attach event Vista - mfc

I want to be notified when a microphone jack is plugged in. What is the event fired by the OS(particularly Vista)
The audio panel shows no recording device active if no mic plugged in(vista). This never happened in XP.
Also if my microphone had a "advance control" for eg Bass Boost, Mic Boost(AGC) etc, how can I get the mixer control for the same to control it.
I'm using MFC for development.
Thanks

I believe that you want to implement IMMNotificationClient and handle the OnDeviceAdded event.
If you want the various controls in Vista, you're better off using the Device Topology API to get the controls (IAudioLoudness, etc.) Otherwise, you need to enumerate the mixer device IDs & ask them for their endpoint IDs, then compare the endpoint ID to find the real device you're interested in.

Related

How to modify WASAPI loopback capture volume when the volume of the system gets modified?

I'm using WASAPI with loopback capture mode to record the audio of my Windows 10 laptop soundcard. I followed the example here: https://learn.microsoft.com/en-us/windows/win32/coreaudio/capturing-a-stream and it works perfectly.
However, when I mute the computer, or slide the volume up or down, the volume of the recording does not change. I would like it to change accordingly and be muted accordingly, instead of always playing. I've looked into adding a IAudioEndpointVolume via the Activate function (https://learn.microsoft.com/en-us/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-immdevice-activate) to my IMM_Device (which already gets Activate with IAudioClient3), but the code now crashes at the Initialize call.
Has anyone been able to do that? Any advices on where to go from now?
Thanks a lot!
However, when I mute the computer, or slide the volume up or down, the volume of the recording does not change.
Volume Controls
As explained in Audio Sessions, Sndvol is the system volume-control program. It displays volume controls for the audio-rendering endpoint devices in the system. (Currently, it does not display the volume controls for audio-capture endpoint devices.) To view the volume controls for a particular device, click Device in the menu bar and select a device name from the list of available devices.
Perhaps the problem is here. You mute the audio rendering, not audio capture.

Manage Bluetooth remote shutter keys from my Windows application

I have developed an application in C++ that runs on Windows 7, 8.x and 10. I would like to use a Bluetooth remote shutter to control the application.
The remote shutter seems to be a HID device that sends keypresses to Windows. The default behavior of those keypresses is Volume Up, Volume Down, Play/Pause, Next and Previous.
While I can detect those keypresses from my application and act on them, I have not managed to disable Windows acting on them. E. g. currently, when someone presses the Volume Up key on the remote shutter, two things happen:
Whatever I tell my application to do on that keypress
Also, volume goes up on Windows
How can I tell Windows not to act on those keypresses for this particular device?
Thank you
I have not tried it but i think it may be possible by disabling the Human Interface Device Access Service on Windows.
There may be some side effects along with that like for example:
If the service is stopped or disable, the buttons on USB keyboards will not function (i.e., back, forward, volume up, down, previous track, next track), nor will the volume buttons on USB speakers.
but you can still try :)
here is how to disable it

Trigger an exe once My device is connected via USB

Once my embedded device is connected to USB port of my PC, it should trigger an exe as an event. How can I achieve this??
Should I create a service to keep monitoring the USB connector bus or is there any default API's available in Windows to achieve this??
thanks.
A simple exe which is started on connect is not possible. But you can write a service or user mode application which listens for device arrival events. WM_DEVICECHANGE is sent to all (registered) applications with a device interface guid which represents which device is plugged in. You can then use this id with the setupapi to see if its your device.
On receiving that event, you can then start your executable.
Depending on your version of Windows it might be possible with a workaround using a AutoRun.inf file in the root folder of a USB drive. For security reasons this is by default turned off, and in Windows 7 not allowed at all.
To achieve the same effect in a more robust way, you need to create a service that monitors whether your device is connected or not (e.g. iTunesHelper that monitors for connected Apple devices).
The easiest solution is probably a trivial UMDF driver. That's basically a small COM component called when your device is connected.

Detecting FireWire cable event within MFC C++?

I'm trying to detect the event when a FireWire cable is plugged into the FireWire port of the PC withing MFC C++ app. I would also like to trigger this even myself as the FireWire connections drops and never is rediscovered withing unplugging the cable and plugging it back in.
Anyone have any experience trying to programmaticaly simulate a unplug-replug event?
You can register yourself to receive device arrival messages. See the help for RegisterDeviceNotification to find an example on how to register yourself.
You can trigger a bus reset notification on the firewire bus, but I don't know if you can do this from user mode, without the help of a kernel mode module.

C/C++ USB drive event

Regarding the Windows platform, is their an event I can look for to tell when a USB drive or any type of portable media us plugged in?
You won't get such notifications without first registering for them. Use RegisterDeviceNotification() to do that.
After you have registered your window to receive such notifications, handle the WM_DEVICECHANGE message.