ex
Fork of mbed-os-example-mbed5-blinky by
DuerOS-Light-SDK-v1.1.0/duer-os-light/external/speex/wavfmt/wavfmt.h@47:9e361da97763, 2017-07-18 (annotated)
- Committer:
- TMBOY
- Date:
- Tue Jul 18 16:54:45 2017 +0800
- Revision:
- 47:9e361da97763
?
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| TMBOY | 47:9e361da97763 | 1 | #ifndef WAVFMT_H |
| TMBOY | 47:9e361da97763 | 2 | #define WAVFMT_H |
| TMBOY | 47:9e361da97763 | 3 | |
| TMBOY | 47:9e361da97763 | 4 | #ifdef __cplusplus |
| TMBOY | 47:9e361da97763 | 5 | extern "C" { |
| TMBOY | 47:9e361da97763 | 6 | #endif |
| TMBOY | 47:9e361da97763 | 7 | |
| TMBOY | 47:9e361da97763 | 8 | |
| TMBOY | 47:9e361da97763 | 9 | typedef struct { |
| TMBOY | 47:9e361da97763 | 10 | char chunkID[4]; |
| TMBOY | 47:9e361da97763 | 11 | long chunkSize; |
| TMBOY | 47:9e361da97763 | 12 | } ChunkHeader; |
| TMBOY | 47:9e361da97763 | 13 | |
| TMBOY | 47:9e361da97763 | 14 | |
| TMBOY | 47:9e361da97763 | 15 | #define RiffID "RIFF" /* chunk ID for RIFF Chunk */ |
| TMBOY | 47:9e361da97763 | 16 | #define RIFF_FORMAT "WAVE" |
| TMBOY | 47:9e361da97763 | 17 | |
| TMBOY | 47:9e361da97763 | 18 | typedef struct { |
| TMBOY | 47:9e361da97763 | 19 | char chunkID[4]; //'RIFF' |
| TMBOY | 47:9e361da97763 | 20 | long chunkSize; |
| TMBOY | 47:9e361da97763 | 21 | char RiffFmt[4]; //'WAVE' |
| TMBOY | 47:9e361da97763 | 22 | } RiffChunk; |
| TMBOY | 47:9e361da97763 | 23 | |
| TMBOY | 47:9e361da97763 | 24 | |
| TMBOY | 47:9e361da97763 | 25 | |
| TMBOY | 47:9e361da97763 | 26 | #define WAVE_FORMAT_PCM 0X01 |
| TMBOY | 47:9e361da97763 | 27 | #define WAVE_CHANNEL_MONO 1 |
| TMBOY | 47:9e361da97763 | 28 | #define WAVE_CHANNEL_STEREO 2 |
| TMBOY | 47:9e361da97763 | 29 | |
| TMBOY | 47:9e361da97763 | 30 | |
| TMBOY | 47:9e361da97763 | 31 | |
| TMBOY | 47:9e361da97763 | 32 | #define OFFSET_FMT_CHK sizeof(RiffChunk) |
| TMBOY | 47:9e361da97763 | 33 | #define FormatID "fmt " /* chunkID for Format Chunk. NOTE: There is a space at the end of this ID. */ |
| TMBOY | 47:9e361da97763 | 34 | |
| TMBOY | 47:9e361da97763 | 35 | typedef struct { |
| TMBOY | 47:9e361da97763 | 36 | char chunkID[4]; |
| TMBOY | 47:9e361da97763 | 37 | long chunkSize; |
| TMBOY | 47:9e361da97763 | 38 | short wFormatTag; |
| TMBOY | 47:9e361da97763 | 39 | unsigned short wChannels; |
| TMBOY | 47:9e361da97763 | 40 | unsigned long dwSamplesPerSec; |
| TMBOY | 47:9e361da97763 | 41 | unsigned long dwAvgBytesPerSec; |
| TMBOY | 47:9e361da97763 | 42 | unsigned short wBlockAlign; |
| TMBOY | 47:9e361da97763 | 43 | unsigned short wBitsPerSample; |
| TMBOY | 47:9e361da97763 | 44 | /* Note: there may be additional fields here, depending upon wFormatTag. */ |
| TMBOY | 47:9e361da97763 | 45 | |
| TMBOY | 47:9e361da97763 | 46 | } FormatChunk; |
| TMBOY | 47:9e361da97763 | 47 | |
| TMBOY | 47:9e361da97763 | 48 | |
| TMBOY | 47:9e361da97763 | 49 | #define OFFSET_DATA_CHK (OFFSET_FMT_CHK + sizeof(FormatChunk)) |
| TMBOY | 47:9e361da97763 | 50 | #define DataID "data" /* chunk ID for data Chunk */ |
| TMBOY | 47:9e361da97763 | 51 | |
| TMBOY | 47:9e361da97763 | 52 | typedef struct { |
| TMBOY | 47:9e361da97763 | 53 | char chunkID[4]; |
| TMBOY | 47:9e361da97763 | 54 | long chunkSize; |
| TMBOY | 47:9e361da97763 | 55 | |
| TMBOY | 47:9e361da97763 | 56 | unsigned char waveformData[]; |
| TMBOY | 47:9e361da97763 | 57 | } DataChunk; |
| TMBOY | 47:9e361da97763 | 58 | |
| TMBOY | 47:9e361da97763 | 59 | |
| TMBOY | 47:9e361da97763 | 60 | #define ListID "list" /* chunk ID for list Chunk */ |
| TMBOY | 47:9e361da97763 | 61 | |
| TMBOY | 47:9e361da97763 | 62 | typedef struct { |
| TMBOY | 47:9e361da97763 | 63 | char chunkID[4]; /* 'list' */ |
| TMBOY | 47:9e361da97763 | 64 | long chunkSize; /* includes the Type ID below */ |
| TMBOY | 47:9e361da97763 | 65 | char typeID[]; /* 'adtl' */ |
| TMBOY | 47:9e361da97763 | 66 | } ListHeader; |
| TMBOY | 47:9e361da97763 | 67 | |
| TMBOY | 47:9e361da97763 | 68 | |
| TMBOY | 47:9e361da97763 | 69 | #define WAVE_HEADER_SIZE (OFFSET_DATA_CHK + sizeof(DataChunk)) |
| TMBOY | 47:9e361da97763 | 70 | |
| TMBOY | 47:9e361da97763 | 71 | |
| TMBOY | 47:9e361da97763 | 72 | int wavfmt_remove_header(FILE *pFile); |
| TMBOY | 47:9e361da97763 | 73 | int wavfmt_add_riff_chunk(FILE *pFile, long size); |
| TMBOY | 47:9e361da97763 | 74 | int wavfmt_add_fmt_chunk(FILE *pFile, unsigned short wChannels, unsigned long dwSamplesPerSec, unsigned long dwAvgBytesPerSec, unsigned short wBitsPerSample); |
| TMBOY | 47:9e361da97763 | 75 | int wavfmt_add_data_chunk_header(FILE *pFile, long size); |
| TMBOY | 47:9e361da97763 | 76 | |
| TMBOY | 47:9e361da97763 | 77 | |
| TMBOY | 47:9e361da97763 | 78 | #ifdef __cplusplus |
| TMBOY | 47:9e361da97763 | 79 | } |
| TMBOY | 47:9e361da97763 | 80 | #endif |
| TMBOY | 47:9e361da97763 | 81 | |
| TMBOY | 47:9e361da97763 | 82 | |
| TMBOY | 47:9e361da97763 | 83 | #endif |
