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
Solved

mixerGetLineControls failure

Posted on 2000-05-15
6
1,053 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
  • 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Title # Comments Views Activity
Error on moodle after upgrade 3 140
lucky13 challenge 11 154
isEverywhere  challenge 19 82
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 103
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: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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