2 * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #define __PACK __attribute__((packed))
20 typedef struct chunk_header {
29 char type[4]; /* WAVE */
33 #define FormatID "fmt "
35 short wFormatTag; /* other than 1, compressed */
36 unsigned short wChannels;
37 unsigned long dwSamplesPerSec; /* 11025, 22050, 44100 Khz ... */
38 unsigned long dwAvBytesPerSec; /* dwSamplesPerSec * wBlockAlign */
40 /* 16-bit mono wave = 2 Bytes */
41 /* 16-bit stereo wave = 4 Bytes */
42 /* wChannels * (wBitsPerSample / 8) == Size of a sample frame, in terms of byte */
43 unsigned short wBlockAlign;
44 unsigned short wBitsPerSample; /* 16-bit waveform would have 16 */
46 /* NOTE: Depends on wFormatTag, here could be more fields exists */
51 IBM_FORMAT_MULAW = 0x0101,
52 IBM_FORMAT_ALAW = 0x0102,
53 IBM_FORMAT_ADPCM = 0x0103,
60 /* ... ( 0x1 << nr of channels ) */
66 unsigned char waveformData[1];
72 unsigned long fccChunk;
91 #define PlaylistID "plst"
96 } __PACK PlaylistChunk;
102 #define LabelID "labl"
108 #define NoteID "note"
114 #define LabelTextID "ltxt"
124 } __PACK LabelTextChunk;
126 #define SamplerID "smpl"
141 long dwMIDIUnityNote;
142 long dwMIDIPitchFraction;
148 } __PACK SamplerChunk;
153 FRAME30_WITH_DROP = 29,
163 #define InstrumentID "inst"
165 unsigned char UnshiftedNote;
168 unsigned char LowNote;
169 unsigned char HighNote;
170 unsigned char LowVelocity;
171 unsigned char HighVelocity;
172 } __PACK InstrumentChunk;
174 #define ListID "list"
180 #define FactID "fact"
189 chunk_header riff_header;
191 /* RIFFChunk *riff; */
193 chunk_header fmt_header;
195 /* FormatChunk *format; */
197 chunk_header data_header;
199 /* DataChunk *data; */
201 chunk_header list_header;
203 /* ListChunk *list; */
206 extern struct wave *open_wave_file(const char *filename);
207 extern int get_wave_channel(struct wave *handle);
208 extern int get_wave_samples_per_sec(struct wave *handle);
209 extern int get_wave_bits_per_sample(struct wave *handle);
210 extern int get_wave_data_size(struct wave *handle);
211 extern int get_wave_data(struct wave *handle, void *data, int off, int size);
212 extern void close_wave_file(struct wave *handle);