 |
|
 |
1. when I use this code to get microphone's value.
I can not get value by call GetVolume() on XP SP2, when I change
hr = mixerOpen(&hMixer, 0, 0, 0, 0); to hr = mixerOpen(&hMixer, 1, 0, 0, 0);
It works well.
2. I found there was a error, before call mixerGetControlDetails ( On GetVolume() )
because this will throw an exception on VS2008.
///////////////////////////////////////////////////////
MIXERCONTROLDETAILS_UNSIGNED vol;
vol.dwValue=0;
mxcd.hwndOwner = 0;
mxcd.cbStruct = sizeof(mxcd);
mxcd.dwControlID = m_dwControlID;
mxcd.cbDetails = sizeof(vol);
mxcd.paDetails = &vol;
mxcd.cChannels = 1;
hr = mixerGetControlDetails((HMIXEROBJ)hMixer, &mxcd, XER_OBJECTF_HMIXER|MIXER_GETCONTROLDETAILSF_VALUE);
mixerClose(hMixer);
//////////////////////////////////////////////////////////
I changed the code, add some fields, It works well.
|
|
|
|
 |
|
 |
Hi Iam new bibe to directshow. In my application want to control microphone volume dynamically. Sometimes I need to mute/unmute microphone volume. During google search I got this link ,hope this will exactly suit my requirment. As you said
I created a simple VC++ console application and included the Mixer.h and Mixer.cpp into my project.
CMixer mixer(MIXERLINE_COMPONENTTYPE_DST_WAVEIN , CMixer::Record);
int current_volume=mixer.GetVolume();
current_volume+=20;
mixer.SetVolume(current_volume);
Inside CMixer constructor call Iam getting an error while running this line
hr = mixerGetLineInfo((HMIXEROBJ)hMixer, &mxl, MIXER_GETLINEINFOF_COMPONENTTYPE);
Error code:An attempt was load to a program with an incorrect format HRESULT-->0x0000000b
Don't know why Iam getting this error. Please help me to solve this problem. Thanks in advance.
regards
Anand Veera
|
|
|
|
 |
|
 |
The following article also covers a few more details like enable/disable (master) mute feature and microphone/audio input selection. Probably still takes "effort" to understand the code, but at least it's available.
Audio Mixer Functions Demo
http://www.codeproject.com/audio/admixer.asp
"A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible." - Freeman Dyson
|
|
|
|
 |
|
 |
Hi everyone, I am new programming with the soundcard, and I would like to change the volume of the microphone. I have tried to use this code, but I don't have the "stdafx" and "send" libraries that the code needs. Where can I get them??
Thanks.
|
|
|
|
 |
|
 |
Hi,
everytime I try one of such mixer examples, I always get this error:
"error: cannot convert `MIXERCONTROL*' to `tagMIXERCONTROLW*' in assignment"
Is there any solution to this?
|
|
|
|
 |
|
 |
I work on a cpp project and I want to change the microphone record volume.
this sources files will really help me.
Please re-upload it.
Thanks !
|
|
|
|
 |
|
 |
Now I want to choose FrontPanel MIC or BackPanel MIC to recorde sound. My mixer panel have two item, but WireType only is MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE. So I only can control FrontPanle MIC using MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE. Can you help me?
|
|
|
|
 |
|
 |
I am facing the same problem. I can only adjust the front panel microphone. Did you ever manage to solve this?
/JON
JON
|
|
|
|
 |
|
 |
We have tried your mixer class's in vista but could not set the record volume. How to set the record volume on Vista OS
|
|
|
|
 |
|
 |
i am new at mixer side
can anyone of you tell me the coding steps to adjust the recording Volume? I want to use Mixer
Jabeen
|
|
|
|
 |
|
 |
The component to record, must be selected (Not a part of this code). If this is done you should be able to change the recording volume of the component by using the code above. Set first parameter of CMixer constructor to the component of choice – eg. MIXERLINE_COMPONENTTYPE_SRC_LINE for “Line In” and secord to RECORD, then call the member function SetVolume with a parameter between 0 and 0xFFFF. However I had to change the code a bit to make it work on my system. In the SetVolume function I changed mxcd.cChannels = m_dwChannels; to mxcd.cChannels = 1;. This should work as long as you don’t want to control the balance as well. If this is the case mxcd.cChannels should be set to 2 and you must create a MIXERCONTROLDETAILS_UNSIGNED array with 2 elements and assign each with a dwValue between 0 and 0xFFFF – Element 0 is left channel.
Greetings
Martin Skibye
|
|
|
|
 |
|
 |
Mixer.obj : error LNK2001: Not dissolved external symbol __imp__mixerGetLineControlsA@12
Mixer.obj : error LNK2001: Not dissolved external symbol __imp__mixerClose@4
Mixer.obj : error LNK2001: Not dissolved external symbol __imp__mixerGetLineInfoA@12
Mixer.obj : error LNK2001: Not dissolved external symbol __imp__mixerOpen@20
Mixer.obj : error LNK2001: Not dissolved external symbol __imp__mixerSetControlDetails@12
Mixer.obj : error LNK2001: Not dissolved external symbol __imp__mixerGetControlDetailsA@12
dosnt work for my
can anybody help me?
|
|
|
|
 |
