README.TXT 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. 1. Mixer architecture
  2. 2. Mixer components architecture
  3. -----------------------------------------------------------------------------
  4. 1. Mixer architecture
  5. -----------------------------------------------------------------------------
  6. What is hided under simple volume control application that you're starting by
  7. double-clicking on the speaker icon? Where is complex construction which
  8. provides device-independent access to different audio flow controlling
  9. capabilities of different sound cards.
  10. All sound comes from some kind of _source audio line_. I.e. sound from CD comes
  11. to soundcard through CD source line. After inside sound card's mixer it combines
  12. with other sound which comes from another source lines and they all fall into
  13. _destination audio line_. One of destination line is playing on the speaker
  14. system, sound from another is recorded by sound recorders. Also in any place
  15. (depending on sound card's capabilities) there are different _mixer controls_ at
  16. sound lines. For example there is master volume control on the destination line
  17. which leads to speaker. There are several types of controls which can be present
  18. at the sound card:
  19. Fader - faders are different volume, bass, treble and other controls of such
  20. type. Mostly you are controlling such a control with some kind of
  21. vertical scrollbar.
  22. Meter - this is not controller, this is measure control. I.e. you got values
  23. from it, which are calculated from sound. For example on most cards
  24. you can see VU-meter on Wave source or Recording target, this is meter
  25. control.
  26. Slider - this is like a fader, but mostly present with horizontal scrollbar.
  27. For example pan control.
  28. Switch - this is just a switch of some type. For example mutes or automatic
  29. gain control.
  30. Time,
  31. Number - controls of such type mostly represent some kind of numeric data.
  32. List - this is interesting kind of control. It will be described later in
  33. section describing line mixing.
  34. Custom - this is not a type, it means that sound card contains something very
  35. uncommon, and should be controlled in some unknown way. You can
  36. operate on low-level with controls of such type using MMMixer stuff.
  37. So what about line mixing? You see that you're not hearing all possible source
  38. audio lines because it will be not eligible. Instead you select which line to
  39. hear, and which not. Or you select which line to mute. And this covers two
  40. different types of mixing: selection and muting. Different destination audio
  41. lines can differently mix their source lines, or different methods can be used
  42. even on one destination line. On recording destination line mostly used
  43. selection method. I.e. there is _Mixer control_ on the destination line which
  44. selects which line to hear. Do not confuse with different "mixer controls",
  45. we'll name control which selects source lines with capital letter, and ordinal
  46. mixer control with lower letter. So then you _select_ lines in volume control
  47. application you're using such Mixer control. But if you mute lines then you use
  48. another technique: each source line contains mute control which can disable
  49. sound to go to destination. Also there can be special type of selection: then
  50. only one line can be connected to destination line - this is done by mux control
  51. which is works like a switch.
  52. Each control can operate with several channels independently or uniform. So you
  53. can mute only one left channel, or set right channel more loud than left. Also
  54. some kind of controls (like Mixer control) allows to set values independently
  55. for different items (i.e. different lines in Mixer control, different bands in
  56. Equalizer and so on).
  57. If you have seen different sound card, you can see that there is as much mixer
  58. construction as much sound cards and card drivers. To allow you more independent
  59. controlling of sound flow you can use several features. Each audio line has type
  60. of component to/from which it connected. For example destination line which
  61. leads to speaker has DstSpeaker component type, and source line which leads from
  62. CD has SrcCD component type. Also each control has control type (like Volume,
  63. Bass, Mute), and system allows you to ask controls with specified types, and
  64. lines with specified component types.
  65. So to control anything you should get needed audio lines, find needed controls
  66. and change their values. Also system allows you to reflect changes in controls
  67. which made by another programs.
  68. -----------------------------------------------------------------------------
  69. 2. Mixer components architecture
  70. -----------------------------------------------------------------------------
  71. MMMixer components organised as wrappers for logical mixer architecture.
  72. MMMixerDevice represents mixer device. Mostly where is one mixer device on
  73. each sound card. To select which device to use you should use DeviceId property.
  74. Number of devices is present in DeviceCount property. DeviceCaps property can
  75. be used to obtain different information about mixer device. There is two
  76. interesting properties: Active and Destinations. Destinations shows how many
  77. destination audio lines present in mixer. they can be accessed by property
  78. Destination[i]. Setting Active property to True allow component to reflect
  79. changes in mixer controls made by another applications. In such a case all
  80. components connected to MMMixerDevice will reflect these changes. There are
  81. three events: OnChange, OnLineChange and OnControlChange. They are fired then
  82. any change occured, change in some audio line occured or change in some audio
  83. control occured.
  84. MMAudioLine component is used to work with both destination and source audio
  85. lines. At first it should be connected to MixerDevice component by Mixer
  86. property. After you have a task to select one of different audio lines. The
  87. target is to obtain a line id. This can be done by setting line id directly
  88. using property LineId. This is usable in run-time if get it from some other
  89. place. But in device-independent case this is not good. If you want to select
  90. source audio line you should connect AudioLine component to another AudioLine
  91. component which represents destination audio line. This will allow you to select
  92. some kinds of audio lines in the set of lines connected to destination line.
  93. But do not forget to connect both source and destination lines to mixer device
  94. component. To select line you can use ComponentType property. Using it you can
  95. say that you want SrcCD type of line. So if you've just audio line component
  96. connected to mixer device you'll commonly get first source CD line present in
  97. the card. It is mostly source line connected to speaker output. If you want to
  98. be more exact you should connect one audio line component to speaker or recorder
  99. (this can be done by using ComponentType too, but for destination line it is no
  100. problem to determine which to use), and after connect needed audio line to it
  101. and specify ComponentType. In such a case there will be found CD source line
  102. which is falls to specified destination. If it will not be found, than line id
  103. becomes badLineId and line becomes unavailable. In another case line id will be
  104. set to valid line identifier. After setting valid audio line you can obtain
  105. different information from LineInfo property. There are two events: OnChange and
  106. OnControlChange. They occurs than specified line changed or one of line's
  107. control is changed.
  108. MMMixerControl component is used to communicate with sound card's audio line's
  109. control. I.e. it does not provide visual representation of control's data, but
  110. allows you to connect different kinds of visual controls to it. You should
  111. connect it to audio line on which you want operate using property AudioLine.
  112. After you should to select control which resides on the line. This can be done
  113. by using ControlId property, but it is device-dependent. Instead of this you can
  114. use ControlType property which allows you to select type of control which you
  115. want to find on the selected line. For example if you connect mixer control to
  116. AudioLine which is connected to CD source line, and set ControlType to ctVolume
  117. you will get volume control for CD. If CD source line does not exist, or volume
  118. control is not present on it, control becomes unavailable, and all visual
  119. controls connected to it reflects it by setting their visual representation to
  120. appropriate state. After connecting control you can access various information
  121. from ControlInfo property. MixerControl has one event - OnChange which is fired
  122. then control's value or state is changed.
  123. MMVolumeControl and MMPanControl - this is special cases of MMMixerControl
  124. specially designed to control volume and pan. On most sound cards there is no
  125. hardware pan controlling. This is done in software. To simulate pan control you
  126. can use MMPanControl component, and this component to work correctly with
  127. corresponding volume controls should be connected to MMVolumeControl.
  128. MMMixerSlider is a visual control which can be used to operate any mixer control
  129. which allow to set numeric values (such as sliders, faders, numbers e.t.c). You
  130. can select control by using Control property, channel on which to operate using
  131. Channel property (left, right or both) and item using Item property (or NoItem
  132. if just ordinary control). Slider will automatically accept min and max values,
  133. step count and will reflect actual value of control if MixerDevice's property
  134. Active is set to True.
  135. MMMixerWheel just as MMMixerSlider, but provides different visual
  136. representation. By the way: you can set any number of visual controls connected
  137. to non-visual mixer control.
  138. MMMixerCheck is provided to display values for switch-type controls. In addition
  139. to standart properties (see MMMixerSlider), it has property AutoCaption which
  140. allows control to automatically set caption using name of sound card's control
  141. (btw: it is often really descriptive name). If you use MixerCheck to control
  142. Mixer control (here we talk about control which controls which source lines to
  143. flow into destination line) you will need to switch just an item not whole
  144. control. To set MixerCheck to control item which corresponds to some audio line
  145. you can point ItemLine property to this line. Also to select which name to use
  146. for caption (there is allways present short and long name) you can use property
  147. Short.
  148. MMMixerConnector is used to show values for controls which is non-controlling
  149. but measures some values. After specified time interval it requests current
  150. value from control and post it to connected visual controls (like Meters and
  151. Levels). So you can connect Peak meters to it to show VU-meter for user.
  152. (btw: you can even connect volume control to it and you'll see visual
  153. representation for current volume).
  154. MMMixerLabelConnector is used to set caption of any component which has Caption
  155. property to name of some mixer control.
  156. MMDeviceSpin and MMDeviceComboBox can be used to simply select different
  157. mixer devices to use.
  158. MMMixerBlock is special component to easily create Volume Control like mixer
  159. panels. You can put different controls on it and automatically arrange and size
  160. them. See Mix and Block app for examples. You should put on it special versions
  161. of mixer visual controls: MixerBlockSlider, MixerBlockCheck, e.t.c. Then you
  162. put such component it automatically jumps to corresponding location. After you
  163. can change its "role" by setting its Role property. For example you can put
  164. first slider and it will become pan control. If you want you can make it left
  165. volume control by changing its Role property. The purpose of block is that you
  166. operate only with block, you should not think about each control. To turn auto
  167. arrangement off you should set AutoArrange property to False, or you can just
  168. set AutoSize property to false - it will only disable auto resizing of controls.
  169. You should connect Block directly to AudioLine using property Line. If mute of
  170. audio line will be available then it automatically will be accessible through
  171. MixerCheck, but if you want to allow selection of audio line you will need to
  172. connect block to MixerControl component connected to sound card's Mixer control
  173. (which selects audio lines). So if in run-time destination audio line will
  174. allow selection of audio lines when block automatically will select audio line,
  175. if there is will be only mute, then it will be available, if no kind of
  176. selection/muting will be available checkbox will be disabled.
  177. So to setup mixer-enabled app you should set MixerDevice component, several
  178. audio lines component for needed destinations, all needed source lines connected
  179. to destinations, possible mixer control components on different lines and visual
  180. controls to control these controls.