wav音頻文件是一種無損的音頻文件,,相對于MP3來說音質(zhì)較好,,當(dāng)然文件大小也很大。
A WAVE file is often just a RIFF file with a single “WAVE” chunk which consists of two sub-chunks – a “fmt ” chunk specifying the data format and a “data” chunk containing the actual sample data. Call this form the “Canonical form”
其文件的內(nèi)部格式如下:
用表格統(tǒng)計各個部分的含義如下:
一個簡單的示例如下所示:
chunk 結(jié)構(gòu) typedef struct waveChunk { unsigned int chunkID; //RIFF unsigned int chunksize; //存儲整個文件的文字?jǐn)?shù) unsigned int WaveID; //WAVE }WAVE;
typedef struct tWAVEFORMATEX { short wFormatTag; // format type short nChannels; // number of channels (i.e. mono, stereo...) unsigned int nSamplesPerSec; // sample rate unsigned int nAvgBytesPerSec; // for buffer estimation short nBlockAlign; // block size of data short wBitsPerSample; // number of bits per sample of mono data short cbSize; // the count in bytes of the size of /* extra information (after cbSize) */ } WAVEFORMATEX, *PWAVEFORMATEX;
typedef struct dataChunk { unsigned int Subchunk2ID; //data unsigned int Subchunk2size; //data size unsigned char *data; //data }WAVE;
Q&A
8bit/16 bit 樣值的二進制編碼表示一樣嗎,? 現(xiàn)有的wav支持哪幾種音頻編碼方法,?
data format
在數(shù)據(jù)域中除了單聲道-量化位數(shù)為8音頻數(shù)據(jù)之外PCM存儲格式按照補碼的形式存放。 于單聲道,、量化位數(shù)為8的情況,,使用offset binary(偏移二進制碼)。 PCM data is two’s-complement except for resolutions of 1-8 bits, which are represented as offset binary.
The data format and maximum and minimums values for PCM waveform samples of various sizes are as follows:
Sample Size |
Data Format |
Maximum Value |
Minimum Value |
one to eight bits |
unsigned integer |
255(0xFF) |
0 |
Nine or more bits |
Signed integer i |
Largest positive value of i |
Most negative value of i |
For example, the maximum, minimum, and midpoint values for 8-bit and 16-bit PCM waveform data are as follows:
Sample Size |
Data Format |
Maximum Value |
Minimum Value |
8-bit PCM |
255(0xFF) |
0 |
128(0x80) |
16-bit PCM |
32767(0x7FFF) |
-32768(-0x8000) |
0 |
Format Code
WAV對音頻流的編碼沒有硬性規(guī)定,,除了PCM之外,,還幾乎所有支持ACM規(guī)范的編碼都可以為WAV的音頻流進行編碼。 The standard format codes for waveform data are given below. The references above give many more format codes for compressed data, a good fraction of which are now obsolete(部分現(xiàn)在已經(jīng)過時了~).
Format Code |
PreProcessor Symbol |
Data |
0x0001 |
WAVE_FORMAT_PCM |
PCM |
0x0003 |
WAVE_FORMAT_IEEE_FLOAT |
IEEE float |
0x0006 |
WAVE_FORMAT_ALAM |
8-bit ITU-T G.711 A-law |
0x0007 |
WAVE_FORMAT_MULAW |
8-bit ITU-T G.711 μ-law |
0xFFFE |
WAVE_FORMAT_EXTENSIBLE |
Determined by SubFormat |
下面維基百科提供的一份參考資料: 幾種不同編碼方式下得到的單聲道m(xù)onophonic(not sterophonic)wav音頻audio quality聲音質(zhì)量與壓縮比特率compression bitrates的對比 code知識補充?。?br> 我們熟知的數(shù)字信號本質(zhì)上是對連續(xù)變化的模擬信號進行抽樣,、量化和編碼得到的,,稱為PCM(Pulse-code modulation),即脈沖編碼調(diào)制,這種電的數(shù)字信號被叫做數(shù)字基帶信號,,由PCM電端機產(chǎn)生,。 音頻編碼:針對頻率范圍較寬的音頻信號進行的編碼。主要應(yīng)用于數(shù)字廣播和數(shù)字電視廣播,、消費電子產(chǎn)品,、音頻信息的存儲、下載等,。 語音編碼:對模擬的語音信號進行編碼,,將模擬信號轉(zhuǎn)化成數(shù)字信號,從而降低傳輸碼率并進行數(shù)字傳輸,。語音編碼的基本方法可分為波形編碼(Waveform Coding),、參量編碼(Parametric Coding)和混合編碼(Hybrid Coding)。 波形編碼是將時域的模擬話音的波形信號經(jīng)過取樣,、量化,、編碼而形成的數(shù)字話音信號; 參量編碼是基于人類語言的發(fā)音機理,,找出表征語音的特征參量,,對特征參量進行編碼; 混合編碼則是結(jié)合了兩種編碼方式的優(yōu)點,基于語音產(chǎn)生模型的假定采用了分析合成技術(shù),,同時又利用了語音的時間波形信息,,增強了重建語音的自然度,使得語音質(zhì)量有明顯的提高,,代價是編碼速率相應(yīng)上升,。 Microsoft GSM 06.10 The low-level speech compression algorithm of the GSM suite is called GSM 06.10 RPE-LTP (Regular-Pulse Excitation Long-Term Predictor). ADPCM (adaptive difference pulse code modulation)自適應(yīng)差分PCM SBC(sub-band coding)子帶編碼 CELP(Code Excited Linear Prediction,碼激勵線性預(yù)測編碼) Truespeech(a proprietary audio codec produced by the DSP Group). It is designed for encoding voice data at low bitrates, and to be embedded into DSP chips. True speech has been integrated into Windows Media Player in older versions of Windows, but no longer supported since Windows Vista. It is also the format used by the voice chat features of Yahoo! Messenger
|