?? wav.h
字號:
/*H**************************************************************************
* NAME: wav.h
*----------------------------------------------------------------------------
* WAVE FILE FORMAT
* ================
* RIFF Chunk (12 bytes in length total)
* -------------------------------------
* Byte Nb
* 0 - 3 "RIFF" (ASCII Characters)
* 4 - 7 Total Length Of Package To Follow (Binary, little endian)
* 8 - 11 "WAVE" (ASCII Characters)
*
* FORMAT Chunk (24 bytes in length total)
* ---------------------------------------
* Byte Nb
* 0 - 3 "fmt " (ASCII Characters)
* 4 - 7 Length Of FORMAT Chunk (Binary, always 0x10)
* 8 - 9 Always 0x01
* 10 - 11 Channel Numbers (Always 0x01=Mono, 0x02=Stereo)
* 12 - 15 Sample Rate (Binary, in Hz)
* 16 - 19 Bytes Per Second
* 20 - 21 Bytes Per Sample: 1= 8b Mono, 2= 8b Stereo or 16b Mono, 4= 16b Stereo
* 22 - 23 Bits Per Sample
*
* DATA Chunk
* ----------
* Byte Nb
* 0 - 3 "data" (ASCII Characters)
* 4 - 7 Length Of Data To Follow
* 8 - end Data (Samples)
*
* EXAMPLE
* -------
* 0000 52 49 46 46 46 2D 00 00-57 41 56 45 66 6D 74 20 RIFFF-..WAVEfmt
* 0010 10 00 00 00 01 00 01 00-22 56 00 00 22 56 00 00 ........"V.."V..
* 0020 01 00 08 00 64 61 74 61-22 2D 00 00 80 80 80 80 ....data"-......
* 0030 80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80 ................
* 0040 80 80 80 80 80 80 80 80-80 80 80 80 80 80 80 80 ................
* As expected, the file begins with the ASCII characters "RIFF" identifying
* it as a WAV file. The next four bytes tell us the length is 0x2D46 bytes
* (11590 bytes in decimal) which is the length of the entire file minus the
* 8 bytes for the "RIFF" and length (11598 - 11590 = 8 bytes).
* The ASCII characters for "WAVE" and "fmt " follow. Next (line 2 above) we
* find the value 0x00000010 in the first 4 bytes (length of format chunk:
* always constant at 0x10). The next four bytes are 0x0001 (Always) and
* 0x0001 (A mono WAV, one channel used).
* Since this is a 8-bit WAV, the sample rate and the bytes/second are the
* same at 0x00005622 or 22,050 in decimal. For a 16-bit stereo WAV the
* bytes/sec would be 4 times the sample rate. The next 2 bytes show the
* number of bytes per sample to be 0x0001 (8-bit mono) and the number of
* bits per sample to be 0x0008.
* Finally, the ASCII characters for "data" appear followed by 0x00002D22
* (11,554 decimal) which is the number of bytes of data to follow (actual
* samples). The data is a value from 0x00 to 0xFF. In the example above 0x80
* would represent "0" or silence on the output since the DAC used to playback
* samples is a bipolar device (i.e. a value of 0x00 would output a negative
* voltage and a value of 0xFF would output a positive voltage at the output
* of the DAC on the sound card)
*****************************************************************************/
#ifndef _WAV_H_
#define _WAV_H_
#include "..\compiler.h"
/*_____ I N C L U D E S ____________________________________________________*/
/*_____ M A C R O S ________________________________________________________*/
/*_____ D E F I N I T I O N ________________________________________________*/
/* WAV Format Structure */
typedef struct
{ /* RIFF info */
char riff[4];
Uint32 pack_length;
char wave[4];
} riff_struct;
typedef struct
{ /* FMT info */
char fmt[4];
Uint32 fmt_length;
Uint16 wav_format;
Uint16 channel_nb;
Uint32 sample_rate;
Uint32 bytes_per_second;
Uint16 bytes_per_sample;
Uint16 bits_per_sample;
} fmt_struct;
typedef struct
{ /* DATA info */
char dat[4];
Uint32 data_length;
} data_struct;
typedef struct
{
riff_struct rif_info;
fmt_struct fmt_info;
data_struct dat_info;
} wav_struct;
/*_____ D E C L A R A T I O N ______________________________________________*/
#endif /* _WAV_H_ */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -