Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
vadpcm.h
Go to the documentation of this file.
1 #ifndef VADPCM_H
2 #define VADPCM_H
3 
4 #include <stdio.h>
5 
6 typedef signed char s8;
7 typedef short s16;
8 typedef int s32;
9 typedef long long s64;
10 typedef unsigned char u8;
11 typedef unsigned short u16;
12 typedef unsigned int u32;
13 typedef unsigned long long u64;
14 typedef float f32;
15 typedef double f64;
16 
17 #ifdef __sgi
18 # define BSWAP16(x)
19 # define BSWAP32(x)
20 # define BSWAP16_MANY(x, n)
21 #else
22 # define BSWAP16(x) x = __builtin_bswap16(x);
23 # define BSWAP32(x) x = __builtin_bswap32(x);
24 # define BSWAP16_MANY(x, n) { s32 _i; for (_i = 0; _i < n; _i++) BSWAP16((x)[_i]) }
25 #endif
26 
27 #ifdef __sgi
28 # define MODE_READ "r"
29 # define MODE_WRITE "w"
30 #else
31 # define MODE_READ "rb"
32 # define MODE_WRITE "wb"
33 #endif
34 
35 typedef struct {
36  u32 ckID;
37  u32 ckSize;
38 } ChunkHeader;
39 
40 typedef struct {
41  u32 ckID;
42  u32 ckSize;
43  u32 formType;
44 } Chunk;
45 
46 typedef struct {
47  s16 numChannels;
48  u16 numFramesH;
49  u16 numFramesL;
50  s16 sampleSize;
51  s16 sampleRate[5]; // 80-bit float
52  u16 compressionTypeH;
53  u16 compressionTypeL;
54 } CommonChunk;
55 
56 typedef struct {
57  s16 MarkerID;
58  u16 positionH;
59  u16 positionL;
60 } Marker;
61 
62 typedef struct {
63  s16 playMode;
64  s16 beginLoop;
65  s16 endLoop;
66 } Loop;
67 
68 typedef struct {
69  s8 baseNote;
70  s8 detune;
71  s8 lowNote;
72  s8 highNote;
73  s8 lowVelocity;
74  s8 highVelocity;
75  s16 gain;
76  Loop sustainLoop;
77  Loop releaseLoop;
79 
80 typedef struct {
81  s32 offset;
82  s32 blockSize;
84 
85 typedef struct {
86  s16 version;
87  s16 order;
88  s16 nEntries;
89 } CodeChunk;
90 
91 typedef struct
92 {
93  u32 start;
94  u32 end;
95  u32 count;
96  s16 state[16];
97 } ALADPCMloop;
98 
99 // vpredictor.c
100 s32 readcodebook(FILE *fhandle, s32 ****table, s32 *order, s32 *npredictors);
101 s32 readaifccodebook(FILE *fhandle, s32 ****table, s16 *order, s16 *npredictors);
102 s32 inner_product(s32 length, s32 *v1, s32 *v2);
103 
104 // quant.c
105 s16 qsample(f32 x, s32 scale);
106 void clamp(s32 fs, f32 *e, s32 *ie, s32 bits);
107 s32 clip(s32 ix, s32 llevel, s32 ulevel);
108 
109 // vdecode.c
110 void vdecodeframe(FILE *ifile, s32 *outp, s32 order, s32 ***coefTable);
111 
112 // vencode.c
113 void vencodeframe(FILE *ofile, s16 *inBuffer, s32 *state, s32 ***coefTable, s32 order, s32 npredictors, s32 nsam);
114 
115 // util.c
116 u32 readbits(u32 nbits, FILE *ifile);
117 char *ReadPString(FILE *ifile);
118 s32 lookupMarker(u32 *sample, s16 loopPoint, Marker *markers, s32 nmarkers);
119 ALADPCMloop *readlooppoints(FILE *ifile, s16 *nloops);
120 
121 // sampleio.c
122 void writeout(FILE *outfd, s32 size, s32 *l_out, s32 *r_out, s32 chans);
123 
124 #endif
s32 lookupMarker(u32 *sample, s16 loopPoint, Marker *markers, s32 nmarkers)
Definition: util.c:74
short s16
Definition: vadpcm.h:7
signed char s8
Definition: ultratypes.h:11
unsigned short int u16
Definition: ultratypes.h:14
u32 readbits(u32 nbits, FILE *ifile)
Definition: util.c:26
long long s64
Definition: vadpcm.h:9
void writeout(FILE *outfd, s32 size, s32 *l_out, s32 *r_out, s32 chans)
Definition: sampleio.c:27
signed short int s16
Definition: ultratypes.h:13
Definition: aifc_decode.c:81
double f64
Definition: vadpcm.h:15
s32 readaifccodebook(FILE *fhandle, s32 ****table, s16 *order, s16 *npredictors)
Definition: aifc_decode.c:158
s32 inner_product(s32 length, s32 *v1, s32 *v2)
Definition: aifc_decode.c:218
void clamp(s32 fs, f32 *e, s32 *ie, s32 bits)
Round all (&#39;fs&#39; many) values in &#39;e&#39; to the nearest &#39;bits&#39;-bit integer, outputting to &#39;ie&#39;...
Definition: quant.c:23
Definition: aifc_decode.c:31
signed char s8
Definition: vadpcm.h:6
Definition: aifc_decode.c:64
int s32
Definition: vadpcm.h:8
Definition: aifc_decode.c:36
float f32
Definition: ultratypes.h:29
s32 readcodebook(FILE *fhandle, s32 ****table, s32 *order, s32 *npredictors)
Definition: vpredictor.c:5
unsigned char u8
Definition: vadpcm.h:10
void vencodeframe(FILE *ofile, s16 *inBuffer, s32 *state, s32 ***coefTable, s32 order, s32 npredictors, s32 nsam)
Definition: vencode.c:6
ALADPCMloop * readlooppoints(FILE *ifile, s16 *nloops)
Definition: aifc_decode.c:203
Definition: libaudio_internal.h:23
Definition: aifc_decode.c:42
void vdecodeframe(FILE *ifile, s32 *outp, s32 order, s32 ***coefTable)
Definition: vdecode.c:4
char * ReadPString(FILE *ifile)
Definition: util.c:58
Definition: aifc_decode.c:76
Loop
Definition: assemble_sound.py:42
s32 clip(s32 ix, s32 llevel, s32 ulevel)
Clamp ix to within [llevel, ulevel].
Definition: quant.c:56
s16 qsample(f32 x, s32 scale)
Compute x / scale rounded to the nearest integer, with x.5 (fuzzy with an epsilon of 1e-7) rounding t...
Definition: quant.c:7
Definition: aifc_decode.c:52
signed int s32
Definition: ultratypes.h:15
unsigned short u16
Definition: vadpcm.h:11
Definition: aifc_decode.c:58
unsigned int u32
Definition: ultratypes.h:16
unsigned int u32
Definition: vadpcm.h:12
float f32
Definition: vadpcm.h:14
unsigned long long u64
Definition: vadpcm.h:13