⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multiple channel audio data and wave files.htm

📁 WAV文件的格式官方宝典
💻 HTM
📖 第 1 页 / 共 5 页
字号:
      <P>If, for example in a multi-channel audio authoring application, no 
      speaker location is desired on any of the mono streams, the 
      <B>dwChannelMask</B> should explicitly be set to <B>0</B>. A 
      <B>dwChannelMask</B> of <B>0</B> tells the audio device to render the 
      first channel to the first port on the device, the second channel to the 
      second port on the device, and so on. This also means that if the device 
      doesn't know how to process the raw audio streams, it should not accept 
      the multi-channel stream with a <B>dwChannelMask</B> of <B>0</B>. A device 
      like a digital mixer or a digital audio storage device (hard disk, ADAT, 
      and so on) might want to accept formats without particular speaker 
      locations.</P>
      <P>The <B>dwChannelMask</B> value 0xFFFFFFFF (or any value in which the 
      most significant bit of the DWORD is set) is pre-defined to indicate that 
      an entity supports all possible channel configurations. An example would 
      be WDM Audio's built-in kernel mixer. There will never be a location 
      corresponding to the most significant bit in <B>dwChannelMask</B>, so this 
      value is unambiguous.</P>
      <P>This format does not deal with speaker locations that do not correspond 
      to the defined values, although Microsoft reserves the right to define 
      them in the future.</P>
      <DIV style="MARGIN-TOP: 3px; MARGIN-BOTTOM: 10px"><A 
      href="http://www.microsoft.com/whdc/hwdev/tech/audio/multichaud.mspx#top"><IMG 
      height=9 alt="Top of page" 
      src="Multiple Channel Audio Data and WAVE Files.files/arrow_px_up.gif" 
      width=7 border=0></A><A class=topOfPage 
      href="http://www.microsoft.com/whdc/hwdev/tech/audio/multichaud.mspx#top">Top 
      of page</A></DIV><A name=#XSLTsection132121120120></A>
      <H2>Examples </H2>
      <P><B>Multi-Channel 16-bit</B><BR>The following <B>WAVEFORMATPCMEX</B> 
      structure indicates a 16-bit four-channel audio rendering with Front Left, 
      Front Right, Back Left and Back Right:</P><PRE class=codeSample>WAVEFORMATPCMEX 	waveFormatPCMEx;
waveFormatPCMEx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
waveFormatPCMEx.Format.nChannels = 4;
waveFormatPCMEx.Format.nSamplesPerSec = 44100L;
waveFormatPCMEx.Format.nAvgBytesPerSec = 352800L; 
waveFormatPCMEx.Format.nBlockAlign = 8;  /* Same as the usual */
waveFormatPCMEx.Format.wBitsPerSample = 16;
waveFormatPCMEx.Format.cbSize = 22;  /* After this to GUID */
waveFormatPCMEx.wValidBitsPerSample = 16;  /* All bits have data */
waveFormatPCMEx.dwChannelMask = SPEAKER_FRONT_LEFT | 
                                SPEAKER_FRONT_RIGHT | 
                                SPEAKER_BACK_LEFT |
                                SPEAKER_BACK_RIGHT;
                                // Quadraphonic = 0x00000033
waveFormatPCMEx.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;  // Specify PCM
</PRE>
      <P>The four channels of audio data are packed into memory as follows, and 
      a pointer to that memory is stored in the <B>lpData</B> member of the 
      <B>WAVEHDR</B> structure.</P>
      <P>Byte 1 - Channel 1, Front Left, Low Order Byte<BR>Byte 2 - Channel 1, 
      Front Left, High Order Byte<BR>Byte 3 - Channel 2, Front Right, Low Order 
      Byte<BR>Byte 4 - Channel 2, Front Right, High Order Byte<BR>Byte 5 - 
      Channel 3, Back Left, Low Order Byte<BR>Byte 6 - Channel 3, Back Left, 
      High Order Byte<BR>Byte 7 - Channel 4, Back Right, Low Order Byte<BR>Byte 
      8 - Channel 4, Back Right, High Order Byte<BR><BR>Byte 9 - Channel 1, 
      Front Left, Low Order Byte, Sample 2<BR>Byte 10 - Channel 1, Front Left, 
      High Order Byte, Sample 2 etc. </P>
      <P>Again, <B>PWAVEFORMATPCMEX</B> can be safely cast to 
      <B>PWAVEFORMATEXTENSIBLE</B> or <B>PWAVEFORMATEX</B> for portability.</P>
      <P><BR><B>Stereo 20-bit, Padded wBitsPerSample</B><BR>The following 
      <B>WAVEFORMATPCMEX</B> structure indicates 2 channels of 20-bit 
      resolution, packed into 24-bit containers on disk:</P><PRE class=codeSample>WAVEFORMATPCMEX 	waveFormatPCMEx;
