使用多媒体API枚举音频设备

  1. //=============================================================================
  2. //=============================================================================
  3. //  MixerInfo.cpp
  4. //
  5. // Utility function to list all available options of your mixer device interface
  6. //
  7. //=============================================================================
  8. //===========================================================================
  9. // Function   : GetDevicesInfo
  10. //          
  11. // Utility function that will print to the specified file all audio lines
  12. // and all mixer controls available on your system. You might want to use
  13. // this function before doing anything else to determine the capabilities
  14. // of your sound card, and of the mixer drivers installed.
  15. //
  16. // It will list all destination lines (ouput lines) and all
  17. // source (input) lines available with every destination line. It will
  18. // also list the available mixer controls for each audio line. Use that
  19. // information to determine what type of windows controls you would
  20. // be allowed to create.
  21. //
  22. // Check the output file and note the type and number of destination (output)
  23. // lines, as well as the source (input) lines associated with every destination
  24. // line. These are labled "Line type".
  25. // Note also the available control types, labeled "Control types"
  26. // You will need these to create your windows controls.
  27. //
  28. // The output may be quite long, but its structure is as follows: for
  29. // every destination line, the controls that work on the output are listed first.
  30. // Then the source lines available for the given output line are listed, as well
  31. // as the controls they contain. Below is an example for the speakers output
  32. // line only, where all the extra information has been removed.
  33. //
  34. //**************************************************************************************
  35. //** Destination line. Index = 0 *******************************************************
  36. //  ------
  37. //  Line type :  ---------  MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
  38. //  ------
  39. //
  40. //      Control type:      MIXERCONTROL_CONTROLTYPE_VOLUME
  41. //
  42. //      Control type:      MIXERCONTROL_CONTROLTYPE_MUTE
  43. //
  44. //      Control type:      MIXERCONTROL_CONTROLTYPE_MIXER
  45. //    
  46. //      Control type:      MIXERCONTROL_CONTROLTYPE_BASS
  47. //    
  48. //      Control type:      MIXERCONTROL_CONTROLTYPE_TREBLE
  49. //    
  50. //      Control type:      ---- UNKNOWN CONTROL TYPE ----
  51. //    
  52. //    =====================================================================================
  53. //    == Source line. Index = 0 ===========================================================
  54. //    ------
  55. //    Line type :  ---------  MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY
  56. //    ------
  57. //    Audio line is a source originating from the auxiliary audio line.
  58. //
  59. //        Control type:      MIXERCONTROL_CONTROLTYPE_VOLUME
  60. //      
  61. //        Control type:      MIXERCONTROL_CONTROLTYPE_MUTE
  62. //      
  63. //    ======================================================================================
  64. //    == Source line. Index = 1 ===========================================================
  65. //    ------
  66. //    Line type :  ---------  MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER
  67. //    ------
  68. //    Audio line is a source originating from the output of an internal synthesizer.
  69. //
  70. //        Control type:      MIXERCONTROL_CONTROLTYPE_VOLUME
  71. //      
  72. //        Control type:      MIXERCONTROL_CONTROLTYPE_MUTE
  73. //      
  74. //    ======================================================================================
  75. //    == Source line. Index = 2 ===========================================================
  76. //    ------
  77. //    Line type :  ---------  MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE
  78. //    ------
  79. //    Audio line is a microphone recording source.
  80. //
  81. //        Control type:      MIXERCONTROL_CONTROLTYPE_VOLUME
  82. //      
  83. //        Control type:      MIXERCONTROL_CONTROLTYPE_MUTE
  84. //      
  85. //        Control type:      MIXERCONTROL_CONTROLTYPE_ONOFF
  86. //
  87. //    ======================================================================================
  88. //    == Source line. Index = 3 ===========================================================
  89. //    ------
  90. //    Line type :  ---------  MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC
  91. //    ------
  92. //    Audio line is a source originating from the output of an internal audio CD.
  93. //
  94. //        Control type:      MIXERCONTROL_CONTROLTYPE_VOLUME
  95. //      
  96. //        Control type:      MIXERCONTROL_CONTROLTYPE_MUTE
  97. //      
  98. //    ======================================================================================
  99. //    == Source line. Index = 4 ===========================================================
  100. //    ------
  101. //    Line type :  ---------  MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT
  102. //    ------
  103. //    Audio line is a source originating from the waveform-audio output digital-to-analog converter (DAC).
  104. //
  105. //        Control type:      MIXERCONTROL_CONTROLTYPE_VOLUME
  106. //      
  107. //        Control type:      MIXERCONTROL_CONTROLTYPE_MUTE
  108. //      
  109. //        Control type:      MIXERCONTROL_CONTROLTYPE_PEAKMETER
  110. //    
  111. //
  112. // Implemented in MixerInfo.cpp
  113. //          
  114. // Return : void
  115. // Arg    : LPCSTR filename : name of output file
  116. //===========================================================================
  117. #include "stdafx.h"
  118. #include <mmsystem.h>
  119. #pragma comment(lib, "winmm.lib")
  120. #ifdef _DEBUG
  121. #define new DEBUG_NEW
  122. #undef THIS_FILE
  123. static char THIS_FILE[] = __FILE__;
  124. #endif
  125. //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
  126. // Name   : PrintLineType
  127. //          
  128. // Descr. : 
  129. //          
  130. // Return : void
  131. // Arg    : int nIndent     : 
  132. // Arg    : MIXERLINE &line : 
  133. // Arg    : FILE *file      : 
  134. //-----------------------------------------------------------------------------
  135. void PrintLineType( int nIndent, MIXERLINE &line, FILE *file )
  136. {
  137.   char *tabs;
  138.   if( nIndent == 0 )
  139.     tabs = "";
  140.   else
  141.     tabs = "/t";
  142.   fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  143.   fprintf( file, "%s Line type :", tabs );
  144.   switch( line.dwComponentType )
  145.   {
  146.     case MIXERLINE_COMPONENTTYPE_DST_DIGITAL:
  147.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_DST_DIGITAL/n", tabs );
  148.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  149.       fprintf( file, "%s Audio line is a digital destination (for example, digital input to a DAT or CD audio device)./n", tabs );
  150.       break;
  151.     case MIXERLINE_COMPONENTTYPE_DST_UNDEFINED:
  152.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_DST_UNDEFINED/n", tabs );
  153.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  154.       fprintf( file,  "%s Audio line is a destination that cannot be defined by one of the standard component types./n", tabs );
  155.       break;
  156.     case MIXERLINE_COMPONENTTYPE_DST_LINE:
  157.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_DST_LINE/n", tabs);
  158.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  159.       fprintf( file,  "%s Audio line is a line level destination that will be the final recording source for the analog-to-digital converter (ADC)./n", tabs );
  160.       break;
  161.     case MIXERLINE_COMPONENTTYPE_DST_MONITOR:
  162.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_DST_MONITOR/n", tabs);
  163.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  164.       fprintf( file,  "%s Audio line is a destination used for a monitor./n", tabs );
  165.       break;
  166.     case MIXERLINE_COMPONENTTYPE_DST_SPEAKERS:
  167.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_DST_SPEAKERS/n", tabs);
  168.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  169.       fprintf( file,  "%s Audio line is an adjustable (gain and/or attenuation) destination intended to drive speakers./n", tabs );
  170.       break;
  171.     case MIXERLINE_COMPONENTTYPE_DST_HEADPHONES:
  172.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_DST_HEADPHONES/n", tabs);
  173.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  174.       fprintf( file,  "%s Audio line is an adjustable (gain and/or attenuation) destination intended to drive headphones./n", tabs );
  175.       break;
  176.     case MIXERLINE_COMPONENTTYPE_DST_TELEPHONE:
  177.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_DST_TELEPHONE/n", tabs);
  178.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  179.       fprintf( file,  "%s Audio line is a destination that will be routed to a telephone line./n", tabs );
  180.       break;
  181.     case MIXERLINE_COMPONENTTYPE_DST_WAVEIN:
  182.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_DST_WAVEIN/n", tabs);
  183.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  184.       fprintf( file,  "%s Audio line is a destination that will be the final recording source for the waveform-audio input (ADC)./n", tabs );
  185.       break;
  186.     case MIXERLINE_COMPONENTTYPE_DST_VOICEIN:
  187.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_DST_VOICEIN/n", tabs);
  188.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  189.       fprintf( file,  "%s Audio line is a destination that will be the final recording source for voice input./n", tabs );
  190.     break;
  191.     case MIXERLINE_COMPONENTTYPE_SRC_ANALOG:
  192.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_SRC_ANALOG/n", tabs);
  193.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  194.       fprintf( file,  "%s Audio line is an analog source (for example, analog output from a video-cassette tape)./n", tabs );
  195.       break;
  196.     case MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY:
  197.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY/n", tabs);
  198.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  199.       fprintf( file,  "%s Audio line is a source originating from the auxiliary audio line./n", tabs );
  200.       break;
  201.     case MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC:
  202.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC/n", tabs);
  203.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  204.       fprintf( file,  "%s Audio line is a source originating from the output of an internal audio CD./n", tabs );
  205.       break;
  206.     case MIXERLINE_COMPONENTTYPE_SRC_DIGITAL:
  207.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_SRC_DIGITAL/n", tabs);
  208.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  209.       fprintf( file,  "%s Audio line is a digital source (for example, digital output from a DAT or audio CD)./n", tabs );
  210.       break;
  211.     case MIXERLINE_COMPONENTTYPE_SRC_LINE:
  212.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_SRC_LINE/n", tabs);
  213.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  214.       fprintf( file,  "%s Audio line is a line-level source (for example, line-level input from an external stereo)./n", tabs );
  215.       break;
  216.     case MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE:
  217.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE/n", tabs);
  218.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  219.       fprintf( file,  "%s Audio line is a microphone recording source./n", tabs );
  220.       break;
  221.     case MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER:
  222.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER/n", tabs);
  223.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  224.       fprintf( file,  "%s Audio line is a source originating from personal computer speaker./n", tabs );
  225.       break;
  226.     case MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER:
  227.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER/n", tabs);
  228.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  229.       fprintf( file,  "%s Audio line is a source originating from the output of an internal synthesizer./n", tabs );
  230.       break;
  231.     case MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE:
  232.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE/n", tabs);
  233.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  234.       fprintf( file,  "%s Audio line is a source originating from an incoming telephone line./n", tabs );
  235.       break;
  236.     case MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED:
  237.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED/n", tabs);
  238.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  239.       fprintf( file,  "%s Audio line is a source that cannot be defined by one of the standard component types./n", tabs );
  240.       break;
  241.     case MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT:
  242.       fprintf( file, "%s MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT/n", tabs);
  243.       fprintf( file, "%s -----------------------------------------------------------------------/n", tabs );
  244.       fprintf( file,  "%s Audio line is a source originating from the waveform-audio output digital-to-analog converter (DAC)./n", tabs );
  245.       break;
  246.     default:
  247.       fprintf( file, "/n" );
  248.       break;
  249.   }
  250.   fprintf( file,  "%s Name: %s/n", tabs, line.szName );
  251.   fprintf( file,  "%s Short Name: %s/n/n", tabs, line.szShortName );
  252.   switch( line.fdwLine )
  253.   {
  254.     case MIXERLINE_LINEF_ACTIVE:
  255.       fprintf( file,  "%s Audio line is active.  signal is probably passing through the line./n", tabs );
  256.       break;
  257.     case MIXERLINE_LINEF_DISCONNECTED:
  258.       fprintf( file,  "%s Audio line is disconnected./n", tabs );
  259.       break;
  260.     case MIXERLINE_LINEF_SOURCE:
  261.       fprintf( file,  "%s Audio line is an audio source line associated with a single audio destination line./n", tabs );
  262.       break;
  263.     default:
  264.       break;
  265.   }
  266.   if( line.Target.dwType != MIXERLINE_TARGETTYPE_UNDEFINED )
  267.   {
  268.     fprintf( file,  "%s     Target type: %lu --    ", tabs, line.Target.dwType );
  269.     switch( line.Target.dwType )
  270.     {
  271.       case MIXERLINE_TARGETTYPE_WAVEOUT:
  272.         fprintf( file, "MIXERLINE_TARGETTYPE_WAVEOUT/n" );
  273.         break;
  274.       case MIXERLINE_TARGETTYPE_WAVEIN:
  275.         fprintf( file, "MIXERLINE_TARGETTYPE_WAVEIN/n" );
  276.         break;
  277.       case MIXERLINE_TARGETTYPE_MIDIOUT:
  278.         fprintf( file, "MIXERLINE_TARGETTYPE_MIDIOUT/n" );
  279.         break;
  280.       case MIXERLINE_TARGETTYPE_MIDIIN:
  281.         fprintf( file, "MIXERLINE_TARGETTYPE_MIDIIN/n" );
  282.         break;
  283.       case MIXERLINE_TARGETTYPE_AUX:
  284.         fprintf( file, "MIXERLINE_TARGETTYPE_AUX/n" );
  285.         break;
  286.       default:
  287.         fprintf( file, "/n" );
  288.         break;
  289.     }
  290.     fprintf( file,  "%s     Target name: %s/n", tabs, line.Target.szPname );
  291.     fprintf( file,  "%s     Manufacturer and product IDs: %u -- %u (see mmreg.h or help subject: /"Manufacturer and Product Identifiers/")/n/n", tabs, line.Target.wMid , line.Target.wPid );
  292.   }
  293.   if( line.dwComponentType > MIXERLINE_COMPONENTTYPE_DST_FIRST && line.dwComponentType <= MIXERLINE_COMPONENTTYPE_DST_LAST )
  294.   {
  295.     fprintf( file,  "%s Number of source lines associated with destination line: %lu/n", tabs, line.cConnections );
  296.   }
  297.   fprintf( file,  "%s Number of channels: %lu/n", tabs, line.cChannels );
  298.   fprintf( file,  "%s Number of controls: %lu/n", tabs, line.cControls );
  299.   if( line.cControls > 0 )
  300.     fprintf( file,  "%s List of controls follows:/n", tabs );
  301. }
  302. //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
  303. LPCTSTR GetControlTypeString( DWORD type )
  304. //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
  305. {
  306.   switch( type )
  307.   {
  308.     case MIXERCONTROL_CONTROLTYPE_CUSTOM:
  309.       return (  "MIXERCONTROL_CONTROLTYPE_CUSTOM" );
  310.     case MIXERCONTROL_CONTROLTYPE_BOOLEANMETER:
  311.       return (  "MIXERCONTROL_CONTROLTYPE_BOOLEANMETER" );
  312.     case MIXERCONTROL_CONTROLTYPE_SIGNEDMETER:
  313.       return (  "MIXERCONTROL_CONTROLTYPE_SIGNEDMETER" );
  314.     case MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER:
  315.       return (  "MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER" );
  316.     case MIXERCONTROL_CONTROLTYPE_PEAKMETER:
  317.       return (  "MIXERCONTROL_CONTROLTYPE_PEAKMETER" );
  318.     case MIXERCONTROL_CONTROLTYPE_BOOLEAN:
  319.       return (  "MIXERCONTROL_CONTROLTYPE_BOOLEAN" );
  320.     case MIXERCONTROL_CONTROLTYPE_ONOFF:
  321.       return (  "MIXERCONTROL_CONTROLTYPE_ONOFF" );
  322.     case MIXERCONTROL_CONTROLTYPE_MUTE:
  323.       return (  "MIXERCONTROL_CONTROLTYPE_MUTE" );
  324.     case MIXERCONTROL_CONTROLTYPE_MONO:
  325.       return (  "MIXERCONTROL_CONTROLTYPE_MONO" );
  326.     case MIXERCONTROL_CONTROLTYPE_LOUDNESS:
  327.       return (  "MIXERCONTROL_CONTROLTYPE_LOUDNESS" );
  328.     case MIXERCONTROL_CONTROLTYPE_STEREOENH:
  329.       return (  "MIXERCONTROL_CONTROLTYPE_STEREOENH" );
  330.     case MIXERCONTROL_CONTROLTYPE_BUTTON:
  331.       return (  "MIXERCONTROL_CONTROLTYPE_BUTTON" );
  332.     case MIXERCONTROL_CONTROLTYPE_DECIBELS:
  333.       return (  "MIXERCONTROL_CONTROLTYPE_DECIBELS" );
  334.     case MIXERCONTROL_CONTROLTYPE_SIGNED:
  335.       return (  "MIXERCONTROL_CONTROLTYPE_SIGNED" );
  336.     case MIXERCONTROL_CONTROLTYPE_UNSIGNED:
  337.       return (  "MIXERCONTROL_CONTROLTYPE_UNSIGNED" );
  338.     case MIXERCONTROL_CONTROLTYPE_PERCENT:
  339.       return (  "MIXERCONTROL_CONTROLTYPE_PERCENT" );
  340.     case MIXERCONTROL_CONTROLTYPE_SLIDER:
  341.       return (  "MIXERCONTROL_CONTROLTYPE_SLIDER" );
  342.     case MIXERCONTROL_CONTROLTYPE_PAN:
  343.       return (  "MIXERCONTROL_CONTROLTYPE_PAN" );
  344.     case MIXERCONTROL_CONTROLTYPE_QSOUNDPAN:
  345.       return (  "MIXERCONTROL_CONTROLTYPE_QSOUNDPAN" );
  346.     case MIXERCONTROL_CONTROLTYPE_FADER:
  347.       return (  "MIXERCONTROL_CONTROLTYPE_FADER" );
  348.     case MIXERCONTROL_CONTROLTYPE_VOLUME:
  349.       return (  "MIXERCONTROL_CONTROLTYPE_VOLUME" );
  350.     case MIXERCONTROL_CONTROLTYPE_BASS:
  351.       return (  "MIXERCONTROL_CONTROLTYPE_BASS" );
  352.     case MIXERCONTROL_CONTROLTYPE_TREBLE:
  353.       return (  "MIXERCONTROL_CONTROLTYPE_TREBLE" );
  354.     case MIXERCONTROL_CONTROLTYPE_EQUALIZER:
  355.       return (  "MIXERCONTROL_CONTROLTYPE_EQUALIZER" );
  356.     case MIXERCONTROL_CONTROLTYPE_SINGLESELECT:
  357.       return (  "MIXERCONTROL_CONTROLTYPE_SINGLESELECT" );
  358.     case MIXERCONTROL_CONTROLTYPE_MUX:
  359.       return (  "MIXERCONTROL_CONTROLTYPE_MUX" );
  360.     case MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT:
  361.       return (  "MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT" );
  362.     case MIXERCONTROL_CONTROLTYPE_MIXER:
  363.       return (  "MIXERCONTROL_CONTROLTYPE_MIXER" );
  364.     case MIXERCONTROL_CONTROLTYPE_MICROTIME:
  365.       return (  "MIXERCONTROL_CONTROLTYPE_MICROTIME" );
  366.     case MIXERCONTROL_CONTROLTYPE_MILLITIME:
  367.       return (  "MIXERCONTROL_CONTROLTYPE_MILLITIME" );
  368.     default:
  369.       return (  "---- UNKNOWN CONTROL TYPE ----" );
  370.   }
  371. }
  372. LPCTSTR GetLineTypeString( DWORD type )
  373. {
  374.   switch( type )
  375.   {
  376.     case MIXERLINE_COMPONENTTYPE_DST_DIGITAL:
  377.       return ( "MIXERLINE_COMPONENTTYPE_DST_DIGITAL" );
  378.     case MIXERLINE_COMPONENTTYPE_DST_UNDEFINED:
  379.       return ( "MIXERLINE_COMPONENTTYPE_DST_UNDEFINED" );
  380.     case MIXERLINE_COMPONENTTYPE_DST_LINE:
  381.       return ( "MIXERLINE_COMPONENTTYPE_DST_LINE");
  382.     case MIXERLINE_COMPONENTTYPE_DST_MONITOR:
  383.       return ( "MIXERLINE_COMPONENTTYPE_DST_MONITOR");
  384.     case MIXERLINE_COMPONENTTYPE_DST_SPEAKERS:
  385.       return ( "MIXERLINE_COMPONENTTYPE_DST_SPEAKERS");
  386.     case MIXERLINE_COMPONENTTYPE_DST_HEADPHONES:
  387.       return ( "MIXERLINE_COMPONENTTYPE_DST_HEADPHONES");
  388.     case MIXERLINE_COMPONENTTYPE_DST_TELEPHONE:
  389.       return ( "MIXERLINE_COMPONENTTYPE_DST_TELEPHONE");
  390.     case MIXERLINE_COMPONENTTYPE_DST_WAVEIN:
  391.       return ( "MIXERLINE_COMPONENTTYPE_DST_WAVEIN");
  392.     case MIXERLINE_COMPONENTTYPE_DST_VOICEIN:
  393.       return ( "MIXERLINE_COMPONENTTYPE_DST_VOICEIN");
  394.     case MIXERLINE_COMPONENTTYPE_SRC_ANALOG:
  395.       return ( "MIXERLINE_COMPONENTTYPE_SRC_ANALOG");
  396.     case MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY:
  397.       return ( "MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY");
  398.     case MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC:
  399.       return ( "MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC");
  400.     case MIXERLINE_COMPONENTTYPE_SRC_DIGITAL:
  401.       return ( "MIXERLINE_COMPONENTTYPE_SRC_DIGITAL");
  402.     case MIXERLINE_COMPONENTTYPE_SRC_LINE:
  403.       return ( "MIXERLINE_COMPONENTTYPE_SRC_LINE");
  404.     case MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE:
  405.       return ( "MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE");
  406.     case MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER:
  407.       return ( "MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER");
  408.     case MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER:
  409.       return ( "MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER");
  410.     case MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE:
  411.       return ( "MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE");
  412.     case MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED:
  413.       return ( "MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED");
  414.     case MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT:
  415.       return ( "MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT");
  416.     default:
  417.       return (  "---- UNKNOWN LINE TYPE ----" );
  418.   }
  419. }
  420. //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
  421. // Name   : PrintControl
  422. //          
  423. // Descr. : 
  424. //          
  425. // Return : void
  426. // Arg    : HMIXEROBJ mixer       : 
  427. // Arg    : MIXERLINE &line       : 
  428. // Arg    : MIXERCONTROL &control : 
  429. // Arg    : FILE *file            : 
  430. //-----------------------------------------------------------------------------
  431. void PrintControl( HMIXEROBJ mixer, MIXERLINE &line, MIXERCONTROL &control, FILE *file )
  432. {
  433.   char *tabs = "/t/t";
  434.   fprintf( file,  "/n%s   ---------------------------- Control ----------------------------/n", tabs );
  435.   fprintf( file,  "%s     Control type:/t%s/n", tabs, GetControlTypeString(control.dwControlType) );
  436.   fprintf( file,  "%s   -----------------------------------------------------------------/n", tabs );
  437.   fprintf( file,  "%s     Short Name: %s/n", tabs, control.szShortName );
  438.   fprintf( file,  "%s     Name: %s/n", tabs, control.szName );
  439.   switch( control.dwControlType & MIXERCONTROL_CT_UNITS_MASK )
  440.   {
  441.     case MIXERCONTROL_CT_UNITS_UNSIGNED:
  442.     case MIXERCONTROL_CT_UNITS_DECIBELS:
  443.       fprintf( file,  "%s     - Min: %lu/n", tabs, control.Bounds.dwMinimum );
  444.       fprintf( file,  "%s     - Max: %lu/n", tabs, control.Bounds.dwMaximum );
  445.       break;
  446.     case MIXERCONTROL_CT_UNITS_PERCENT:
  447.     case MIXERCONTROL_CT_UNITS_SIGNED:
  448.     case MIXERCONTROL_CT_UNITS_BOOLEAN:
  449.       fprintf( file,  "%s     - Min: %ld/n", tabs, control.Bounds.lMinimum );
  450.       fprintf( file,  "%s     - Max: %ld/n", tabs, control.Bounds.lMaximum );
  451.       break;
  452.     case MIXERCONTROL_CT_UNITS_CUSTOM:
  453.       fprintf( file,  "%s     Custom control/n", tabs );
  454.       break;
  455.     default:
  456.       break;
  457.   }
  458.   fprintf( file,  "%s     - Steps: %lu/n", tabs, control.Metrics.cSteps );
  459.   fprintf( file,  "%s     Status and support flags:/n", tabs);
  460.   if( control.fdwControl & MIXERCONTROL_CONTROLF_UNIFORM )
  461.     fprintf( file,  "%s         - Uniform control/n", tabs );
  462.   if( control.fdwControl & MIXERCONTROL_CONTROLF_DISABLED )
  463.     fprintf( file,  "%s         - Control is disabled/n", tabs );
  464.   if( control.fdwControl & MIXERCONTROL_CONTROLF_MULTIPLE )
  465.     fprintf( file,  "%s         - Multiple control. The control has two or more possible settings./n", tabs );
  466.   fprintf( file,  "%s             Number of items per channel: %d/n", tabs, control.cMultipleItems );
  467.   if( control.cMultipleItems > 0 )
  468.   {
  469.     MIXERCONTROLDETAILS details;
  470.     details.cbStruct       = sizeof( MIXERCONTROLDETAILS );
  471.     details.dwControlID    = control.dwControlID;
  472.     details.cMultipleItems = control.cMultipleItems;
  473.     details.cbDetails      = sizeof( MIXERCONTROLDETAILS_LISTTEXT );
  474.     int listSize;
  475.     if( control.fdwControl & MIXERCONTROL_CONTROLF_UNIFORM )
  476.     {
  477.       details.cChannels = 1;
  478.       listSize = control.cMultipleItems;
  479.     }
  480.     else
  481.     {
  482.       details.cChannels = line.cChannels;
  483.       listSize = control.cMultipleItems*line.cChannels;
  484.     }
  485.     MIXERCONTROLDETAILS_LISTTEXT *list = new MIXERCONTROLDETAILS_LISTTEXT[listSize];
  486.     details.paDetails = list;
  487.     if( mixerGetControlDetails( mixer, &details, 
  488.       MIXER_GETCONTROLDETAILSF_LISTTEXT ) != MMSYSERR_NOERROR )
  489.     {
  490.       TRACE( "mixerGetControlDetails failed/n" );
  491.       delete[] list;
  492.       return;
  493.     }
  494.     for ( int i = 0; i < listSize; i++ )
  495.     {
  496.       fprintf( file,  "%s              -------------- Item %d -------------/n", tabs, i );
  497.       fprintf( file,  "%s              Name: %s/n", tabs, list[i].szName );
  498.     }
  499.     delete[] list;
  500.   }
  501. }
  502. //mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
  503. // Name   : GetDevicesInfo
  504. //          
  505. // Descr. : Finds all the input and output lines, and all mixer controls
  506. //          available through the audio mixer device.
  507. //
  508. //          Use GetDevicesInfo() to find out the capabilities of your sound card.
  509. //          Check the the file and note the type and number of destination (output)
  510. //          lines, as well as the source (input) lines associated with every
  511. //          destination line. Note also the type of the controls available.
  512. //          You will need these to create your windows controls.
  513. //          
  514. // Return : void
  515. // Arg    : LPCSTR filename : 
  516. //-----------------------------------------------------------------------------
  517. void GetDevicesInfo( LPCSTR filename )
  518. {
  519.   FILE *file;
  520.   UINT nbMixers = mixerGetNumDevs();
  521.   if( nbMixers < 1 )
  522.   {
  523.     AfxMessageBox( "No mixer device present" );
  524.     return;
  525.   }
  526.   file = fopen( filename, "w" );
  527.   if( file == NULL )
  528.   {
  529.     AfxMessageBox("Could not open file.");
  530.     return;
  531.   }
  532.   HMIXER hMixer;
  533.   if( mixerOpen( &hMixer, 0, 0, 0, 0 ) != MMSYSERR_NOERROR )
  534.   {
  535.     AfxMessageBox( "Could not open mixer device" );
  536.     return;
  537.   }
  538.   MIXERCAPS caps;
  539.   if( mixerGetDevCaps( ( UINT )hMixer, &caps, sizeof( MIXERCAPS ) ) != MMSYSERR_NOERROR )
  540.   {
  541.     fclose( file );
  542.     mixerClose(hMixer);
  543.     return;
  544.   }
  545.   fprintf( file, "Name of device: %s/n", caps.szPname );
  546.   fprintf( file, "Number of destination lines: %d/n/n", caps.cDestinations );
  547.   fprintf( file, "/nPay particular attention to the /"Line type/" and /"Control type/" lines./n"
  548.     "You will pass these to the Init() functions of the various CMixerBase-derived classes/n"
  549.     "to specify which type of control you want to use./n");
  550.   MIXERLINE line;
  551.   MIXERLINECONTROLS   mixerLineControl;
  552.   MIXERCONTROL        *pMixerControl;
  553.   int nDest = caps.cDestinations;
  554.   forint i = 0; i < nDest; i++ )
  555.   {
  556.     line.cbStruct = sizeof( MIXERLINE );
  557.     line.dwSource = 0;
  558.     line.dwDestination = i;
  559.     mixerGetLineInfo( ( HMIXEROBJ )hMixer, &line, MIXER_GETLINEINFOF_DESTINATION );
  560.     fprintf( file, "/n***************************************************************************************************/n");
  561.     fprintf( file, "** Destination line. Index = %d  *******************************************************************/n", i );
  562.     fprintf( file, "***************************************************************************************************/n");
  563.     PrintLineType( 0, line, file );
  564.     pMixerControl = new MIXERCONTROL[line.cControls];
  565.     ASSERT( pMixerControl != NULL );
  566.     mixerLineControl.cbStruct  = sizeof( MIXERLINECONTROLS );
  567.     mixerLineControl.dwLineID  = line.dwLineID;
  568.     mixerLineControl.cControls = line.cControls;
  569.     mixerLineControl.cbmxctrl  = sizeof( MIXERCONTROL );
  570.     mixerLineControl.pamxctrl  = pMixerControl;
  571.     mixerGetLineControls( ( HMIXEROBJ )hMixer, &mixerLineControl, MIXER_GETLINECONTROLSF_ALL );
  572.     UINT ncontrols = line.cControls;
  573.     for( UINT k = 0; k < ncontrols; k++ )
  574.     {
  575.       PrintControl( ( HMIXEROBJ )hMixer, line, pMixerControl[k], file );
  576.     }
  577.     delete[] pMixerControl;
  578.     // for each destination line, list the source lines and their controls
  579.     UINT nconn = line.cConnections;
  580.     for( UINT j = 0; j < nconn; j++ )
  581.     {
  582.       line.cbStruct = sizeof( MIXERLINE );
  583.       line.dwSource = j;
  584.       line.dwDestination = i;
  585.       mixerGetLineInfo( ( HMIXEROBJ )hMixer, &line, MIXER_GETLINEINFOF_SOURCE );
  586.       fprintf( file,  "/n/t======================================================================================/n");
  587.       fprintf( file,  "/t== Source line. Index = %d ===========================================================/n", j );
  588.       fprintf( file,  "/t======================================================================================/n");
  589.       PrintLineType( 1, line, file );
  590.       pMixerControl = new MIXERCONTROL[line.cControls];
  591.       ASSERT( pMixerControl != NULL );
  592.       mixerLineControl.cbStruct  = sizeof( MIXERLINECONTROLS );
  593.       mixerLineControl.dwLineID  = line.dwLineID;
  594.       mixerLineControl.cControls = line.cControls;
  595.       mixerLineControl.cbmxctrl  = sizeof( MIXERCONTROL );
  596.       mixerLineControl.pamxctrl  = pMixerControl;
  597.       mixerGetLineControls( ( HMIXEROBJ )hMixer, &mixerLineControl, MIXER_GETLINECONTROLSF_ALL );
  598.       UINT ncontrols = line.cControls;
  599.       for( UINT k = 0; k < ncontrols; k++ )
  600.       {
  601.         PrintControl( ( HMIXEROBJ )hMixer, line, pMixerControl[k], file );
  602.       }
  603.       delete[] pMixerControl;
  604.     }
  605.   }
  606.   fclose( file );
  607.   mixerClose(hMixer);
  608. }
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值