Is there a way i use waveInOpen to establish a "link" with the mic.
If anyone has a starting point of which api to use please drop me a line. i
can figure it out once i have a place to start.
NO DX please.
many thanks
Ebred
> i was using the mixerXXX apis to gater info about the mic. unfortunately i
> can not use those apis to open the mic for recording.
>
> Is there a way i use waveInOpen to establish a "link" with the mic.
What do you mean by link?
> If anyone has a starting point of which api to use please drop me a line. i
> can figure it out once i have a place to start.
You can cross reference the wave API device handle to the mixer device
handle if that's what you mean. Just call mixerOpen() with uMxId set to
you wave device handle and set the flag MIXER_OBJECTF_HWAVEIN.
For samples on how to record audio with waveIn, there are plenty on
codeguru.com.
As an example of what im asking. Lets say i want to activate the mic when a
button is pushed and decativate when released. When i call waveinopen...how
does waveinopen know that i am looking for mic input?
many thanks again
Eric
I will use what you have described to me to monitor when a signal is being
sent to the card. when that event is true then...
waveinopen
waveinprepareheader
waveinaddbuffer
waveinstart
...use filled buffer as input to be used for waveoutwrite
waveinunprepareheader
waveinclose
those events are triggered by a signal from the mic and all other signal
input, unless otherwise specified, will be disregarded for my input in this
case.
On the right track here?
> Thanks for your help chris. i have done what you recommended, but i am still
> confused. Although i have opened the mixer with reference to a wavein
> handle; how can mixeropen and waveinopen know that the device i am looking
> for is only the Mic.
>
> As an example of what im asking. Lets say i want to activate the mic when a
> button is pushed and decativate when released. When i call waveinopen...how
> does waveinopen know that i am looking for mic input?
> many thanks again
The wave input doesn't know what your audio source is, and it doesn't care.
Just set you audio input selection using the mixer API, I have some code
that will get you started which I posted last week. It can be tweaked
slightly to do what you want.
// return the current mux input number and the name string
int GetMuxInput(HMIXER mix, CString &sInputName)
{
int retval = -1;
MMRESULT error;
MIXERLINE mxl;
mxl.cbStruct = sizeof(mxl);
MIXERLINECONTROLS controls;
MIXERCONTROL * control;
MIXERCONTROLDETAILS cd;
HRESULT hr;
memset(&mxl, 0, sizeof(mxl));
mxl.cbStruct = sizeof(mxl);
mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
hr = mixerGetLineInfo((HMIXEROBJ)mix, &mxl,
MIXER_GETLINEINFOF_COMPONENTTYPE);
hr = mixerGetLineInfo((HMIXEROBJ)mix, &mxl,
MIXER_GETLINEINFOF_DESTINATION);
if (hr == MMSYSERR_NOERROR)
{
// should always be the first, but should iterate to make sure
//for (int dest=0; dest<mxl.dwDestination; dest++)
{
controls.cbStruct = sizeof(MIXERLINECONTROLS);
controls.dwLineID = mxl.dwLineID; // from MIXERLINE
controls.cControls = mxl.cControls;
controls.cbmxctrl = sizeof(MIXERCONTROL);
control = (MIXERCONTROL *)LocalAlloc(LPTR, sizeof(MIXERCONTROL) *
controls.cControls);
controls.pamxctrl = control;
controls.dwControlType = MIXERCONTROL_CONTROLTYPE_MUX;
error = mixerGetLineControls((HMIXEROBJ)mix, &controls,
MIXER_GETLINECONTROLSF_ONEBYTYPE);
if (MMSYSERR_NOERROR == error)
{
for (int c=0; c < controls.cControls; c++) // c should equal 0 (1
control) but you never know
{
// MUX - MULTIPLE SELECT
if (MIXERCONTROL_CONTROLTYPE_MUX == (MIXERCONTROL_CONTROLTYPE_MUX &
control[c].dwControlType))
{
cd.cbStruct = sizeof(MIXERCONTROLDETAILS);
cd.dwControlID = control->dwControlID;
cd.cChannels = 1;
cd.cMultipleItems = control->cMultipleItems;
//cd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
cd.cbDetails = sizeof(MIXERCONTROLDETAILS_LISTTEXT);
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 (NULL != lv)
{
// get the text names
cd.paDetails = lt;
error = mixerGetControlDetails((HMIXEROBJ)mix, &cd,
MIXER_GETCONTROLDETAILSF_LISTTEXT);
// get the state values
cd.paDetails = lv;
error = mixerGetControlDetails((HMIXEROBJ)mix, &cd,
MIXER_GETCONTROLDETAILSF_VALUE);
// find out which mux input is selected
for (int i = 0; i < cd.cMultipleItems; i++)
{
CString temp;
temp.Format("%-30s [%c]\n", lt[i].szName, lv[i].fValue?'X':' ');
OutputDebugString(temp);
if (lv[i].fValue)
{
retval = i;
sInputName = lt[i].szName;
}
}
LocalFree(lv);
LocalFree(lt);
}
}
}
}
}
}
return retval;
}
// Set the active Mux input select and return previous selection
int SetMuxInput(HMIXER mix, DWORD target)
{
int retval = -1;
MMRESULT error;
MIXERLINE mxl;
mxl.cbStruct = sizeof(mxl);
MIXERLINECONTROLS controls;
MIXERCONTROL * control;
MIXERCONTROLDETAILS cd;
HRESULT hr;
memset(&mxl, 0, sizeof(mxl));
mxl.cbStruct = sizeof(mxl);
mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
hr = mixerGetLineInfo((HMIXEROBJ)mix, &mxl,
MIXER_GETLINEINFOF_COMPONENTTYPE);
hr = mixerGetLineInfo((HMIXEROBJ)mix, &mxl,
MIXER_GETLINEINFOF_DESTINATION);
if (hr == MMSYSERR_NOERROR)
{
// should always be the first, but should iterate to make sure
//for (int dest=0; dest<mxl.dwDestination; dest++)
{
controls.cbStruct = sizeof(MIXERLINECONTROLS);
controls.dwLineID = mxl.dwLineID; // from MIXERLINE
controls.cControls = mxl.cControls;
controls.cbmxctrl = sizeof(MIXERCONTROL);
control = (MIXERCONTROL *)LocalAlloc(LPTR, sizeof(MIXERCONTROL) *
controls.cControls);
controls.pamxctrl = control;
controls.dwControlType = MIXERCONTROL_CONTROLTYPE_MUX;
error = mixerGetLineControls((HMIXEROBJ)mix, &controls,
MIXER_GETLINECONTROLSF_ONEBYTYPE);
if (MMSYSERR_NOERROR == error)
{
if (target > control->cMultipleItems)
return -1; // value out of range
for (int c=0; c < controls.cControls; c++) // c should equal 0 (1
control) but you never know
{
// MUX - MULTIPLE SELECT
if (MIXERCONTROL_CONTROLTYPE_MUX == (MIXERCONTROL_CONTROLTYPE_MUX &
control[c].dwControlType))
{
cd.cbStruct = sizeof(MIXERCONTROLDETAILS);
cd.dwControlID = control->dwControlID;
cd.cChannels = 1;
cd.cMultipleItems = control->cMultipleItems;
cd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN);
MIXERCONTROLDETAILS_BOOLEAN * lv = (MIXERCONTROLDETAILS_BOOLEAN
*)LocalAlloc (LPTR, cd.cChannels * cd.cMultipleItems * cd.cbDetails);
if (NULL != lv)
{
// get the state values
cd.paDetails = lv;
error = mixerGetControlDetails((HMIXEROBJ)mix, &cd,
MIXER_GETCONTROLDETAILSF_VALUE);
// find out which mux input is selected
for (int i = 0; i < cd.cMultipleItems; i++)
{
if (lv[i].fValue)
{
// if the select flag is on turn it off
retval = i; // save it for return value
lv[i].fValue = 0;
}
}
// set the select flag for the target item
lv[target].fValue = 1;
error = mixerSetControlDetails((HMIXEROBJ)mix, &cd,
MIXER_SETCONTROLDETAILSF_VALUE);
LocalFree(lv);
}
}
}
}
}
}
return retval; // return previously selected item
}
I just want to build a console app that prints the current selected mux
input or set mux input to specified value like:
consoleapp.exe -getSelectedMuxId
consoleapp.exe -setSelectedMuxId valueHere