混音器原理及Mixer API函数介绍1

为了理解Mixer API是如何工作的,首先我们得弄清楚一个典型声卡的硬件组成。因此非常有必要去建立一个声卡模型,此声卡应拥有多个典型的组件并且这些组件都是相关联的。

让我们看一个典型的、最基本的声卡。首先,如果声卡能够进行数字化录音,那么典型情况下它就有一个Microphone Input(麦克风传声器,下同)(附有某种前置放大器),同时它还有一个ADC(模数转换器,下同)将麦克风输入的模拟信号转换为数字信号,因此,它就有两个组件——Microphone InputADC。从Microphone Input组件输入的信号输送到ADC。我们可以使用以下的方块图来表示这两个组件,并表明信号在这两个组件之间的传输关系(通过箭头表示)。

                                  混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客

一个典型的声卡应该还可以回放数字声音,因此它有一个DAC(数模转换器,下同)组件将数字信号转换回模拟信号,同时它还应有一个Speaker Out(扬声器,下同)(附有某种模拟信号放大器)。因此,它又添加了两个组件——DACSpeaker Out。从DAC输出的信号输送到Speaker Out中。

混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客

一个典型的声卡或许还有其它组件。例如,它或许有一个能播放MIDI音频的内置声音模块(比如Synth(合成器,下同))。这个组件的声音输出同DAC的输出同样输入到Speaker Out组件中。因此,我们的方框图现在是如下的样子:

混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客

同样的,一个典型的声卡还有一个内部的连接器连接着计算机的CDROM驱动器的声音输出(这样就可以通过扬声器来播放CDROM里的CD)。与SynthDAC一样,这个组件的输出会输入到Speaker Out。现在,我们的方块图就成了如下的样子:

混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客

最后,我们假设这个声卡还有一个Line In(线路输入,下同)组件,因此其它外部的录音机或音频设备或外部的硬件混音器就能够连接到此插孔并将其输入信号数字化。同Microphone Input组件一样,这个组件的输出会输送到ADC组件。下面是我们最终的方块图,其中包括7个组件(和5个信号流向线图——也就是将各个组件相连的箭头线)

混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客

典型情况下,每个组件都有它自己的参数。例如,Synth通常会有它的音量参数。Internal CD Audio同样有它自己的音量参数。DAC也会有它自己的音量参数。在这种方式下,如果用户同时播放一个Audio CD、一个MIDI文件和一个WAVE文件,他可以分别调整这三个组件输入到Speaker Out的音量。同样的,Speaker Out组件也有它自己的音量参数——控制上述3个输入组件最终输出的主音量。

同样的,Line InMicrophone Input组件也都有各自的音量参数,这样在同时录音的情况下,就可以平衡二者的输入。ADC组件有个主音量参数,它控制着上述2个连接到它的输入组件的录音音量。

一个给定的组件还拥有其它可控的参数。例如,上述每个组件都有各自的用于快速打开或关闭声音的静音(Mute)开关。

混音器设备

系统中每个声卡都有一个与其相连的混音器设备。声卡上所有的组件都由与声卡关联的混音器设备控制。Windows Mixer API就是用来访问声卡的混音器设备的一组函数。Mixer API有一组函数,可以获取声卡上所有的组件并调整它们的参数。这是Win95/98WinNT (4.X 及以上版本)新增的一组API,虽然加入到windows 3.1及更早的版本中也可以使用。

注意:有些声卡的设备驱动需要额外的支持才可以协同Mixer API工作。不是所有的Win95WinNT驱动都支持Mixer API操作。Win3.1驱动不支持Mixer API操作。

