Solved

mixerGetLineControls failure

Posted on 2000-05-15
6
1,068 Views
Last Modified: 2013-11-20
I'm trying to open a mixer to monitor audio levels but am getting a MIXERR_INVALCONTROL failure on mixerGetLineControls(). Here is the code I'm using:

    MMRESULT rc;              // Return code.
    MIXERCONTROL mxc;         // Holds the mixer control data.
    MIXERLINE mxl;            // Holds the mixer line data.
    MIXERLINECONTROLS mxlc;   // Obtains the mixer control.
      MIXERCAPS mxrcaps;
      HMIXER hMixer = NULL;

      int nNumDevs = ::mixerGetNumDevs();

      ::ZeroMemory(&m_mxrcaps, sizeof(MIXERCAPS));

      if(!nNumDevs)
      {
            GetMMError(rc);
            return;
      }

      rc = ::mixerOpen(&m_hMixer, 0, 0, NULL, MIXER_OBJECTF_MIXER );
      if(rc != MMSYSERR_NOERROR )
      {
            GetMMError(rc);
            return;
      }

      if(m_hMixer == NULL)
      {
            GetMMError(rc);
            return;
      }

    // Initialize MIXERLINE structure.
    ZeroMemory(&mxl,sizeof(mxl));
    mxl.cbStruct = sizeof(mxl);

    mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;

    rc = mixerGetLineInfo((HMIXEROBJ)m_hMixer, &mxl,
                           MIXER_GETLINEINFOF_COMPONENTTYPE);
      if(rc != MMSYSERR_NOERROR )
      {
            GetMMError(rc);
      }

    // Get the control.
    ZeroMemory(&mxlc, sizeof(mxlc));
    mxlc.cbStruct = sizeof(mxlc);
    mxlc.dwLineID = mxl.dwLineID;
    mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_PEAKMETER;
    mxlc.cControls = 1;
    mxlc.cbmxctrl = sizeof(mxc);
    mxlc.pamxctrl = &mxc;
    ZeroMemory(&mxc, sizeof(mxc));
    mxc.cbStruct = sizeof(mxc);
    rc = mixerGetLineControls((HMIXEROBJ)m_hMixer,&mxlc,
                               MIXER_GETLINECONTROLSF_ONEBYTYPE);
    if (MMSYSERR_NOERROR != rc)
      {
            GetMMError(rc);
    }

    MIXERCONTROLDETAILS mxcd;             // Gets the control values.
    MIXERCONTROLDETAILS_SIGNED volStruct; // Gets the control values.

    // Initialize the MIXERCONTROLDETAILS structure
    ZeroMemory(&mxcd, sizeof(mxcd));
    mxcd.cbStruct = sizeof(mxcd);
    mxcd.cbDetails = sizeof(volStruct);
    mxcd.dwControlID = mxc.dwControlID;
    mxcd.paDetails = &volStruct;
    mxcd.cChannels = 1;

    rc = mixerGetControlDetails((HMIXEROBJ)m_hMixer, &mxcd,
                                 MIXER_GETCONTROLDETAILSF_VALUE);
    if (MMSYSERR_NOERROR != rc)
      {
            GetMMError(rc);
      }

      ... use MIXERCONTROLDETAILS structure


Any ideas?
0
Comment
Question by:Grailman
[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
  • 3
  • 3
6 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 2811231
The MIXERLINE_COMPONENTTYPE_DST_WAVEIN audio line might not support the MIXERCONTROL_CONTROLTYPE_PEAKMETER control. Check out the Windows Volume Control utility and the following Win32 sample to see if the control is there.

MixApp: Sample Mixer Application
http://msdn.microsoft.com/library/devprods/vs6/visualc/vcsample/vcsmpmixapp.htm

Also, check out my article at CodeGuru.

Audio Mixer Functions Demo
http://www.codeguru.com/multimedia/ADMixer.shtml
0
 
LVL 1

Author Comment

by:Grailman
ID: 2813169
I tried your Audio Mixer Functions Demo and it worked fine but only for playing wav files. How do you use it to get the cd play or the microphone input?
0
 
LVL 1

Author Comment

by:Grailman
ID: 2813191
I tried using MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC and MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE for mxl.dwComponentType but still could not get any response...?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:chensu
ID: 2814120
The controls you are trying to get are unlikely to be supported by the audio driver. Check out the Windows Volume Control utility and the following Win32 sample to see if the controls are there.
0
 
LVL 1

Author Comment

by:Grailman
ID: 2838796
The win32 sample & volume controls show the mixer so it should be there. I don't have time to dig into it for now but it looks like I should be able t find it.
0
 
LVL 23

Expert Comment

by:chensu
ID: 2839068
Good luck.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 114
Best tools for Backup and restore of Wordpress site 6 58
sumHeights2  challenge 7 140
Work with App store 7 123
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

710 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