|
 |
..unfortunately, it fails to accomplish its objective. I ran into a similar problem when I wrote the Stay In Touch Messager Client. The folks at PalTalk seemed to have a similar problem with their client a few years back, too. Eventually, the PalTalk folks opted to use the Windows' "Audio Setup Wizard," but even that seems to fail 10-15% of the time.
There doesn't seem to be a 'one-size-fits-all' solution to the problem because each sound card vendor seems to do things their own way. That coupled with the different languages supported by Windows seems to make this a lost cause. The best you can hope for is a 'horseshoes-n-grenades' solution.
The problem with this CMixer class is that it fails to take into account the possibility that the microphone recording control may not actually be a MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE control. It may be part of a MIXERCONTROL_CONTROLTYPE_MUX control. And in that situation, the only way to find the control is by enumerating all of the controls and searching for it by name... and as you indicated at the top of your article, the name could be virtually anything, from "Microphone" to "Mic Volume"... or even something in a foreign language.
My 'horseshoes-n-grenades' solution was to enumerate all of the recording controls in a combobox that I placed in an "Audio Setup" dialog. The program searches through the list items of controls in the combobox for 'Microphone' and if it finds it, it selects that list item. If that fails, it searchs through the list for anything that starts with 'Mic' and selects whatever it finds. If the 'Mic' search fails, it selects the first list item in the combobox and lets the user to select the appropriate recording control from the list in the combobox.
It is a considerably complex process to traverse the mixer devices hierarchy, but there doesn't seem to be a simple way to accurately locate the desired control without traversing the hierarchy and searching for the control by name, rather than by control type.
|
|
|
|
 |
|
 |
plus this approach get stuck if MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE is an invalid source.
|
|
|
|
 |
|
 |
I have used the CMixer class to controll the microphone volume controll in my app. It's working great.
NowI am trying to put three cards onto one system,I would like to know how can I control the microphone volume for all these cards separatly?
desperate for help!!!!!!!!!!!!
suju david
bangalore
|
|
|
|
 |
|
 |
I believe you select the appropriate mixer for a sound card using the uMxID paramater of mixerOpen(). This program uses a hardcoded index of 0 to select only the first mixer in the system: mixerOpen(&hMixer, [0], 0, 0, 0); To open multiple mixers, you will need to acquire the actual number of mixers in your system using mixerGetNumDevs(VOID). Then you will need an array of HMIXER handles, one handle for each mixer indicated by the call to mixerGetNumDevs(). Call mixerOpen() to open each mixer device. Once you have the handle to each mixer device, you can step through the [mixers-->lines-->controls] hierarchy to find the microphone volume for each mixer using the appropriate mixer handle. Unfortunately, I think this 'class' is overly simplistic. I find it considerably more complex to get/set the microphone volume and 'select' the microphone recording device. Failing to properly traverse the [mixers-->lines-->controls] hierarchy usually results in the wrong mixer control being selected, or an error condition. In most mixers I've encountered, the microphone recording control is a member of a MIXERCONTROL_CONTROLTYPE_MUX, rather than a standalone MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE control. This 'class' doesn't seem to handle that situation.
|
|
|
|
 |
|
 |
Thank you very much
Signature for Forums
(Maximum 500 chars)
This will appear at the
end of messages you post
to the Code Project
|
|
|
|
 |
|
 |
count = mxl.dwSource;
now get a invalid value in my XP system.
but it did work 2 years ago, when I coded it in 2k and test in 9x.
It's also strange why I write that code, coz I can't find any document to indicate that usage(fetch the lines count), even now.
perhaps I just digged it out through test & watch, & test & watch..., but unfortunately MS change his mind at last.
documents about MIX on MSDN are still big mess. so the commented is just hardcode count to a reasonable value (20 is far enough in most system), til u find the way to get the right count of lines.
as to "select control", it dosen't exist in my original code, and won't late. regret to it.
thank u all, thank Comawhite.
|
|
|
|
 |
|
 |
using the CMixer class I think it changes the volume but how can I have that control Selected. I mean how can the Select check box in the mixer control is checked using the same class.Any help on that would be appreciated.
|
|
|
|
 |
|
 |
I'm also searching for how to do that. Is there an API or programmatic way to select the playback & recording control? Anybody around here know?
"A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible." - Freeman Dyson
|
|
|
|
 |
|
 |
