none
How to enable stereo Mix in WIN7 & xp?

    Question

  • It seems in XP mixAPI is used, but in WIN7 only core audio API can be used.

    Is there some common way to solve this?

    any suggest or example?

    Thanks guys.

    Wednesday, December 12, 2012 2:42 AM

Answers

  • mixer APIs are emulated using core audio APIs on Windows 7.


    Visual C++ MVP

    Wednesday, December 12, 2012 3:23 AM
    Moderator
  • Thanks.

    And I found this paper that helps a lot in WIN7. (switch )

    http://www.daveamenta.com/2011-05/programmatically-or-command-line-change-the-default-sound-playback-device-in-windows-7/

    In XP, ths is a way to switch among input

    1. Use

    waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0 ,0, CALLBACK_NULL);
    err = mixerOpen(&m_hInputMixer, (UINT)hWaveIn, 0, 0, MIXER_OBJECTF_HWAVEIN);
    to Open m_hInputMixer

    2. Switch to next input

    	MMRESULT error1 = MMSYSERR_ERROR, error2 = MMSYSERR_ERROR;
    	MIXERLINE mxl;
    	MIXERCONTROL mxc;
    	MIXERCONTROLDETAILS cd;
    	memset(&mxl, 0, sizeof(mxl));
    	mxl.cbStruct = sizeof(mxl);
        // Get Line: DST WAVEIN
    	if (!GetFirstLineByType(m_hInputMixer, &mxl, MIXERLINE_COMPONENTTYPE_DST_WAVEIN))
    		return -1;
        // Get MUX Control
    	if (!GetFirstControlByType(m_hInputMixer, &mxl, &mxc, MIXERCONTROL_CONTROLTYPE_MUX))
    		return -1;
        // Get all input channels of this MUX Control
    	cd.cbDetails = sizeof(MIXERCONTROLDETAILS_LISTTEXT);
    	cd.cbStruct = sizeof(MIXERCONTROLDETAILS);
    	cd.dwControlID = mxc.dwControlID;
    	cd.cChannels = 1;
    	cd.cMultipleItems = mxc.cMultipleItems;
    	if (cd.cMultipleItems <=0) return -1;
    	MIXERCONTROLDETAILS_BOOLEAN * lv = (MIXERCONTROLDETAILS_BOOLEAN
    		*)LocalAlloc (LPTR, cd.cChannels * cd.cMultipleItems * cd.cbDetails);
    	MIXERCONTROLDETAILS_LISTTEXT * lt = (MIXERCONTROLDETAILS_LISTTEXT
    		*)LocalAlloc (LPTR, cd.cChannels * cd.cMultipleItems * cd.cbDetails);
    	if (lv && lt)
    	{
    		// get the text names
    		cd.paDetails = lt;
    		error1 = mixerGetControlDetails((HMIXEROBJ)m_hInputMixer, &cd,
    			MIXER_GETCONTROLDETAILSF_LISTTEXT);
    		// get the state values
    		cd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
    		cd.paDetails = lv;
    		error2 = mixerGetControlDetails((HMIXEROBJ)m_hInputMixer, &cd,
    			MIXER_GETCONTROLDETAILSF_VALUE);
    		if (error1 == MMSYSERR_NOERROR && error2 == MMSYSERR_NOERROR && cd.cMultipleItems > 0){
    			int deviceCount = cd.cMultipleItems;
    			for(int i=0;i<deviceCount;i++){
    				if (i==nSel)
    				{
    					lv[i].fValue = 1;
    				}else{
    					lv[i].fValue = 0;
    				}
    			}
    			szName = string_utility::ConstructString(L"%d %s", nSel, lt[nSel].szName);
    			nSel = (nSel + 1) % deviceCount;
    			error1 = mixerSetControlDetails((HMIXEROBJ)m_hInputMixer, &cd,
    				MIXER_SETCONTROLDETAILSF_VALUE);
    		}
    		LocalFree(lv);
    		LocalFree(lt);
    	}

    • Marked as answer by Andyzn Friday, January 18, 2013 5:20 AM
    Friday, January 18, 2013 5:19 AM