在一个计算机中,可能安装有一个以上声卡。你或许已经注意到windows在系统中维护了一组WAVEMIDI 输入输出的设备列表。既然每个已安装的声卡都有其对应的混音器设备(只要声卡的驱动支持),windows同样也就维护了一组已安装在系统中的混音器设备。例如,如果你有在系统中安装了两块声卡,那么系统中就应该有两个混音器设备(假设两个声卡的驱动都支持Mixer API)。

       WAVEMIDI输入输出设备一样,windows也会给每个混音器设备赋一个数值ID。因此,系统中的第一个(默认)混音器设备的ID号为0。如果系统中有第二个声卡,那么就有一个ID1的混音器设备。

打开一个混音器设备

怎样在你的程序中选择一个混音器设备来进行操作?这里有很多种方法,具体要看你想做多炫、多灵活的程序了。

如果你只是想简单的打开首选的混音器设备,那么您可以使用mixerOpen函数,并使设备ID0,如下:

unsigned long err;  
HMIXER        mixerHandle;    
/* Open the mixer associated with the default     Audio/MIDI card in the computer */  err = mixerOpen(&mixerHandle, 0, 0, 0, 0);  
if (err)  
{      printf("ERROR: Can't open Mixer Device! -- %08X\n", err);  }  
else  
{      
/* The mixer device is now open, and its        handle is in the variable 'mixerHandle'.        You may now use it with other Mixer API        functions */  
}  
     当然,如果没有安装混音器,上述调用将会返回一个错误值,因此要始终检查那个返回值。(调用Mixer API返回的预期错误值已列在头文件MMSYSTEM.H中。不幸的是,不像其它WAVEMIDI那些更低级的API,这里没有将这些错误值代码转换为描述字符串的API函数)。
     但是,什么是首选混音器设备?好,让我来告诉你,那就是第一个安装在系统中的混音器设备。如果系统中只有一个声卡,那么你得到的混音器设备肯定就是首选混音器设备。但是,如果你尝试着去使用第二块声卡上的Wave Output组件,那该怎么做?你肯定不希望使用第一块声卡的混音器设备去控制第二块声卡上的Wave Out组件的音量。(第一块声卡的混音器当然控制不了第二块声卡的Wave Output组件了)。
     但是,你怎样打开与你想要的那块声卡关联的混音器?幸运的是,mixerOpen()函数允许你传递与这个声卡关联的其它设备的ID或句柄来打开混音器。在这种情况下,mixerOpen()函数将会准确无疑的返回与那个声卡的其它设备关联的混音器设备。以下是一个样例程序,展示了如何通过打开默认的WAVE OUT设备(默认声卡上的WAVE OUT设备)获取混音器设备的句柄:
unsigned long err;  
HMIXER        mixerHandle;  
WAVEFORMATEX  waveFormat;  
HWAVEOUT      hWaveOut;    
/* Open the default WAVE Out Device, specifying my callback.     Assume that waveFormat has already been initialized as desired */ 
err = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, (DWORD)WaveOutProc, 0, CALLBACK_FUNCTION);  
if (err)  
{      
	printf("ERROR: Can't open WAVE Out Device! -- %08X\n", err);  
} 
else  
{/* Open the mixer associated with the WAVE OUT device         opened above. Note that I pass the handle obtained         via waveOutOpen() above */      
	err = mixerOpen(&mixerHandle, hWaveOut, 0, 0, MIXER_OBJECTF_HWAVEOUT);      
	if (err)     
	{    printf("ERROR: Can't open Mixer Device! -- %08X\n", err);      }  
}  
上述代码的关键不仅仅是传递waveOutOpen()(或者waveInOpen(), 或者midiOutOpen(),或者midiInOpen())返回的句柄,同样要注意的是mixerOpen()的最后一个参数必须是MIXER_OBJECTF_HWAVEOUT (或者MIXER_OBJECTF_HWAVEIN,或者MIXER_OBJECTF_HMIDIOUT, 或者MIXER_OBJECTF_HMIDIIN),用于指明传递的是哪一类设备句柄。
   如果你知道你想要打开的WAVE OUT设备的ID(但是还未通过waveOutOpen()获取它的句柄),你可以传递这个ID并在mixerOpen的最后一个参数中指定MIXER_OBJECTF_WAVEOUTmixerOpen()将会找到与这个ID关联的混音器。
   你可以通过混音器的句柄获取它的ID,按如下方式使用mixerGetID()