waveFormatPCMEx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
waveFormatPCMEx.Format.nChannels = 2;
waveFormatPCMEx.Format.nSamplesPerSec = 44100L;
waveFormatPCMEx.Format.nAvgBytesPerSec = 264600L; // Compute using nBlkAlign * nSamp/Sec
waveFormatPCMEx.Format.nBlockAlign = 6;
waveFormatPCMEx.Format.wBitsPerSample = 24; //Container has 3 bytes waveFormatPCMEx.Format.cbSize = 22;
waveFormatPCMEx.wValidBitsPerSample = 20;  // Top 20 bits have data
waveFormatPCMEx.dwChannelMask = SPEAKER_FRONT_LEFT |
                                SPEAKER_FRONT_RIGHT | 
                                // Stereo = 0x00000003
waveFormatPCMEx.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;  // Specify PCM
</PRE>
      <P>The two channels of three-byte audio data are packed into memory as 
      follows, and a pointer to that memory is stored in the <B>lpData</B> 
      member of the <B>WAVEHDR</B> structure.</P>
      <P>Byte 1 - Channel 1, Front Left, Low Order Byte, only top four bits have 
      valid data<BR>Byte 2 - Channel 1, Front Left, Mid Order Byte, all valid 
      data<BR>Byte 3 - Channel 1, Front Left, High Order Byte, all valid 
      data<BR>Byte 4 - Channel 2, Front Right, Low Order Byte, top four bits 
      have valid data<BR>Byte 5 - Channel 2, Front Right, Mid Order Byte, all 
      valid data<BR>Byte 6 - Channel 2, Front Right, High Order Byte, all valid 
      data<BR><BR>Byte 7 - Channel 1, Front Left, Low Order Byte, top four bits 
      have valid data, Sample 2<BR>Byte 8 - Channel 1, Front Left, Mid Order 
      Byte, all valid data, Sample 2 etc.<BR></P>
      <P><B>NOTE: nAvgBytesPerSec</B> is computed using the block size 
      (<B>nBlockAlign</B>), as opposed to the container size 
      (<B>wBitsPerSample</B>) or the actual number of significant bits 
      (<B>wValidBitsPerSample</B>).</P>
      <P><BR><B>6 Channels in 5.1 Format</B><BR>The following 
      <B>WAVEFORMATPCMEX</B> structure is an example of a structure that might 
      be specified as the output of a decoder producing audio streams for a 5.1 
      speaker layout.</P><PRE class=codeSample>WAVEFORMATPCMEX 	waveFormatPCMEx;
waveFormatPCMEx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
waveFormatPCMEx.Format.nChannels = 6;
waveFormatPCMEx.Format.nSamplesPerSec = 48000L;
waveFormatPCMEx.Format.nAvgBytesPerSec = 864000L; // Compute using nBlkAlign * nSamp/Sec 
waveFormatPCMEx.Format.nBlockAlign = 18;
waveFormatPCMEx.Format.wBitsPerSample = 24; //Container has 3 bytes waveFormatPCMEx.Format.cbSize = 22;
waveFormatPCMEx.wValidBitsPerSample = 20;  // Top 20 bits have data
waveFormatPCMEx.dwChannelMask = KSAUDIO_SPEAKER_5POINT1;
                             // SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT |
                             // SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY |
                             // SPEAKER_BACK_LEFT  | SPEAKER_BACK_RIGHT
