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

📄 0,1410,21300,00.html

📁 C++builder学习资料C++builder
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML>



<HEAD>



<TITLE>Reading a Waveform Audio File</TITLE>

</HEAD>

<BODY MARGINWIDTH="5" MARGINHEIGHT="5" TOPMARGIN="0" LEFTMARGIN="0" BGCOLOR="#FFFFFF">



<A NAME="top"></A>

<table>

<TR>

   <td>



<P> 

  

<font size="+2"><center><b>Reading a Waveform Audio File</b></center></font> 

	<hr noshade> 

	<p> 

		<table border="1" cellspacing="0" cellpadding="2"> 

			<tr align="left" valign="top"> 

				<td align="center"> 

                    <b><a name="TableOfContents">Table Of Contents</a></b> 

				</td>				 

			</tr> 

			<tr align="left" valign="top"> 

				<td> 

					<a href="#Objective">Objective</a><br>		 

					<a href="#WhatIsAWaveformAudioFile">What is a Waveform Audio File?</a><br> 

					<a href="#StructureOfAWaveformAudioFile">The Structure of a Waveform Audio File</a><br> 

					<a href="#TheWaveFormatStructure">The WaveFormat Structure</a><br> 

					<a href="#ReadingTheWavefromAudioFile">Reading the Waveform Audio File</a><br> 

					<a href="#Conclusion">Conclusion</a> 

				</td> 

			</tr> 

		</table> 

	<p> 

		<table border="0" cellspacing="0" cellpadding="2" width="100%"> 

			<tr align="left" valign="top"> 

				<td align="left"> 

                    <a name="Objective">Objective</a> 

				</td> 

				<td align="right"> 

					<a href="#TableOfContents">TOC</a> 

				</td> 

			</tr> 

			<tr align="left" valign="top"> 

				<td bgcolor="White" align="left" colspan="2"> 

					<br> 

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The objective of this article is to explain how digital audio data is stored in waveform audio files.  The article explains what a waveform audio file is, how the data is stored, and how to read the data out.  This article assumes that the reader has the following knowledge:  

<ul type="disc">  

	<li type="disc">C/C++</li>  

	<li type="disc">Windows 32 API</li>  

	<li type="disc">File Streams (File I/O)</li>	  

</ul>  

				</td>  

			</tr>							  

		</table>  

	<p>  

		<table border="0" cellspacing="0" cellpadding="2" width="100%">  

			<tr align="left" valign="top">  

				<td align="left">  

                    <a name="WhatIsAWaveformAudioFile">What is a Waveform Audio File?</a>  

				</td>  

				<td align="right">  

					<a href="#TableOfContents">TOC</a>  

				</td>  

			</tr>  

			<tr align="left" valign="top">  

				<td bgcolor="White" align="left" colspan="2">  

					<br>  

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A waveform audio file is the most common audio file format on Windows PC's.  It is the simplest way to store sounds on your computer.  They are in Resource Interchange File Format (RIFF), which stores headers and data in variable length "chunks", that always start with a four letter code like "WAVE", or "data".  It stores the "data" as PCM (<u>P</u>ulse <u>C</u>ode <u>M</u>odulation) data.  Almost all of the time a waveform audio file does not compress its PCM data, this makes the files large, but easy and quick to read.  

				</td>  

			</tr>							  

		</table>  

	<p>  

		<table border="0" cellspacing="0" cellpadding="2" width="100%">  

			<tr align="left" valign="top">  

				<td align="left">  

                    <a name="StructureOfAWaveformAudioFile">Structure of a Waveform Audio File</a>  

				</td>  

				<td align="right">  

					<a href="#TableOfContents">TOC</a>  

				</td>  

			</tr>  

			<tr align="left" valign="top">  

				<td bgcolor="White" align="left" colspan="2">  

					<br>  

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The structure of a waveform audio file is quite elegant and logical.  The file has three different "chunks" or sections to it.  The first section is the "RIFF" section.  The reason I call it the "RIFF" section is because all of the "chunks" start with a four byte key, or "id", that the file must have for it to be valid.  The first sections key is the four byte's "RIFF".  After the first key comes the file size.  This is a long value that describes the size in bytes of the file.  Next we have the second part of the "RIFF" "chunk", the form-type id.  This is always a four byte value, and for waveform audio this value must be equal to "WAVE".<br>  

