Solved

Get microphone state

Posted on 1997-07-04
2
522 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 100 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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