problem on recording sound<p align=left>Hello,<br>My application needs to record the sound of the microphone. But, I am <br>worrying the user may set the microphone input volume mute by accident. So I <br>want to use some codes to check it and set the volume of microphone input <br>maximum. <br>Is there any API to do this?</p> <p align=left>Thanks</p>© 2009 Microsoft Corporation. All rights reserved.Tue, 03 Mar 2009 21:59:26 Z2774ba56-7de3-4b20-8f58-a6a3d8076964http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#2774ba56-7de3-4b20-8f58-a6a3d8076964http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#2774ba56-7de3-4b20-8f58-a6a3d8076964bertpuhttp://social.msdn.microsoft.com/Profile/en-US/?user=bertpuproblem on recording sound<p align=left>Hello,<br>My application needs to record the sound of the microphone. But, I am <br>worrying the user may set the microphone input volume mute by accident. So I <br>want to use some codes to check it and set the volume of microphone input <br>maximum. <br>Is there any API to do this?</p> <p align=left>Thanks</p>Wed, 13 Feb 2008 06:10:55 Z2008-02-14T01:12:09Zhttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#3e0de7a9-3f92-49fc-bd4e-3d4c022089eehttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#3e0de7a9-3f92-49fc-bd4e-3d4c022089eeAliRafieehttp://social.msdn.microsoft.com/Profile/en-US/?user=AliRafieeproblem on recording sound<p align=left>You will need to use the Mixer functions, MixerGetControlDetail and MixerSetControlDetail.</p> <p align=left> </p> <p align=left>See if this helps.</p> <p align=left><a title="http://www.codeguru.com/cpp/g-m/multimedia/audio/article.php/c1561/" href="http://www.codeguru.com/cpp/g-m/multimedia/audio/article.php/c1561/">http://www.codeguru.com/cpp/g-m/multimedia/audio/article.php/c1561/</a></p> <p align=left> </p> <p align=left>AliR.</p> <p align=left> </p> <p align=left> </p>Wed, 13 Feb 2008 17:42:49 Z2008-02-14T01:12:09Zhttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#0a14a3b9-995f-42a7-baa7-4ae110325724http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#0a14a3b9-995f-42a7-baa7-4ae110325724bertpuhttp://social.msdn.microsoft.com/Profile/en-US/?user=bertpuproblem on recording sound<p>When I build the project, an error occured:</p> <p align=left>c:\program files\microsoft visual studio\vc98\include\mmsystem.h(113) : error C2146: syntax error : missing ';' before identifier 'MMVERSION'<br>c:\program files\microsoft visual studio\vc98\include\mmsystem.h(113) : fatal error C1004: unexpected end of file found</p> <p align=left> </p> <p align=left>What is the problem?</p>ThanksThu, 14 Feb 2008 01:13:42 Z2008-02-14T01:13:42Zhttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#c5830d88-fb09-4161-a893-3b8b06cd4fc0http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#c5830d88-fb09-4161-a893-3b8b06cd4fc0bertpuhttp://social.msdn.microsoft.com/Profile/en-US/?user=bertpuproblem on recording sound<p align=left><font face=Arial size=2>Hello,</font></p> <p align=left> </p> <p align=left><font face=Arial size=2>Now, I have solved the above problem by some other articles, but I have a new problem.</font></p> <p align=left> </p> <p align=left>I can control the output volume with the codes provided by the above article, but I still can't change the input volume. How can I change the input volume?</p> <p align=left> </p> <p align=left>Thanks.</p>Thu, 14 Feb 2008 12:27:35 Z2008-02-14T12:27:35Zhttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#ea44472d-f7b2-44c4-bd94-ec9aadeec034http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#ea44472d-f7b2-44c4-bd94-ec9aadeec034AliRafieehttp://social.msdn.microsoft.com/Profile/en-US/?user=AliRafieeproblem on recording sound<p>Pass <font size=2>MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE to these functions for the microphone volume.  See the help for MIXERLINE struct for other possible values.  The dwVolume range is from 0 to 0xFFFF</font></p> <p align=left> </p> <p align=left> </p><font face=Arial size=2><font color="#0000ff" size=2> <p align=left> <div class=codeseg> <div class=codecontent> <div class=codesniptitle><span style="width:100%">Code Snippet</span></div><font face=Arial size=2><font color="#0000ff" size=2><font color="#0000ff" size=2> <p>void</font><font size=2><font color="#000000"> SetVolume(DWORD OfWhichDevice, DWORD dwVolume )</font></p> <p>{</p> <blockquote dir=ltr style="margin-right:0px"> <p>MMRESULT result;</p> <p>HMIXER hMixer;</p> <p>MIXERLINE ml = {0};</p> <p>MIXERLINECONTROLS mlc = {0};</p> <p>MIXERCONTROL mc = {0};</p> <p>MIXERCONTROLDETAILS mcd = {0};</p> <p>MIXERCONTROLDETAILS_UNSIGNED mcdu = {0};</p></blockquote> <p> </p> <blockquote dir=ltr style="margin-right:0px"> <p></font><font color="#008000" size=2>// get a handle to the mixer device</p></font><font size=2> <p>result = mixerOpen(&amp;hMixer, MIXER_OBJECTF_MIXER, 0, 0, 0);</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (MMSYSERR_NOERROR == result)</p> <p>{</p> <blockquote dir=ltr style="margin-right:0px"> <p>ml.cbStruct = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(MIXERLINE);</p> <p>ml.dwComponentType = OfWhichDevice;</p> <p></font><font color="#008000" size=2>// get the speaker line of the mixer device</p></font><font size=2> <p>result = mixerGetLineInfo((HMIXEROBJ) hMixer, &amp;ml, MIXER_GETLINEINFOF_COMPONENTTYPE);</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (MMSYSERR_NOERROR == result)</p> <p>{</p> <blockquote dir=ltr style="margin-right:0px"> <p>mlc.cbStruct = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(MIXERLINECONTROLS);</p> <p>mlc.dwLineID = ml.dwLineID;</p> <p>mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;</p> <p>mlc.cControls = 1;</p> <p>mlc.pamxctrl = &amp;mc;</p> <p>mlc.cbmxctrl = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(MIXERCONTROL);</p> <p></font><font color="#008000" size=2>// get the volume controls associated with the speaker line</p></font><font size=2> <p>result = mixerGetLineControls((HMIXEROBJ) hMixer, &amp;mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (MMSYSERR_NOERROR == result)</p> <p>{</p> <blockquote dir=ltr style="margin-right:0px"> <p>mcdu.dwValue = dwVolume;</p> <p>mcd.cbStruct = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(MIXERCONTROLDETAILS);</p> <p>mcd.hwndOwner = 0;</p> <p>mcd.dwControlID = mc.dwControlID;</p> <p>mcd.paDetails = &amp;mcdu;</p> <p>mcd.cbDetails = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(MIXERCONTROLDETAILS_UNSIGNED);</p> <p>mcd.cChannels = 1;</p> <p></font><font color="#008000" size=2>// set the volume</p></font><font size=2> <p>result = mixerSetControlDetails((HMIXEROBJ) hMixer, &amp;mcd, MIXER_SETCONTROLDETAILSF_VALUE);</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (MMSYSERR_NOERROR == result)</p> <blockquote dir=ltr style="margin-right:0px"> <p>AfxMessageBox(</font><font color="#008080" size=2>&quot;Volume changed!&quot;</font><font size=2>);</font></p></blockquote> <p dir=ltr align=left><font color="#0000ff" size=2>else</p></font><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p>AfxMessageBox(</font><font color="#008080" size=2>&quot;mixerSetControlDetails() failed&quot;</font><font size=2>);</p></blockquote></blockquote> <p>}</p> <p></font><font color="#0000ff" size=2>else</p></font><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p>AfxMessageBox(</font><font color="#008080" size=2>&quot;mixerGetLineControls() failed&quot;</font><font size=2>);</p></blockquote></blockquote> <p>}</p> <p></font><font color="#0000ff" size=2>else</p></font><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p>AfxMessageBox(</font><font color="#008080" size=2>&quot;mixerGetLineInfo() failed&quot;</font><font size=2>);</p></blockquote></blockquote></blockquote> <p></p> <blockquote dir=ltr style="margin-right:0px"> <blockquote dir=ltr style="margin-right:0px"> <p>mixerClose(hMixer);</p></blockquote> <p>}</p> <p></font><font color="#0000ff" size=2>else</p></font><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p>AfxMessageBox(</font><font color="#008080" size=2>&quot;mixerOpen() failed&quot;</font><font size=2>);</p></blockquote></blockquote> <p>}</p></font><font color="#008000" size=2> <p>//====================================================================</p></font><font size=2> <p>DWORD GetVolume( DWORD OfWhichDevice)</p> <p>{</p> <blockquote dir=ltr style="margin-right:0px"> <p>DWORD dwVolume = -1;</p> <p>MMRESULT result;</p> <p>HMIXER hMixer;</p> <p>MIXERLINE ml = {0};</p> <p>MIXERLINECONTROLS mlc = {0};</p> <p>MIXERCONTROL mc = {0};</p> <p>MIXERCONTROLDETAILS mcd = {0};</p> <p>MIXERCONTROLDETAILS_UNSIGNED mcdu = {0};</p> <p> </p> <p></font><font color="#008000" size=2>// get a handle to the mixer device</p></font><font size=2> <p>result = mixerOpen(&amp;hMixer, 0, 0, 0, MIXER_OBJECTF_HMIXER);</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (MMSYSERR_NOERROR == result)</p> <p>{</p> <blockquote dir=ltr style="margin-right:0px"> <p>ml.cbStruct = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(MIXERLINE);</p> <p>ml.dwComponentType = OfWhichDevice;</p> <p></font><font color="#008000" size=2>// get the speaker line of the mixer device</p></font><font size=2> <p>result = mixerGetLineInfo((HMIXEROBJ) hMixer, &amp;ml, MIXER_GETLINEINFOF_COMPONENTTYPE);</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (MMSYSERR_NOERROR == result)</p> <p>{</p> <blockquote dir=ltr style="margin-right:0px"> <p>mlc.cbStruct = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(MIXERLINECONTROLS);</p> <p>mlc.dwLineID = ml.dwLineID;</p> <p>mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;</p> <p>mlc.cControls = 1;</p> <p>mlc.pamxctrl = &amp;mc;</p> <p>mlc.cbmxctrl = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(MIXERCONTROL);</p> <p></font><font color="#008000" size=2>// get the volume controls associated with the speaker line</p></font><font size=2> <p>result = mixerGetLineControls((HMIXEROBJ) hMixer, &amp;mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (MMSYSERR_NOERROR == result)</p> <p>{</p> <blockquote dir=ltr style="margin-right:0px"> <p>mcd.cbStruct = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(MIXERCONTROLDETAILS);</p> <p>mcd.hwndOwner = 0;</p> <p>mcd.dwControlID = mc.dwControlID;</p> <p>mcd.paDetails = &amp;mcdu;</p> <p>mcd.cbDetails = </font><font color="#0000ff" size=2>sizeof</font><font size=2>(MIXERCONTROLDETAILS_UNSIGNED);</p> <p>mcd.cChannels = 1;</p> <p></font><font color="#008000" size=2>// get the volume</p></font><font size=2> <p>result = mixerGetControlDetails((HMIXEROBJ) hMixer, &amp;mcd, MIXER_SETCONTROLDETAILSF_VALUE);</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (MMSYSERR_NOERROR == result)</p> <blockquote dir=ltr style="margin-right:0px"> <p>dwVolume = mcdu.dwValue;</p></blockquote> <p></font><font color="#0000ff" size=2>else</p></font><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p>AfxMessageBox(</font><font color="#008080" size=2>&quot;mixerGetControlDetails() failed&quot;</font><font size=2>);</p></blockquote></blockquote> <p>}</p> <p></font><font color="#0000ff" size=2>else</p></font><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p>AfxMessageBox(</font><font color="#008080" size=2>&quot;mixerGetLineControls() failed&quot;</font><font size=2>);</p></blockquote></blockquote> <p>}</p> <p></font><font color="#0000ff" size=2>else</p></font><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p>AfxMessageBox(</font><font color="#008080" size=2>&quot;mixerGetLineInfo() failed&quot;</font><font size=2>);</p></blockquote></blockquote></blockquote> <p></p> <blockquote dir=ltr style="margin-right:0px"> <blockquote dir=ltr style="margin-right:0px"> <p>mixerClose(hMixer);</p></blockquote> <p dir=ltr>}</p> <p></font><font color="#0000ff" size=2>else</p></font><font size=2> <blockquote dir=ltr style="margin-right:0px"> <p>AfxMessageBox(</font><font color="#008080" size=2>&quot;mixerOpen() failed&quot;</font><font size=2>);</p></blockquote> <p></font><font color="#0000ff" size=2>return</font><font size=2> (dwVolume);</p></blockquote> <p>}</p></font></font></font></div></div> <p align=left> </p></font> <p></p><font size=2> <p align=left></p></font></font>Thu, 14 Feb 2008 16:09:43 Z2008-02-14T16:09:43Zhttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#26bb0741-19d0-4db8-8f9d-47e1f56ea8cfhttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#26bb0741-19d0-4db8-8f9d-47e1f56ea8cfbertpuhttp://social.msdn.microsoft.com/Profile/en-US/?user=bertpuproblem on recording sound<p align=left><font face=Arial size=2></font> </p> <p>Thanks.</p> <p align=left>But when I invoked SetVolume(MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE,0);, it told me mixerGetLineInfo() failed.</p> <p align=left> </p>And because of the restriction of my sound card, I can't change the microphone input volume in the control panel neither. I can only change the leftmost volume in the &quot;Realtek HD Audio Input&quot;, maybe it is called &quot;Recording Control&quot; in English.(My OS is not a english version). How can I change the &quot;recording control&quot; volume? What argument should I pass to the SetVolume method?<br>Fri, 15 Feb 2008 03:27:05 Z2008-02-15T03:27:05Zhttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#487f1caa-d386-47df-9b27-5e117e17a53chttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#487f1caa-d386-47df-9b27-5e117e17a53cAliRafieehttp://social.msdn.microsoft.com/Profile/en-US/?user=AliRafieeproblem on recording sound<p align=left><font face=Arial size=2>Look at the help for MIXERLINE, try passing in different values of dwComponentType to Get/SetVolume and see if any of them help.  Otherwise I am out of suggestions.</font></p> <p align=left> </p> <p align=left>mabye MIXERLINE_COMPONENTTYPE_DST_DIGITAL or MIXERLINE_COMPONENTTYPE_DST_LINE</p> <p align=left> </p> <p align=left>AliR.</p> <p align=left> </p>Fri, 15 Feb 2008 15:30:32 Z2008-02-15T15:30:32Zhttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#de71b146-9343-4697-bdea-0e9237d9777chttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#de71b146-9343-4697-bdea-0e9237d9777cbertpuhttp://social.msdn.microsoft.com/Profile/en-US/?user=bertpuproblem on recording sound<p align=left>Unfortunately, I have tried all the values and they all didn't work<img src="http://forums.microsoft.com/Forums/WebResource.axd?d=NySzF1eivP_rMoc50GQJzcvS4MHMOEKwYrCIgDtzuzlw7GsNki3H_INlfYaLgkxFSSG0MZbJ1z6uFFjZvu3APg2&amp;t=633337194230757564"></p>Sat, 16 Feb 2008 00:50:23 Z2008-02-16T00:50:23Zhttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#5f1738bb-7af5-4259-beeb-5a6385e9bcf6http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#5f1738bb-7af5-4259-beeb-5a6385e9bcf6Cord02http://social.msdn.microsoft.com/Profile/en-US/?user=Cord02problem on recording sound<p align=left><font face=Arial size=2>Was anyone able to resolve this? This is the exact same problem I am experiencing.</font></p> <p align=left> </p> <p align=left>I can control all the audio sources and destination on the Volume Control except for the &quot;Line Volume&quot; and &quot;Mic Volume&quot; when selecting the Realtek HD Audio Input as the Mixer device.</p> <p align=left> </p> <p align=left><a title="http://www.teamsoftwaresolutions.com/picts/realtek.gif" href="http://www.teamsoftwaresolutions.com/picts/realtek.gif">http://www.teamsoftwaresolutions.com/picts/realtek.gif</a></p> <p> </p> <p align=left>Any information would be appreciated.</p> <p align=left> </p>Fri, 16 May 2008 18:03:08 Z2008-05-16T18:03:08Zhttp://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#6c34af1e-00a2-45b8-85b0-930a92cdfac3http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/2774ba56-7de3-4b20-8f58-a6a3d8076964#6c34af1e-00a2-45b8-85b0-930a92cdfac3coachjackhttp://social.msdn.microsoft.com/Profile/en-US/?user=coachjackproblem on recording sound Hi, I am having same Error using the MMSystem.   <br><br>mmsystem.h(113) : error C2146: syntax error : missing ';'<br><br>What did you do to resolve your compiler error?<br><br>ThanksTue, 03 Mar 2009 21:58:18 Z2009-03-03T21:59:23Z