waveFormatPCMEx.SubFormat =  KSDATAFORMAT_SUBTYPE_PCM;  // Specify PCM
</PRE>
      <P>The two channels of three-byte audio data are packed into memory as 
      follows, and a pointer to that memory is stored in the <B>lpData</B> 
      member of the <B>WAVEHDR</B> structure.</P>
      <P>Byte 1 - Channel 1, Front Left, Low Order Byte, only top four bits have 
      valid data<BR>Byte 2 - Channel 1, Front Left, Mid Order Byte, all valid 
      data<BR>Byte 3 - Channel 1, Front Left, High Order Byte, all valid 
      data<BR>Byte 4 - Channel 2, Front Right, Low Order Byte, top four bits 
      have valid data<BR>Byte 5 - Channel 2, Front Right, Mid Order Byte, all 
      valid data<BR>Byte 6 - Channel 2, Front Right, High Order Byte, all valid 
      data<BR>Byte 7 - Channel 3, Front Center, Low Order Byte, only top four 
      bits have valid data<BR>Byte 8 - Channel 3, Front Center, Mid Order Byte, 
      all valid data<BR>Byte 9 - Channel 3, Front Center, High Order Byte, all 
      valid data<BR>Byte 10 - Channel 4, Low Frequency, Low Order Byte, top four 
      bits have valid data<BR>Byte 11 - Channel 4, Low Frequency, Mid Order 
      Byte, all valid data<BR>Byte 12 - Channel 4, Low Frequency, High Order 
      Byte, all valid data<BR>Byte 13 - Channel 5, Back Left, Low Order Byte, 
      only top four bits have valid data<BR>Byte 14 - Channel 5, Back Left, Mid 
      Order Byte, all valid data<BR>Byte 15 - Channel 5, Back Left, High Order 
      Byte, all valid data<BR>Byte 16 - Channel 6, Back Right, Low Order Byte, 
      top four bits have valid data<BR>Byte 17 - Channel 6, Back Right, Mid 
      Order Byte, all valid data<BR>Byte 18 - Channel 6, Back Right, High Order 
      Byte, all valid data<BR><BR>Byte 19 - Channel 1, Front Left, Low Order 
      Byte, top four bits have valid data, Sample 2<BR>Byte 20 - Channel 1, 
      Front Left, Mid Order Byte, all valid data, Sample 2 etc.<BR></P>
      <P><BR><B>Unspecified location channel, DWORD Container</B><BR>The 
      following <B>WAVEFORMATPCMEX</B> structure indicates three channels of 
      23-bit resolution, packed into 32-bit containers on disk, of which only 
      the first two channels are localized:</P><PRE class=codeSample>WAVEFORMATPCMEX 	waveFormatPCMEx;
waveFormatPCMEx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
waveFormatPCMEx.Format.nChannels = 3;
waveFormatPCMEx.Format.nSamplesPerSec = 48000L;
waveFormatPCMEx.Format.nAvgBytesPerSec = 576000L; // Compute using nBlkAlign * nSamp/Sec 
waveFormatPCMEx.Format.nBlockAlign = 12;
waveFormatPCMEx.Format.wBitsPerSample = 32; //Container has 4 bytes waveFormatPCMEx.Format.cbSize = 22;
waveFormatPCMEx.wValidBitsPerSample = 23; // Top 23 bits have data
waveFormatPCMEx.dwChannelMask =
                         SPEAKER_FRONT_LEFT_OF_CENTER |
                         SPEAKER_FRONT_RIGHT_OF_CENTER
                     // Left, Right of Center = 0x000000C0
