Several people have asked me for the sample code I use to program the mixer in Windows. Since it's a fairly short sample and there's clearly some interest, I thought I'd post it directly to the newsgroup. Here it is ... enjoy! (?) Julian // Example routine that manipulates the mixer controls for Win32 // This code is not a stand-alone application ... // // It's also not very pretty ... // // But then, neither is the API ... // // Julian Bunn, 1998, julianb@altavista.net #include #include MIXERCONTROLDETAILS mixDetailsMic,mixDetailsSpk,mixDetailsLin; LONG lMaximumSpk,lMaximumMic,lMaximumLin,lMinimumMic,lMinimumSpk,lMinimumLin; int nMixerDevs; int nMicMixID; LPHMIXER hMixer; UINT IdMixer; /**************************************************************************** Function: ProgramInitMixer() PURPOSE : Initialises the mixer *****************************************************************************/ LONG WINAPI ProgramInitMixer() { UINT iS,iD,iDC,iC, itype; UINT volume; MMRESULT mmres; MIXERCAPS mixCaps; MIXERLINE mixLine; MIXERLINECONTROLS mixControls; MIXERCONTROL mixClist[50]; MIXERCONTROLDETAILS mixDetails; MIXERCONTROLDETAILS_UNSIGNED mixValue; MIXERCONTROLDETAILS_BOOLEAN mixMute; MIXERCONTROLDETAILS_BOOLEAN mixBoolean[50]; MIXERCONTROLDETAILS_LISTTEXT mixList[50]; BOOL bDoneMike = FALSE; BOOL bDoneSpkr = FALSE; UINT LineID = 0; if(!bMixerOpened) { // check first if we have a mixer if((nMixerDevs = mixerGetNumDevs()) < 1) { return (Program_ERROR); } // really need to pop up a chooser for which mixer device, in // cases where there is more than one. // In the meantime, I select the last one listed IdMixer = nMixerDevs-1; mmres = mixerOpen((LPHMIXER) &hMixer, IdMixer, (DWORD) 0, (DWORD) NULL, MIXER_OBJECTF_MIXER); if(mmres != MMSYSERR_NOERROR) { return (Program_ERROR); } bMixerOpened = TRUE; } mmres = mixerGetDevCaps(IdMixer, (LPMIXERCAPS) &mixCaps, sizeof(MIXERCAPS)); if(mmres != MMSYSERR_NOERROR) { return (Program_ERROR); } // Set the manufacturer's name for the mixer ... SetDlgItemText(hWndDialogBox,IDC_MIXERNAME,mixCaps.szPname); if(nMixerDevs>1) { DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_INFOMESSAGE1), hWndDialogBox, DialogBoxCallback); } // Loop over the destination mixer lines for (iD=0;iD