unsigned long mixerID;    
err = mixerGetID(mixerHandle, &mixerID, MIXER_OBJECTF_HMIXER);  
if (err)  
{      printf("ERROR: Can't get Mixer Device ID! -- %08X\n", err);  }  
else  
{      printf("Mixer Device ID = %d\n", mixerID);  }  
列举所有的混音器设备

如果你想写一个能列举系统中所有混音器的程序,windows有一个函数可以确定列表中有多少个混音器,这个函数就是mixerGetNumDevs()。它返回系统中混音器的个数。切记设备ID是从0开始并以1递增。因此,如果windows显示列表中有3个混音器,那么你就应该知道它们的ID分别是012。然后你可以将这些ID用于其他windows函数中。例如,这里有一个函数可以用来获取列表中的设备信息,包括它的名称和其它特征——比如它包含多少个组件及每个组件的类型,等等。你可以传递你想获取信息的混音器设备ID(和一个指向类型为MIXERCAPS的结构体的指针,windows将设备信息填入此结构体),然后调用获取混音器设备信息的函数mixerGetDevCaps()

如下样例程序遍历混音器列表,并打印出每个设备名:

MIXERCAPS     mixcaps;  
unsigned long iNumDevs, i;    /* Get the number of Mixer devices in this computer */  iNumDevs = mixerGetNumDevs();    /* Go through all of those devices, displaying their IDs/names */  
for (i = 0; i < iNumDevs; i++)  
{      /* Get info about the next device */      
	if (!mixerGetDevCaps(i, &mixcaps, sizeof(MIXERCAPS)))      
	{          /* Display its ID number and name */          
		printf("Device ID #%u: %s\r\n", i, mixcaps.szPname);      
	}  	
}  
线路和控件

我已经使用了术语“组件”来描述一个具有独立并可调整参数的硬件模块,Mixer API实际上通过信号流来工作。(在我们的方块图中,信号流是那5个连接各个组件的箭头)微软官方文档将每个信号流(就是方块图中的每个箭头)称为一个“源线路”,因此,一个混音器设备控制着“源线路”,而不是组件本身。每个“源线路”有它独立的、可调整的参数——而不是每个组件本身拥有。我们的示例声卡关联的混音器有5个源线路,从此,只要你看到“源线路”,就将它想象为组件之间的信号流。

例如,实际上不是Microphone Input组件与Mixer API相关联,而是Microphone Input组件和ADC组件之间的信号流与Mixer API关联。Microphone Input音量控件调整着Microphone Input组件和ADC组件间的信号流的音量。

为了更进一步说明“组件”和“源线路”之间的差别,我们再添加一个功能到我们的样例声卡中。有时,你或许希望Microphone Input组件输入的信号不仅仅能够输送到ADC(因此你可以录音),还可以输送到Speaker Out组件中(这样你就可以监视你正在录制的信号,通过Speaker Out组件能够听到它是个什么样子),因此,我们添加一个方块图来展示信号从Microphone Input组件同时输送到ADC组件和Speaker Out组件。

混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客混音器原理及Mixer API函数介绍1 - 我,猪八戒 - 我,猪八戒的博客

注意我们现在已经有了6条源线路。有两个源线路引出自Microphone Input组件,即使它只是我们声卡上的一个组件。每个源线路都有它自己的设置。例如,