All replies

  • mixer APIs are emulated using core audio APIs on Windows 7.


    Visual C++ MVP

    Wednesday, December 12, 2012 3:23 AM
    Moderator
  • mixer APIs are emulated using core audio APIs on Windows 7.


    Visual C++ MVP

    Thanks.

    Does that mean mixer API can be used  seamlessly in WIN7 just like XP?

    I got 2 operating systems WIN7 and XP in the same computer.

    I use mixerGetNumDevs(). XP returns 3 but WIN7 return zero.


    Wednesday, December 12, 2012 4:49 AM
  • Wednesday, December 12, 2012 5:29 AM
    Moderator
  • Thanks.

    And I found this paper that helps a lot in WIN7. (switch )

    http://www.daveamenta.com/2011-05/programmatically-or-command-line-change-the-default-sound-playback-device-in-windows-7/

    In XP, ths is a way to switch among input

    1. Use

    waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0 ,0, CALLBACK_NULL);
    err = mixerOpen(&m_hInputMixer, (UINT)hWaveIn, 0, 0, MIXER_OBJECTF_HWAVEIN);
    to Open m_hInputMixer

    2. Switch to next input

    	MMRESULT error1 = MMSYSERR_ERROR, error2 = MMSYSERR_ERROR;
    	MIXERLINE mxl;
    	MIXERCONTROL mxc;
    	MIXERCONTROLDETAILS cd;
    	memset(&mxl, 0, sizeof(mxl));
    	mxl.cbStruct = sizeof(mxl);
        // Get Line: DST WAVEIN
    	if (!GetFirstLineByType(m_hInputMixer, &mxl, MIXERLINE_COMPONENTTYPE_DST_WAVEIN))
    		return -1;
        // Get MUX Control
    	if (!GetFirstControlByType(m_hInputMixer, &mxl, &mxc, MIXERCONTROL_CONTROLTYPE_MUX))
    		return -1;
        // Get all input channels of this MUX Control
    	cd.cbDetails = sizeof(MIXERCONTROLDETAILS_LISTTEXT);
    	cd.cbStruct = sizeof(MIXERCONTROLDETAILS);
    	cd.dwControlID = mxc.dwControlID;
    	cd.cChannels = 1;
    	cd.cMultipleItems = mxc.cMultipleItems;
    	if (cd.cMultipleItems <=0) return -1;
    	MIXERCONTROLDETAILS_BOOLEAN * lv = (MIXERCONTROLDETAILS_BOOLEAN
    		*)LocalAlloc (LPTR, cd.cChannels * cd.cMultipleItems * cd.cbDetails);
    	MIXERCONTROLDETAILS_LISTTEXT * lt = (MIXERCONTROLDETAILS_LISTTEXT
    		*)LocalAlloc (LPTR, cd.cChannels * cd.cMultipleItems * cd.cbDetails);
    	if (lv && lt)
    	{
    		// get the text names
    		cd.paDetails = lt;
    		error1 = mixerGetControlDetails((HMIXEROBJ)m_hInputMixer, &cd,
    			MIXER_GETCONTROLDETAILSF_LISTTEXT);
    		// get the state values
    		cd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
    		cd.paDetails = lv;
    		error2 = mixerGetControlDetails((HMIXEROBJ)m_hInputMixer, &cd,
    			MIXER_GETCONTROLDETAILSF_VALUE);
    		if (error1 == MMSYSERR_NOERROR && error2 == MMSYSERR_NOERROR && cd.cMultipleItems > 0){
    			int deviceCount = cd.cMultipleItems;
    			for(int i=0;i<deviceCount;i++){
    				if (i==nSel)
    				{
    					lv[i].fValue = 1;
    				}else{
    					lv[i].fValue = 0;
    				}
    			}
    			szName = string_utility::ConstructString(L"%d %s", nSel, lt[nSel].szName);
    			nSel = (nSel + 1) % deviceCount;
    			error1 = mixerSetControlDetails((HMIXEROBJ)m_hInputMixer, &cd,
    				MIXER_SETCONTROLDETAILSF_VALUE);
    		}
    		LocalFree(lv);
    		LocalFree(lt);
    	}

    • Marked as answer by Andyzn Friday, January 18, 2013 5:20 AM
    Friday, January 18, 2013 5:19 AM