[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Get microphone state

Posted on 1997-07-04
2
Medium Priority
?
526 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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…
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

656 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