WAVEFORMATPCMEX.SUBFORMAT =  KSDATAFORMAT_SUBTYPE_PCM; // SPECIFY PCM
</PRE>
      <P>The two channels of four-byte audio data are packed into memory as 
      follows, and a pointer to that memory is stored in the <B>lpData</B> 
      member of the <B>WAVEHDR</B> structure.</P>
      <P>Byte 1 - Channel 1, Left of Center, Low Order Byte, no valid 
      data<BR>Byte 2 - Channel 1, Left of Center, Mid Low Order Byte, only top 
      seven bits have valid data<BR>Byte 3 - Channel 1, Left of Center, Mid High 
      Order Byte, all valid data<BR>Byte 4 - Channel 1, Left of Center, High 
      Order Byte, all valid data<BR>Byte 5 - Channel 2, Right of Center, Low 
      Order Byte, no valid data<BR>Byte 6 - Channel 2, Right of Center, Mid Low 
      Order Byte, top seven bits have valid data<BR>Byte 7 - Channel 2, Right of 
      Center, Mid High Order Byte, all valid data<BR>Byte 8 - Channel 2, Right 
      of Center, High Order Byte, all valid data<BR>Byte 9 - Channel 3, 
      Unspecified Location, Low Order Byte, no valid data<BR>Byte 10 - Channel 
      3, Unspecified Location, Mid Low Order Byte, top seven bits have valid 
      data<BR>Byte 11 - Channel 3, Unspecified Location, Mid High Order Byte, 
      all valid data<BR>Byte 12 - Channel 3, Unspecified Location, High Order 
      Byte, all valid data<BR><BR>Byte 13 - Channel 1, Left of Center, Low Order 
      Byte, no valid data, Sample 2<BR>Byte 14 - Channel 1, Left of Center, Mid 
      Low Order Byte, top seven bits have valid data, Sample 2 etc.<BR></P>
      <P>These streams could be sent through a scaling algorithm that puts 
      fractional values into the lower 9 bits as well, and the only change to 
      the values in the wave format structure would be:</P><PRE class=codeSample>// All 32 bits have datawaveFormat
PCMEx.wValidBitsPerSample = 32;
</PRE>
      <P><B>An Example Using WAVEFORMATIEEEFLOATEX</B><BR>The following 
      <B>WAVEFORMATIEEEFLOATEX</B> structure indicates seven channels of 18-bit 
      data, in 32-bit containers. Channel seven contains valid audio data that 
      simply is not assigned a spatial location.</P><PRE class=codeSample>PWAVEFORMATIEEEFLOATEX 	waveFormatIEEEFloatEx;
waveFormatIEEEFloatEx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
waveFormatIEEEFloatEx.Format.nChannels = 7;
waveFormatIEEEFloatEx.Format.nSamplesPerSec = 48000L;
waveFormatIEEEFloatEx.Format.nAvgBytesPerSec = 1344000L;
waveFormatIEEEFloatEx.Format.nBlockAlign = 28;
waveFormatIEEEFloatEx.Format.wBitsPerSample = 32;
waveFormatIEEEFloatEx.Format.cbSize = 22;
waveFormatIEEEFloatEx.wValidBitsPerSample = 18; //Top 18 bits have data
waveFormatIEEEFloatEx.dwChannelMask = SPEAKER_FRONT_LEFT |
                                      SPEAKER_FRONT_RIGHT |
                                      SPEAKER_FRONT_CENTER |
                                      SPEAKER_LOW_FREQUENCY | 
                                      SPEAKER_BACK_LEFT |
                                      SPEAKER_BACK_RIGHT;
waveFormatPCMEx.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; // 5.1 + unassigned chan
</PRE>
      <P>Byte 1 - Channel 1, Front Left, Low Order Byte, no valid 
      data<BR><BR>Byte 2 - Channel 1, Front Left, Mid Low Order Byte, only top 
      two bits have valid data<BR>Byte 3 - Channel 1, Front Left, Mid High Order 
      Byte, all valid data<BR>Byte 4 - Channel 1, Front Left, High Order Byte, 
      all valid data<BR>Byte 5 - Channel 2, Front Right, Low Order Byte, no 
      valid data<BR>Byte 6 - Channel 2, Front Right, Mid Low Order Byte, top two 
      bits have valid data<BR>Byte 7 - Channel 2, Front Right, Mid High Order 
      Byte, all valid data<BR>Byte 8 - Channel 2, Front Right , High Order Byte, 
      all valid data<BR>Byte 9 - Channel 3, Front Center, Low Order Byte, no 
      valid data<BR>Byte 10 - Channel 3, Front Center, Mid Low Order Byte, top 
      two bits have valid data<BR>Byte 11 - Channel 3, Front Center, Mid High 
      Order Byte, all valid data<BR>Byte 12 - Channel 3, Front Center, High 
      Order Byte, all valid data<BR>Byte 13 - Channel 4, Low 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -