Developer World
Spresense SDK Library v3.2.0-ebc0364
wav_containerformat.h
1/****************************************************************************
2 * modules/include/audio/utilities/wav_containerformat.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_H
37#define MODULES_INCLUDE_AUDIO_UTILITIES_WAV_CONTAINERFORMAT_H
38
39#include "audio/utilities/wav_containerformat_common.h"
40
43#define FORMAT_ID_PCM WAVE_FORMAT_PCM
44
47#define FMT_CHUNK_SIZE 16
48
52{
55 uint32_t riff;
56
59 uint32_t total_size;
60
63 uint32_t wave;
64
67 uint32_t fmt;
68
71 uint32_t fmt_size;
72
75 uint16_t format;
76
79 uint16_t channel;
80
83 uint32_t rate;
84
87 uint32_t avgbyte;
88
91 uint16_t block;
92
95 uint16_t bit;
96
99 uint32_t data;
100
101 uint32_t data_size;
102};
103typedef struct wav_header_s WAVHEADER;
104
106{
107public:
109 m_format_id(0),
110 m_channel_number(0),
111 m_sampling_rate(0),
112 m_bitwidth(0)
113 {}
115
127 bool init(uint16_t format_id,
128 uint16_t channel_number,
129 uint32_t sampling_rate);
130
142 bool init(uint16_t format_id,
143 uint16_t channel_number,
144 uint32_t sampling_rate,
145 uint8_t bitwidth);
146
157 bool getHeader(WAVHEADER *wav_header,
158 uint32_t data_size);
159
160private:
161 uint16_t m_format_id;
162 uint16_t m_channel_number;
163 uint32_t m_sampling_rate;
164 uint8_t m_bitwidth;
165};
166
167#endif /* MODULES_INCLUDE_AUDIO_UTILITIES_WAV_CONTAINERFORMAT_H */
Definition: wav_containerformat.h:106
bool init(uint16_t format_id, uint16_t channel_number, uint32_t sampling_rate)
Init function.
bool getHeader(WAVHEADER *wav_header, uint32_t data_size)
Get WAV header.
bool init(uint16_t format_id, uint16_t channel_number, uint32_t sampling_rate, uint8_t bitwidth)
Init function (Bitwidth can be specified)
Definition: wav_containerformat.h:52
uint16_t bit
bit length
Definition: wav_containerformat.h:95
uint16_t block
channels * bit / 8
Definition: wav_containerformat.h:91
uint32_t data
character "data"
Definition: wav_containerformat.h:99
uint16_t channel
channel number
Definition: wav_containerformat.h:79
uint16_t format
format type
Definition: wav_containerformat.h:75
uint32_t avgbyte
rate * block
Definition: wav_containerformat.h:87
uint32_t rate
sampling rate
Definition: wav_containerformat.h:83
uint32_t fmt_size
fmt chunk size
Definition: wav_containerformat.h:71
uint32_t wave
character "WAVE"
Definition: wav_containerformat.h:63
uint32_t total_size
Whole size exclude "RIFF".
Definition: wav_containerformat.h:59
uint32_t fmt
character "fmt "
Definition: wav_containerformat.h:67
uint32_t riff
character "RIFF"
Definition: wav_containerformat.h:55