Microphone InputADC间的源线路上有一个音量控件(这样你就可以设置录音音量)。在Microphone InputSpeaker Out间的源线路上还有一个单独的音量控件(这样你就可以设置Microphone Input组件的监控音量,与录音音量分离开来)。这些源线路还可以有各自的静音开关(因此你可以让Microphone Input的信号仅仅输送到ADC,而不输送到Speaker Out)。它们还可以拥有其它的控件,并且每个源线路的控件都和其它线路的控件相分离。

       这里还要讨论另外一个和线路相关的重要概念。这里有一些名为“目标线路”的东西,我们要区分源线路和目标线路。它们是些什么东西?哦,一个目标线路有其它的线路——源线路——流向它。在我们的方块图中,Speaker Out是一个目标线路,因为来自“Internal CD Audio”、“Synth”、“DAC Wave Out”和“Microphone Input”的信号会输送到它里面,后4个是源线路。他们是目标线路Speaker Out的源线路,因为他们的信号流都输送到了Speaker Out线路。源线路的信号总是输送到目标线路(注:不存在一个没有与目标线路关联的源线路)。

       因此,源线路就是我们方块图中的箭头,目标线路就是方块图中的实际组件。

       同理,ADC Wave Input是我们样例声卡中的一个目标线路。它有两个源线路——“Microphone Input”和“Line In”。那两条线路不是Speaker Out的源线路,因为它们不流向Speaker Out。同样地,流向Speaker Out4根源线路也不是目标线路ADC Wave Input的源线路,因为它们不流向后者。

       同源线路一样,目标线路也有控件,并且每个目标线路的控件和其它线路的控件是分离的。例如,Speaker Out可以有一个音量控件。它可以作为一个主音量控件控制其它4条流向Speaker Out的源线路的音量。(这四个源线路都有它自己的音量控件)。

       注意:虽然一个声卡可以有一个立体声组件(例如,大部分声卡上的Speaker Out组件一般都是立体声),但是还是被当作一条线路。它有两个声道,但是在混音器中它还是一条线路。实际上,一个组件可以拥有2个以上的声道,但仍然被当作一条线路。总之,线路同声道是不同的东西。在有些情况下,你可以将一条线路想象成一路MIDI。一路MIDI连接着两个组件,但是可以有多个声道同时通过这路MIDI。这个情况与线路一样。

       总之,我们的样例声卡有6个源线路和2个目标线路。4个标为“Internal CD Audio”、“Synth”、“DAC Wave Out”和“Microphone Input”的源线路连接到Speaker Out目标线路。2个标为“Microphone Input”和“Line In”的源线路连接到ADC Wave Input目标线路。

线路ID和类型

混音器中的每个线路必须有一个唯一的ID。每个线路还有一个类型值。这仅仅是一个描述线路类型的数值。这些都定义在头文件MMSYSTEM.H中。例如,一个类型值为MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER的线路表明它是来自内部声音模块的信号。

可用的源线路类型值如下:

MIXERLINE_COMPONENTTYPE_SRC_DIGITAL

A digital source, for example, a SPDIF input jack.

MIXERLINE_COMPONENTTYPE_SRC_LINE

A line input source. Typically used for a line input jack, if there is a separate microphone input (ie, MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE).

MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE

