1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (rwav.h).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef __LIBRETRO_SDK_FORMAT_RWAV_H__
24 #define __LIBRETRO_SDK_FORMAT_RWAV_H__
26 #include <retro_common_api.h>
34 unsigned int bitspersample;
36 /* number of channels */
37 unsigned int numchannels;
40 unsigned int samplerate;
42 /* number of *samples* */
45 /* number of *bytes* in the pointer below, i.e. numsamples * numchannels * bitspersample/8 */
54 RWAV_ITERATE_ERROR = -1,
55 RWAV_ITERATE_MORE = 0,
56 RWAV_ITERATE_DONE = 1,
57 RWAV_ITERATE_BUF_SIZE = 4096
60 typedef struct rwav_iterator rwav_iterator_t;
63 * Initializes the iterator to fill the out structure with data parsed from buf.
65 void rwav_init(rwav_iterator_t* iter, rwav_t* out, const void* buf, size_t size);
68 * Parses a piece of the data. Continue calling as long as it returns RWAV_ITERATE_MORE.
69 * Stop calling otherwise, and check for errors. If RWAV_ITERATE_DONE is returned,
70 * the rwav_t structure passed to rwav_init is ready to be used. The iterator does not
73 enum rwav_state rwav_iterate(rwav_iterator_t *iter);
76 * Loads the entire data in one go.
78 enum rwav_state rwav_load(rwav_t* out, const void* buf, size_t size);
81 * Frees parsed wave data.
83 void rwav_free(rwav_t *rwav);