Developer World
Spresense SDK Library v3.3.0-375c679
wav_containerformat_parser.h
1/****************************************************************************
2 * modules/include/audio/utilities/wav_containerformat_parser.h
3 *
4 * Copyright 2018 Sony Semiconductor Solutions Corporation
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17 * the names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior written
19 * permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 ****************************************************************************/
35
36#ifndef MODULES_INCLUDE_AUDIO_UTILITIES_WAV_CONTAINERFORMAT_PARSER_H
37#define MODULES_INCLUDE_AUDIO_UTILITIES_WAV_CONTAINERFORMAT_PARSER_H
38
39#include "audio/utilities/wav_containerformat_common.h"
40
41typedef void* handel_wav_parser;
42
43/* For line buffer mode. */
44
45#define STDIO_BUFFER_SIZE 4096
46
47#define MAX_CHUNK_LIST 128
48
51struct chunk_s
52{
55 uint32_t chunk_id;
56
59 int32_t size;
60};
61typedef struct chunk_s chunk_t;
62
66{
69 uint8_t cnt;
70
73 chunk_t chunk[MAX_CHUNK_LIST];
74};
75typedef struct chunk_list_s chunk_list_t;
76
80{
81 struct chunk_s chunk;
82 uint32_t type;
83};
84typedef struct riff_chunk_s riff_chunk_t;
85
89{
92 uint16_t format;
93
96 uint16_t channel;
97
100 uint32_t rate;
101
104 uint32_t avgbyte;
105
108 uint16_t block;
109
112 uint16_t bit;
113
117};
118typedef struct fmt_chunk_s fmt_chunk_t;
119
123{
124 chunk_list_t chunk_list;
125 uint32_t chunk_offset[MAX_CHUNK_LIST];
126 uint32_t data_offset;
127 uint32_t cur_offset;
128 uint32_t file_size;
129 uint32_t data_size;
130 uint32_t read_size;
131 FILE *fd;
132};
134
138{
139public:
142
155 handel_wav_parser parseChunk(const char *file_path, fmt_chunk_t *fmt);
156
168 bool getChunkList(handel_wav_parser handle, chunk_list_t *list);
169
182 bool getChunk(handel_wav_parser handle, uint32_t chunk_id, int8_t *buffer);
183
197 int32_t getDataChunk(handel_wav_parser handle, uint16_t format, int8_t *buffer, uint32_t size);
198
207 void resetParser(handel_wav_parser handle);
208
209private:
210};
211
212#endif /* MODULES_INCLUDE_AUDIO_UTILITIES_WAV_CONTAINERFORMAT_PARSER_H */
Definition: wav_containerformat_parser.h:138
bool getChunk(handel_wav_parser handle, uint32_t chunk_id, int8_t *buffer)
Get Chunk.
void resetParser(handel_wav_parser handle)
Reset Parser.
handel_wav_parser parseChunk(const char *file_path, fmt_chunk_t *fmt)
Parse WAV container.
bool getChunkList(handel_wav_parser handle, chunk_list_t *list)
Get Chunk List.
int32_t getDataChunk(handel_wav_parser handle, uint16_t format, int8_t *buffer, uint32_t size)
Get Data Chunk.
Definition: wav_containerformat_parser.h:66
uint8_t cnt
Number of chunks in a list.
Definition: wav_containerformat_parser.h:69
chunk_t chunk[MAX_CHUNK_LIST]
Chunk list (MAX num is MAX_CHUNK_LIST)
Definition: wav_containerformat_parser.h:73
Definition: wav_containerformat_parser.h:52
uint32_t chunk_id
Chunk ID.
Definition: wav_containerformat_parser.h:55
int32_t size
Chunk size.
Definition: wav_containerformat_parser.h:59
Definition: wav_containerformat_parser.h:89
uint16_t extended_size
extend area size
Definition: wav_containerformat_parser.h:116
uint16_t bit
bit per sample
Definition: wav_containerformat_parser.h:112
uint16_t block
block size
Definition: wav_containerformat_parser.h:108
uint16_t channel
Number of channel.
Definition: wav_containerformat_parser.h:96
uint16_t format
Number of chunks in a list.
Definition: wav_containerformat_parser.h:92
uint32_t avgbyte
Averate byte per second.
Definition: wav_containerformat_parser.h:104
uint32_t rate
Sampling rate (fs)
Definition: wav_containerformat_parser.h:100
Definition: wav_containerformat_parser.h:123
Definition: wav_containerformat_parser.h:80