libdragon
Loading...
Searching...
No Matches
wav64_internal.h
1#ifndef __LIBDRAGON_WAV64_INTERNAL_H
2#define __LIBDRAGON_WAV64_INTERNAL_H
3
4#define WAV64_ID "WV64"
5#define WAV64_FILE_VERSION 2
6#define WAV64_FORMAT_RAW 0
7#define WAV64_FORMAT_VADPCM 1
8#define WAV64_FORMAT_OPUS 3
9#define WAV64_NUM_FORMATS 4
10
11typedef struct wav64_s wav64_t;
12typedef struct samplebuffer_s samplebuffer_t;
13
15typedef struct __attribute__((packed)) {
16 char id[4];
17 int8_t version;
18 int8_t format;
19 int8_t channels;
20 int8_t nbits;
21 int32_t freq;
22 int32_t len;
23 int32_t loop_len;
24 int32_t start_offset;
26
27_Static_assert(sizeof(wav64_header_t) == 24, "invalid wav64_header size");
28
30typedef struct __attribute__((aligned(8))) {
31 int16_t v[8];
33
35typedef struct __attribute__((packed, aligned(8))) {
36 int8_t npredictors;
37 int8_t order;
38 uint16_t padding;
39 uint32_t padding1;
40 wav64_vadpcm_vector_t loop_state[2];
44
46typedef struct {
48 void (*init)(wav64_t *wav);
50 void (*close)(wav64_t *wav);
52 int (*get_bitrate)(wav64_t *wav);
54
60void raw_waveform_read(samplebuffer_t *sbuf, int fd, int wpos, int wlen, int bps);
61
68void raw_waveform_read_address(samplebuffer_t *sbuf, int rom_addr, int wpos, int wlen, int bps);
69#endif
Definition samplebuffer.h:82
WAV64 pluggable compression algorithm.
Definition wav64_internal.h:46
Header of a WAV64 file.
Definition wav64_internal.h:15
int8_t channels
Number of interleaved channels.
Definition wav64_internal.h:19
int8_t version
Version of the file (WAV64_FILE_VERSION)
Definition wav64_internal.h:17
int8_t format
Format of the file (WAV64_FORMAT_RAW)
Definition wav64_internal.h:18
int8_t nbits
Width of sample in bits (8 or 16)
Definition wav64_internal.h:20
int32_t freq
Default playback frequency.
Definition wav64_internal.h:21
int32_t start_offset
Offset of the first sample in the file.
Definition wav64_internal.h:24
int32_t len
Length of the file (in samples)
Definition wav64_internal.h:22
int32_t loop_len
Length of the loop since file end (or 0 if no loop)
Definition wav64_internal.h:23
Extended header for a WAV64 file with VADPCM compression.
Definition wav64_internal.h:35
uint32_t padding1
padding1
Definition wav64_internal.h:39
uint16_t padding
padding
Definition wav64_internal.h:38
int8_t npredictors
Number of predictors.
Definition wav64_internal.h:36
int8_t order
Order of the predictors.
Definition wav64_internal.h:37
A vector of audio samples.
Definition wav64_internal.h:30
int close(int fildes)
Close a file.
Definition system.c:577
void raw_waveform_read(samplebuffer_t *sbuf, int current_fd, int wpos, int wlen, int bps)
Utility function to help implementing WaveformRead for uncompressed (raw) samples.
Definition wav64.c:59
void raw_waveform_read_address(samplebuffer_t *sbuf, int base_rom_addr, int wpos, int wlen, int bps)
Utility function to help implementing WaveformRead for uncompressed (raw) samples.
Definition wav64.c:69
WAV64 structure.
Definition wav64.h:32