<br>  

That finishes the "RIFF" "chunk", which takes us to the "fmt " "chunk".  This chunk stores the structure that contains the format information for the PCM data.  So, the next four bytes after "WAVE" must be the four bytes "fmt ".  <i>Note that I am quoting the space after fmt.  This space is important and must be there.</i> After the "id" "fmt " comes a long value that represents the size of the wave format structure, followed by data block that contains the wave format structure information.  The wave format structure info ends the "fmt " "chunk" and brings us to our last "chunk" the "data" "chunk".<br>  

<br>  

The "data" "chunk" of course starts with the four bytes "data", and is followed by a long that describes the length of the data.  After that all that is left is the actual PCM data.<br>  

<br>  

This table show the structure of the Waveform Audio file:  

<center>  

	<table size="70%" border="0" cellspacing="1" cellpadding="5" bordercolor="#BCBCBC" bordercolordark="#BCBCBC" bordercolorlight="#BCBCBC">  

		<tr bgcolor="Black" align="center" valign="middle">  

			<th align="center" valign="middle" bgcolor="#FFFFFF" colspan="3">  

                Waveform Audio File Structure  

			</th>  

		</tr>  

		<tr bgcolor="Gray" align="center" valign="middle">  

			<td align="center" valign="middle">  

				<font color="White"><b>Type</b></font>  

			</td>  

			<td align="center" valign="middle">  

				<font color="White"><b>Size</b></font>  

			</td>  

			<td align="center" valign="middle">  

				<font color="White"><b>Value</b></font>  

			</td>  

		</tr>  

		<tr bgcolor="#DEDEDE" align="center" valign="middle">  

			<td align="left" valign="middle">  

				<font color="Black">First "Chunk" ID</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">4 bytes (char &#91;4&#93;)</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">"RIFF"</font>  

			</td>  

		</tr>  

		<tr bgcolor="DEDEDE" align="center" valign="middle">  

			<td align="left" valign="middle">  

				<font color="Black">File Size</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">4 bytes (long)</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">Size of the file in bytes</font>  

			</td>  

		</tr>  

		<tr bgcolor="DEDEDE" align="center" valign="middle">  

			<td align="left" valign="middle">  

				<font color="Black">Form Type ID</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">4 bytes (char &#91;4&#93;)</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">"WAVE"</font>  

			</td>  

		</tr>  

		<tr bgcolor="DEDEDE" align="center" valign="middle">  

			<td align="left" valign="middle">  

				<font color="Black">Second "Chunk" ID</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">4 bytes (char &#91;4&#93;)</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">"fmt "</font>  

			</td>  

		</tr>  

		<tr bgcolor="DEDEDE" align="center" valign="middle">  

			<td align="left" valign="middle">  

				<font color="Black">Wave Format Size</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">4 bytes (long)</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">Size in bytes of the Wave Format Info</font>  

			</td>  

		</tr>  

		<tr bgcolor="DEDEDE" align="center" valign="middle">  

			<td align="left" valign="middle">  

				<font color="Black">Wave Format Info</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">Wave Format Size</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">Information on the format of the PCM data.</font>  

			</td>  

		</tr>  

		<tr bgcolor="DEDEDE" align="center" valign="middle">  

			<td align="left" valign="middle">  

				<font color="Black">Third "Chunk" ID</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">4 bytes (char &#91;4&#93;)</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">"data"</font>  

			</td>  

		</tr>  

		<tr bgcolor="DEDEDE" align="center" valign="middle">  

			<td align="left" valign="middle">  

				<font color="Black">Data Size</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">4 bytes (long)</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">Size in bytes of the PCM data</font>  

			</td>  

		</tr>  

		<tr bgcolor="DEDEDE" align="center" valign="middle">  

			<td align="left" valign="middle">  

				<font color="Black">Data</font>  

			</td>  

			<td align="left" valign="middle">  

				<font color="Black">Data Size</font>  

			</td>  

⌨️ 快捷键说明

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