Solved

mixerGetLineControls failure

Posted on 2000-05-15
6
1,034 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
Comment Utility
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
Comment Utility
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
Comment Utility
I tried using MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC and MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE for mxl.dwComponentType but still could not get any response...?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 23

Expert Comment

by:chensu
Comment Utility
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
Comment Utility
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
Comment Utility
Good luck.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Named range not carried over 10 57
wait notify demo infinite loop 3 79
zeroFront challenge 7 70
sumHeights  challenge 17 59
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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now