Microphone input (but also used for a combination of Mic/Line input if there isn't a separate line input source).

MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER

Musical synth. Typically used for a card that contains a synth capable of playing MIDI. This would be the audio out of that built-in synth.

MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC

The audio feed from an internal CDROM drive (connected to the sound card).

MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE

Typically used for a telephone line's incoming audio to be piped through the computer's speakers, or the telephone line in jack for a built-in modem.

MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER

Typically, to allow sound, that normally goes to the computer's built-in speaker, to instead be routed through the card's speaker output. The motherboard's system speaker connector would be internally connected to some connector on the sound card for this purpose.

MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT

Wave playback (ie, this is the card's DAC).

MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY

An aux jack meant to be routed to the Speaker Out, or to the ADC (for WAVE recording). Typically, this is used to connect external, analog equipment (such as tape decks, the audio outputs of musical instruments, etc) for digitalizing or playback through the sound card.

MIXERLINE_COMPONENTTYPE_SRC_ANALOG

May be used similiarly to MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY (although I have seen some mixers use this like MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER). In general, this would be some analog connector on the sound card which is only accessible internally, to be used to internally connect some analog component inside of the computer case so that it plays through the speaker out.

MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED

Undefined type of source. If none of the others above are applicable.

可用的目标线路类型值如下:

MIXERLINE_COMPONENTTYPE_DST_DIGITAL

A digital destination, for example, a SPDIF output jack.

MIXERLINE_COMPONENTTYPE_DST_LINE

A line output destination. Typically used for a line output jack, if there is a separate speaker output (ie, MIXERLINE_COMPONENTTYPE_DST_SPEAKERS).

MIXERLINE_COMPONENTTYPE_DST_MONITOR

Typically a "Monitor Out" jack to be used for a speaker system separate from the main speaker out. Or, it could be some built-in monitor speaker on the sound card itself, such as a speaker for a built-in modem.

MIXERLINE_COMPONENTTYPE_DST_SPEAKERS

The audio output to a pair of speakers (ie, the Speaker Out jack).

MIXERLINE_COMPONENTTYPE_DST_HEADPHONES

Typically, a headphone output jack.

MIXERLINE_COMPONENTTYPE_DST_TELEPHONE

Typically used to daisy-chain a telephone to an analog modem's "telephone out" jack.

MIXERLINE_COMPONENTTYPE_DST_WAVEIN

The card's ADC (to digitize analog sources, for example, in recording WAVE files of such).

MIXERLINE_COMPONENTTYPE_DST_VOICEIN

May be some sort of hardware used for voice recognition. Typically, a microphone source line would be attached to this.

MIXERLINE_COMPONENTTYPE_DST_UNDEFINED

Undefined type of destination. If none of the others above are applicable.

控件ID和类型

       每个线路都有一个或多个可调整的“声音控件”。(但是,一个线路也可能连一个控件都没有)。例如,“Synth”线路可以有一个音量控件和一个静音开关。每个控件都有一个类型值。这些都在MMSYSTEM.H中定义。例如:

音量控件的类型为MIXERCONTROL_CONTROLTYPE_VOLUME

静音控件的类型为MIXERCONTROL_CONTROLTYPE_MUTE

每个控件都有它自己唯一的ID,任何两个控件都不会有相同的ID,即使它们属于不同的线路。

控件类型被分为几个种类。这些种类是大略的根据控件所调整的值的类型来划分,因此它基本决定了你提供什么样的图形界面给用户来调整控件的值。例如,你可以提供一个滑动条给用户调整类型为MIXERCONTROL_CONTROLTYPE_VOLUME的控件的值。另外一方面,你可以提供一个图形按钮(代码标记)给用户调整类型为MIXERCONTROL_CONTROLTYPE_MUTE的控件的值(因为那个控件只有两个可能的值或状态)。

可用的控件类的值如下:

MIXERCONTROL_CT_CLASS_FADER

A control that is adjusted by a vertical fader, with a linear scale of positive values (ie, 0 is the lowest possible value). A MIXERCONTROLDETAILS_UNSIGNED structure is used to retrieve or set the control's value.

MIXERCONTROL_CT_CLASS_LIST

A control that is adjusted by a listbox containing numerous "values" to be selected. The user will single-select, or perhaps multiple-select if desired, his choice of value(s). A MIXERCONTROLDETAILS_BOOLEAN structure is used to retrieve or set the control's value. A MIXERCONTROLDETAILS_LISTTEXT structure is also used to retrieve the text description of each item of this control.

MIXERCONTROL_CT_CLASS_METER

A control that is adjusted by a graphical meter. A MIXERCONTROLDETAILS_BOOLEAN, MIXERCONTROLDETAILS_SIGNED, or MIXERCONTROLDETAILS_UNSIGNED structure is used to retrieve or set the control's value.

MIXERCONTROL_CT_CLASS_NUMBER

A control that is adjusted by numeric entry. The user enters a signed integer, unsigned integer, or integer decibel value. A MIXERCONTROLDETAILS_SIGNED or MIXERCONTROLDETAILS_UNSIGNED structure is used to retrieve or set the control's value.

MIXERCONTROL_CT_CLASS_SLIDER

A control that is adjusted by a horizontal slider with a linear scale of negative and positive values. (ie, Generally, 0 is the mid or "neutral" point). A MIXERCONTROLDETAILS_SIGNED structure is used to retrieve or set the control's value.

MIXERCONTROL_CT_CLASS_SWITCH

A control that is has only two states (ie, values), and is therefore adjusted via a button. A MIXERCONTROLDETAILS_BOOLEAN structure is used to retrieve or set the control's value.

MIXERCONTROL_CT_CLASS_TIME

A control that allows the user to enter a time value, such as Reverb Decay Time. It is a positive, integer value.

MIXERCONTROL_CT_CLASS_CUSTOM

A custom class of control. If none of the others above are applicable.

每个类都有特定的类型值与其关联,例如MIXERCONTROL_CT_CLASS_FADER 种类有以下5个值与其关联:

MIXERCONTROL_CONTROLTYPE_VOLUME

Volume fader. The range of allowable values is 0 through 65,535.

MIXERCONTROL_CONTROLTYPE_BASS

Bass boost fader. The range of allowable values is 0 through 65,535.

MIXERCONTROL_CONTROLTYPE_TREBLE

Treble boost fader. The range of allowable values is 0 through 65,535.

MIXERCONTROL_CONTROLTYPE_EQUALIZER

A graphic EQ. The range of allowable values for each band is 0 through 65,535. A MIXERCONTROLDETAILS_LISTTEXT structure is used to retrieve the text label for each band of the EQ. Typically, this control will also have its MIXERCONTROL_CONTROLF_MULTIPLE flag set, since the EQ will likely have numerous bands.

MIXERCONTROL_CONTROLTYPE_FADER

A generic fader, to be used when none of the above are applicable. The range of allowable values is 0 through 65,535.

实际上,如果你看一下MMSYSTEM.H,你就会发现类型

MIXERCONTROL_CONTROLTYPE_VOLUME的控件被定义为

MIXERCONTROL_CT_CLASS_FADER | MIXERCONTROL_CT_UNITS_UNSIGNED + 1

种类的值实际上包含在类型的高4位中。因此,如果你知道一个控件的类型,你就可以通过此类型值的高4位确定它的种类。例如,假设你已查询了一个控件的类型,并且将Mixer API返回的值保存在名为“type”的变量中,如下是你确定它的种类的代码:

unsigned long   type;    /* Figure out the class based upon the top 4 bits of its type */  switch (MIXERCONTROL_CT_CLASS_MASK & type)  
{ 
case MIXERCONTROL_CT_CLASS_FADER:      
{     printf("It's a fader class.");    break;   }      
case MIXERCONTROL_CT_CLASS_LIST:      
{     printf("It's a list class.");     break;   }      
case MIXERCONTROL_CT_CLASS_METER:      
{     printf("It's a meter class.");    break;   }      
case MIXERCONTROL_CT_CLASS_NUMBER:      
{     printf("It's a number class.");   break;   }      
case MIXERCONTROL_CT_CLASS_SLIDER:      
{     printf("It's a slider class.");   break;   }      
case MIXERCONTROL_CT_CLASS_TIME:      
{     printf("It's a time class.");     break;   }      
case MIXERCONTROL_CT_CLASS_CUSTOM:      
{     printf("It's a custom class.");   break;   } 
}  

种类MIXERCONTROL_CT_CLASS_SWITCH有以下7个类型与其相关联:

MIXERCONTROL_CONTROLTYPE_BOOLEAN

A control with a boolean value. The value is an integer that is either 0 (FALSE) or non-zero (TRUE).

MIXERCONTROL_CONTROLTYPE_BUTTON

A control whose value is 1 when the button is pressed (ie, some feature/action is enabled), or 0 if not pressed (ie, no action is taken). For example, this type of control may be used by a talkback button or pedal sustain -- the action/feature is on only while the button is pressed, and otherwise is not applicable.

MIXERCONTROL_CONTROLTYPE_LOUDNESS

A control whose value is 1 to boost bass frequencies, or 0 for normal (ie, no boost). (A MIXERCONTROL_CONTROLTYPE_BASS fader control may be used to set the actual amount of boost, in conjunction with this control turning the boost on/off)

MIXERCONTROL_CONTROLTYPE_MONO

A control whose value is 1 for mono operation (ie, all channels are summed into one), or 0 for normal (ie, stereo or multi-channel).

MIXERCONTROL_CONTROLTYPE_MUTE

A control whose value is 1 to mute some feature, or 0 for normal (ie, no mute).

MIXERCONTROL_CONTROLTYPE_ONOFF

A control whose value is 1 to enable some feature/action, or 0 to disable that feature/action. The difference between this and MIXERCONTROL_CONTROLTYPE_BUTTON is that the latter's 0 value doesn't disable the feature/action per se, but rather, simply represents a "not applicable" state for the feature/action. MIXERCONTROL_CONTROLTYPE_ONOFF would be similiar to a real on/off switch (ie, a checkmark button in Windows parlance) whereas MIXERCONTROL_CONTROLTYPE_BUTTON would be more akin to a "momentary switch" (ie, a pushbutton). The difference between MIXERCONTROL_CONTROLTYPE_ONOFF and MIXERCONTROL_CONTROLTYPE_BOOLEAN is merely the labeling/grahics that would be shown on the user interface. The former is "ON" when its value is 1. The latter is "TRUE" when its value is 1. So typically, the two buttons would be represented by different labels and/or graphics to reflect that difference in semantics.

MIXERCONTROL_CONTROLTYPE_STEREOENH

A control whose value is 1 to enable a stereo enhance feature (ie, increase stereo separation), or 0 for normal (ie, no enhance).

种类MIXERCONTROL_CT_CLASS_LIST 有以下4个类型与其关联:

MIXERCONTROL_CONTROLTYPE_SINGLESELECT

Allows one selection out of a choice of many selections. For example, this can be used to select a reverb type out of choice of many types (ie, Hall, Plate, Room, etc).

MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT

Like MIXERCONTROL_CONTROLTYPE_SINGLESELECT, but allows the selection of more than one item simultaneously.

MIXERCONTROL_CONTROLTYPE_MUX

Allows the selection of one audio line out of several choices of audio lines. For example, to allow a source line to be routed to one of several possible destination lines -- this control could list all of the possible choices of destination lines, and allow one to be chosen.

MIXERCONTROL_CONTROLTYPE_MIXER

Like MIXERCONTROL_CONTROLTYPE_MUX, but allows the selection of more than one audio line simultaneously. For example, this control could be for a reverb component which allows several source lines to be simultaneously routed to it, and this control determines which source lines are selected for routing to the reverb.

种类MIXERCONTROL_CT_CLASS_METER有以下4个类型与其关联:

MIXERCONTROL_CONTROLTYPE_BOOLEANMETER

A meter whose integer value is either 0 (ie, FALSE) or non-zero (TRUE). A MIXERCONTROLDETAILS_BOOLEAN struct is used to set/retrieve its value.

MIXERCONTROL_CONTROLTYPE_PEAKMETER

A control with a value that is an integer whose allowable, maximum range is -32,768 (lowest) through 32,767 (highest). In other words, its value is a SHORT. A MIXERCONTROLDETAILS_SIGNED struct is used to set/retrieve its value.

MIXERCONTROL_CONTROLTYPE_SIGNEDMETER

A control with a value that is an integer whose allowable, maximum range is -2,147,483,648 (lowest) through 2,147,483,647 (highest) inclusive. In other words, its value is a LONG. A MIXERCONTROLDETAILS_SIGNED struct is used to set/retrieve its value.

MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER

Like MIXERCONTROL_CONTROLTYPE_SIGNEDMETER, but its allowable, maximum value range is from 0 (lowest) to 4,294,967,295. In other words, its value is a ULONG. A MIXERCONTROLDETAILS_UNSIGNED struct is used to set/retrieve its value.

种类MIXERCONTROL_CT_CLASS_NUMBER关联的部分类型与种类MIXERCONTROL_CT_CLASS_METER关联的部分类型相似。

对于种类为MIXERCONTROL_CT_CLASS_NUMBER的控件你可以提供一个 Edit控件供用户输入一个数值。而对于种类为MIXERCONTROL_CT_CLASS_METER的控件,你可以提供一个类似于某种声音仪表的控件。

种类MIXERCONTROL_CT_CLASS_NUMBER有以下4个类型与其关联:

MIXERCONTROL_CONTROLTYPE_SIGNED

A control with a value that is an integer whose allowable, maximum range is -2,147,483,648 (lowest) through 2,147,483,647 (highest) inclusive. In other words, its value is a LONG. A MIXERCONTROLDETAILS_SIGNED struct is used to set/retrieve its value.

MIXERCONTROL_CONTROLTYPE_UNSIGNED

Like MIXERCONTROL_CONTROLTYPE_SIGNEDMETER, but its allowable, maximum value range is from 0 (lowest) to 4,294,967,295. In other words, its value is a ULONG. A MIXERCONTROLDETAILS_UNSIGNED struct is used to set/retrieve its value.

MIXERCONTROL_CONTROLTYPE_PERCENT

A control whose integer value is a percent. A MIXERCONTROLDETAILS_UNSIGNED struct is used to set/retrieve its value.

MIXERCONTROL_CONTROLTYPE_DECIBELS

A control with a value that is an integer whose allowable, maximum range is -32,768 (lowest) through 32,767 (highest). In other words, its value is a SHORT. Each increment is a tenth of a decibel. A MIXERCONTROLDETAILS_SIGNED struct is used to set/retrieve its value.

种类MIXERCONTROL_CT_CLASS_SLIDER有以下3个类型与其关联:

MIXERCONTROL_CONTROLTYPE_SLIDER

A slider with a value that is an integer whose allowable, maximum range is -32,768 (lowest) through 32,767 (highest). In other words, its value is a SHORT.

MIXERCONTROL_CONTROLTYPE_PAN

A slider with a value that is an integer whose allowable, maximum range is -32,768 (far left) through 32,767 (far right). In other words, its value is a SHORT. It represents pan position in the stereo spectrum, where 0 is center position.

MIXERCONTROL_CONTROLTYPE_QSOUNDPAN

A slider with a value that is an integer whose allowable, maximum range is -15 (lowest) through 15 (highest). In other words, its value is a SHORT. It represents Qsound's expanded sound setting.

种类MIXERCONTROL_CT_CLASS_TIME有以下2个类型与其关联:

MIXERCONTROL_CONTROLTYPE_MICROTIME

A control with a value that is an integer whose allowable, maximum range is 0 (lowest) through 4,294,967,295. In other words, its value is a ULONG. Its value represents an amount of time in microseconds.

MIXERCONTROL_CONTROLTYPE_MILLITIME

A control with a value that is an integer whose allowable, maximum range is 0 (lowest) through 4,294,967,295. In other words, its value is a ULONG. Its value represents an amount of time in milliseconds.

值为MIXERCONTROL_CT_CLASS_CUSTOM的种类是一个自定义的种类。使用此种类控件的混音器只能由专门为这个混音器所写的程序识别此种类的控件有哪些类型,和使用什么样的结构去存取他们的值。(或许只有自定义的结构才能用)

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值