One way of selecting a component in "Recording Control" is this: /// CODE START /// void setInputSel(long compType) { HMIXER hMixer; MMRESULT result; MIXERLINE ml = {0}; MIXERCONTROL mc = {0}; MIXERLINECONTROLS mlc = {0}; MIXERCONTROLDETAILS mcd = {0}; DWORD dwi; DWORD m_dwControlType, m_dwSelectControlID, m_dwMultipleItems; result = mixerOpen(&hMixer, MIXER_OBJECTF_MIXER, 0, 0, 0); if (result == MMSYSERR_NOERROR) { // get dwLineID ml.cbStruct = sizeof(MIXERLINE); ml.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN; //"Recording Control" result = mixerGetLineInfo((HMIXEROBJ) hMixer, &ml, MIXER_OBJECTF_HMIXER | MIXER_GETLINEINFOF_COMPONENTTYPE); if (result == MMSYSERR_NOERROR) { // try MUX m_dwControlType = MIXERCONTROL_CONTROLTYPE_MUX; mlc.cbStruct = sizeof(MIXERLINECONTROLS); mlc.dwLineID = ml.dwLineID; mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_MUX; mlc.cControls = 1; mlc.cbmxctrl = sizeof(MIXERCONTROL); mlc.pamxctrl = &mc; result = mixerGetLineControls((HMIXEROBJ) hMixer, &mlc, MIXER_OBJECTF_HMIXER | MIXER_GETLINECONTROLSF_ONEBYTYPE); if (result != MMSYSERR_NOERROR) { return; } // store dwControlID, cMultipleItems m_dwSelectControlID = mc.dwControlID; m_dwMultipleItems = mc.cMultipleItems; // get the index of the component type Select control MIXERCONTROLDETAILS_LISTTEXT *pmcdSelectText = new MIXERCONTROLDETAILS_LISTTEXT[m_dwMultipleItems]; if (pmcdSelectText != NULL) { MIXERCONTROLDETAILS mcd; mcd.cbStruct = sizeof(MIXERCONTROLDETAILS); mcd.dwControlID = m_dwSelectControlID; mcd.cChannels = 1; mcd.cMultipleItems = m_dwMultipleItems; mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_LISTTEXT); mcd.paDetails = pmcdSelectText; result = mixerGetControlDetails((HMIXEROBJ) hMixer, &mcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_LISTTEXT); if (result == MMSYSERR_NOERROR) { // Run through the list of the recording components to find the array element (dwi) for the componentType for (dwi = 0; dwi < m_dwMultipleItems; dwi++) { // get the line information MIXERLINE ml; ml.cbStruct = sizeof(MIXERLINE); ml.dwLineID = pmcdSelectText[dwi].dwParam1; result = mixerGetLineInfo((HMIXEROBJ) hMixer, &ml, MIXER_OBJECTF_HMIXER | MIXER_GETLINEINFOF_LINEID); if (result == MMSYSERR_NOERROR && ml.dwComponentType == compType) { // found, dwi is the index. break; } } } delete []pmcdSelectText; } // get all the values first MIXERCONTROLDETAILS_BOOLEAN *pmcdSelectValue = new MIXERCONTROLDETAILS_BOOLEAN[m_dwMultipleItems]; if (pmcdSelectValue != NULL) { MIXERCONTROLDETAILS mcd; mcd.cbStruct = sizeof(MIXERCONTROLDETAILS); mcd.dwControlID = m_dwSelectControlID; mcd.cChannels = 1; mcd.cMultipleItems = m_dwMultipleItems; mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN); mcd.paDetails = pmcdSelectValue; result = mixerGetControlDetails((HMIXEROBJ) hMixer, &mcd, MIXER_OBJECTF_HMIXER | MIXER_GETCONTROLDETAILSF_VALUE); if (result == MMSYSERR_NOERROR) { // Check if m_dwControlType has a valid value: assert(m_dwControlType == MIXERCONTROL_CONTROLTYPE_MUX); // MUX restricts the line selection to one source line at a time. ZeroMemory(pmcdSelectValue, m_dwMultipleItems * sizeof(MIXERCONTROLDETAILS_BOOLEAN)); // set the component type value pmcdSelectValue[dwi].fValue = 1; mcd.cbStruct = sizeof(MIXERCONTROLDETAILS); mcd.dwControlID = m_dwSelectControlID; mcd.cChannels = 1; mcd.cMultipleItems = m_dwMultipleItems; mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_BOOLEAN); mcd.paDetails = pmcdSelectValue; result = mixerSetControlDetails((HMIXEROBJ) hMixer, &mcd, MIXER_OBJECTF_HMIXER | MIXER_SETCONTROLDETAILSF_VALUE); int test = 0; } delete []pmcdSelectValue; } } mixerClose(hMixer); } } /// CODE END /// This function is to be called with the component to be selected (e.g. MIXERLINE_COMPONENTTYPE_SRC_LINE ("Line In")). Greetings, Martin Skibye Vivir con miedo es como vivir a medias!
|
|
|
|
 |
|
 |
Hello,
How to Set Microphone record volume in Visual Basic. I can set microphone volume in Playback(master volume). How to set microphone volume in record.
I can set microphone volume (master volume) in all OS; bu i cant in windows Xp
See suggest me.
|
|
|
|
 |
|
 |
The link to get the source code doesn't work. Could anybody pass me the proyect source files?
Thank you very much, Ramon.
|
|
|
|
 |
|
|
 |
|
 |
Has anyone used the code to control the playback wave volume ? I have used this on XP and the record microphone volume works well but nothing on playback (yes i checked and use the correct parameters based on the mm headers and also use the Play parameter)
TIA
|
|
|
|
 |