?
Solved

Get microphone state

Posted on 1997-07-04
2
Medium Priority
?
525 Views
Last Modified: 2013-11-20
I would know if there are MFC (or API) in Windows 95 that retrieve the microphone state when I switch on/off it by hand. My input is only by microphone and not by mouse or keyboard.
How can I do ? Thanks a lot
0
Comment
Question by:grimaldi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:grimaldi
ID: 1302454
Adjusted points to 100
0
 
LVL 23

Accepted Solution

by:
chensu earned 200 total points
ID: 1302455
If I understand correctly, you mean the switch on the microphone. Some microphones have such switches, some don't have. There is no way to retrieve the state. What you can do is to detect the audio signal coming into the microphone. I copied the following PAQ answered by me in Microsoft Windows Programming Topic Area. You can also use Audio Mixers functions to select or deselect the microphone (switch on/off by software control, it is different from the phisical switch).

Question:
I want to capture the realtime amplitude of the microphone using the mixer functions in
                  Win32. I would like to to have this value returned in the range of 0 to 255. How do I do
                  this?

        Answer:
                   Use Audio Mixers functions. The following are some sample codes.

                   // open the first mixer
                   ::mixerOpen(&m_hMixer, 0, (DWORD)this->GetSafeHwnd(), NULL,
                   MIXER_OBJECTF_MIXER | CALLBACK_WINDOW);

                   ...

                   // get the mixer control
                   if (m_hMixer == NULL)
                   return FALSE;

                   // get dwLineID
                   MIXERLINE mxl;
                   mxl.cbStruct = sizeof(MIXERLINE);
                   mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
                   if (::mixerGetLineInfo((HMIXEROBJ)m_hMixer,
                   &mxl,
                   MIXER_OBJECTF_HMIXER |
                   MIXER_GETLINEINFOF_COMPONENTTYPE)
                   != MMSYSERR_NOERROR)
                   return FALSE;

                   // get dwControlID
                   MIXERCONTROL mxc;
                   MIXERLINECONTROLS mxlc;
                   mxlc.cbStruct = sizeof(MIXERLINECONTROLS);
                   mxlc.dwLineID = mxl.dwLineID;
                   mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_PEAKMETER;
                   mxlc.cControls = 1;
                   mxlc.cbmxctrl = sizeof(MIXERCONTROL);
                   mxlc.pamxctrl = &mxc;
                   if (::mixerGetLineControls((HMIXEROBJ)m_hMixer,
                   &mxlc,
                   MIXER_OBJECTF_HMIXER |
                   MIXER_GETLINECONTROLSF_ONEBYTYPE)
                   != MMSYSERR_NOERROR)
                   return FALSE;

                       m_dwMeterControlID = mxc.dwControlID;


                   // get the value, lVal is in the range of -32768 to 32767, you can convert it to 0-255.
                   BOOL GetMeterValue(LONG &lVal)
                   {
                   if (m_hMixer == NULL)
                   return FALSE;

                   MIXERCONTROLDETAILS_SIGNED mxcdMeter;
                       MIXERCONTROLDETAILS mxcd;
                   mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
                       mxcd.dwControlID = m_dwMeterControlID;
                       mxcd.cChannels = 1;
                       mxcd.cMultipleItems = 0;
                       mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_SIGNED);
                       mxcd.paDetails = &mxcdMeter;
                   if (::mixerGetControlDetails((HMIXEROBJ)m_hMixer,
                   &mxcd,
                   MIXER_OBJECTF_HMIXER |
                   MIXER_GETCONTROLDETAILSF_VALUE)
                   != MMSYSERR_NOERROR)
                   return FALSE;

                   lVal = mxcdMeter.lValue;

                   return TRUE;
                   }


                   ::mixerClose(m_hMixer);
                   m_hMixer = NULL;


                   You can call GetMeterValue() with a timer.

                   For more information, see Win32 SDK documentations about Audio Mixers.

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question