git ssb

0+

kode54 / syntrax-c



Tree: efff0d5be49e438aefc3460617744c5e1dd1be61

Files: efff0d5be49e438aefc3460617744c5e1dd1be61 / src / syntrax / syntrax.h

8690 bytesRaw
1#ifndef SYNTRAX_H
2#define SYNTRAX_H
3
4#include <stdint.h>
5
6//----------------------------typedefs-------------------------
7#ifndef NULL
8#define NULL 0
9#endif
10typedef unsigned uint;
11#ifndef __cplusplus
12typedef enum { false, true } bool;
13#endif
14
15//----------------------------defines--------------------------
16#define SE_NROFEFFECTS 18
17#define SE_MAXCHANS 16
18#define SE_NROFFINETUNESTEPS 16
19
20#define SE_OVERLAP 100
21
22#define BUFFERLENGTH 4096
23#define CHANNELS 2
24#define BITRATE 16
25#define RESAMPLE_POINTS 4
26
27//some constants for controlling stuff
28//I've no idea what the abreviations stand for
29#define SE_PM_SONG 0
30#define SE_PM_PATTERN 1
31
32
33//---------------------------structures------------------------
34//player structs
35//don't pack these
36typedef struct
37{
38 int wavelength;
39 int gainDelay;
40 int delta;
41 int freq;
42 int isSample;
43 int isPlayingBackward;
44 int smpLoopEnd;
45 int PPMXBYLQ; //unused
46 int gain;
47 const int16_t *waveBuff;
48 int hasBidiLoop;
49 int synthPos;
50 int gainRight;
51 int smpLoopStart;
52 int bkpSynthPos;
53 int sampPos;
54 int gainLeft;
55 int hasLoop;
56 int smpLength;
57 int gainDelayRight;
58 int gainDelayLeft;
59 int hasLooped;
60 void * resampler[2];
61 int last_delta;
62} Voice;
63
64typedef struct
65{
66 int VMBNMTNBQU;
67 int TIPUANVVR;
68 double MDTMBBIQHRQ;
69 double YLKJB;
70 double DQVLFV;
71 int MFATTMREMVP;
72 double ILHG;
73 double RKF;
74 int SPYK;
75 int QOMCBTRPXF;
76 int ABJGHAUY;
77} VoiceEffect;
78
79typedef struct
80{
81 int JOEEPJCI;
82 int BNWIGU;
83 int isPlayingBackward;
84 int ELPHLDR;
85 int panning;
86 int TVORFCC;
87 int EYRXAB; //rather unused
88 int UHYDBDDI;
89 int XESAWSO;
90 int hasBidiLoop;
91 int fmDelay;
92 int volume;
93 int ACKCWV;
94 int sampPos;
95 int insNum;
96 int EQMIWERPIF;
97 int freq;
98 int HFRLJCG;
99 int VNVJPDIWAJQ;
100 int hasLoop;
101 int LJHG;
102 const int16_t *sampleBuffer;
103 //SQUASH effect overflows into next buffer
104 //SE_MAXCHANS * 0x100 + 1 must be allocated
105 int16_t synthBuffers[SE_MAXCHANS][0x100];
106 int16_t OVERFLOW_DUMMY;
107 int smpLoopStart;
108 int smpLoopEnd;
109 int hasLooped;
110 VoiceEffect effects[4];
111} TuneChannel;
112
113
114//data structs
115
116typedef struct
117{
118 uint32_t destWave;
119 uint32_t srcWave1;
120 uint32_t srcWave2;
121 uint32_t oscWave;
122 uint32_t variable1;
123 uint32_t variable2;
124 uint32_t fxSpeed;
125 uint32_t oscSpeed;
126 uint32_t effectType;
127 int8_t oscSelect;
128 int8_t resetEffect;
129 int16_t UNK00;
130} InstrumentEffect;
131
132typedef struct
133{
134 int16_t version;
135 char name[33];
136 int16_t waveform;
137 int16_t wavelength;
138 int16_t masterVolume;
139 int16_t amWave;
140 int16_t amSpeed;
141 int16_t amLoopPoint;
142 int16_t finetune;
143 int16_t fmWave;
144 int16_t fmSpeed;
145 int16_t fmLoopPoint;
146 int16_t fmDelay;
147 int16_t arpIndex;
148 uint8_t m_ResetWave[SE_MAXCHANS];
149 int16_t panWave;
150 int16_t panSpeed;
151 int16_t panLoopPoint;
152 int16_t UNK00;
153 int16_t UNK01;
154 int16_t UNK02;
155 int16_t UNK03;
156 int16_t UNK04;
157 int16_t UNK05;
158 InstrumentEffect effects[4];
159 //why do we even need to store a full path?
160 //only filename appears to be used.
161 char smpFullImportPath[193];
162 uint32_t UNK06;
163 uint32_t UNK07;
164 uint32_t UNK08;
165 uint32_t UNK09;
166 uint32_t UNK0A;
167 uint32_t UNK0B;
168 uint32_t UNK0C;
169 uint32_t UNK0D;
170 uint32_t UNK0E;
171 uint32_t UNK0F;
172 uint32_t UNK10;
173 uint32_t UNK11;
174 int16_t UNK12;
175 int16_t shareSmpDataFromInstr; //0 is off
176 int16_t hasLoop;
177 int16_t hasBidiLoop;
178 uint32_t smpStartPoint;
179 uint32_t smpLoopPoint;
180 uint32_t smpEndPoint;
181 uint32_t hasSample;
182 uint32_t smpLength;
183 int16_t synthBuffers[SE_MAXCHANS][0x100];
184} Instrument;
185
186typedef struct
187{
188 uint8_t note;
189 uint8_t dest;
190 uint8_t instr;
191 int8_t spd;
192 uint8_t command;
193} Row;
194
195typedef struct
196{
197 int16_t patIndex; //0 means empty
198 int16_t patLen;
199} Order;
200
201typedef struct
202{
203 uint32_t UNK00[16];
204 //UNK00 is used for something. No idea what.
205 //There is a sequence to the data in it.
206 //zeroing it out with hex editor doesn't seem to break stuff with Jaytrax
207 //it could as well be uninitialized memory
208 uint8_t mutedChans[SE_MAXCHANS];
209 uint32_t tempo;
210 uint32_t groove;
211 uint32_t startPosCoarse;
212 uint32_t startPosFine;
213 uint32_t endPosCoarse;
214 uint32_t endPosFine;
215 uint32_t loopPosCoarse;
216 uint32_t loopPosFine;
217 int16_t isLooping;
218 char m_Name[33];
219 int16_t channelNumber;
220 uint16_t delayTime;
221 uint8_t chanDelayAmt[SE_MAXCHANS];
222 int16_t amplification;
223 int16_t UNK01;
224 int16_t UNK02;
225 int16_t UNK03;
226 int16_t UNK04;
227 int16_t UNK05;
228 int16_t UNK06;
229 //if my eyes don't deceive me, this actually happens
230 //waste of space
231 Order orders[SE_MAXCHANS][0x100];
232} Subsong;
233
234typedef struct
235{
236 uint16_t version;
237 uint16_t UNK00;
238 uint32_t patNum;
239 uint32_t subsongNum;
240 uint32_t instrNum;
241 uint32_t UNK01;
242 int16_t UNK02;
243 int16_t UNK03;
244 int16_t UNK04;
245 int16_t UNK05;
246 int16_t UNK06;
247 int16_t UNK07;
248 int16_t UNK08;
249 int16_t UNK09;
250 int16_t UNK0A;
251 int16_t UNK0B;
252 int16_t UNK0C;
253 int16_t UNK0D;
254 int16_t UNK0E;
255 int16_t UNK0F;
256 int16_t UNK10;
257 int16_t UNK11;
258} SongHeader;
259
260
261typedef struct
262{
263 SongHeader h;
264 int8_t arpTable[0x100];
265
266 Row *rows;
267 //we don't know what maximum pat name length should be
268 //in fact this is probably a buffer overflow target in Syntrax(app crashed on too long name, from UI);
269 uint32_t *patNameSizes;
270 char **patternNames;
271 Instrument *instruments;
272 Subsong *subsongs;
273 int16_t **samples;
274} Song;
275
276
277typedef struct Player
278{
279 int16_t *silentBuffer;
280 uint8_t m_LastNotes[SE_MAXCHANS];
281
282 uint32_t *freqTable;
283 int16_t *dynamorphTable;
284
285 const Song *synSong;
286 TuneChannel *tuneChannels;
287 Voice *voices;
288
289 int SAMPLEFREQUENCY;
290
291 int samplesPerBeat;
292 int otherSamplesPerBeat;
293 int someCounter;
294 int channelNumber;
295 int sePmSong;
296 int16_t *overlapBuff;
297 int16_t *delayBufferR;
298 int16_t *delayBufferL;
299
300 int bkpDelayPos;
301 int delayPos;
302 int gainPos;
303 int overlapPos;
304
305 int ISWLKT;
306 int WDTECTE;
307 int PQV;
308 int AMVM;
309 int DONGS;
310 int posCoarse;
311 int AMYGPFQCHSW;
312 int posFine;
313 int8_t mutedChans[SE_MAXCHANS];
314
315 int selectedSubsong;
316 Subsong curSubsong;
317
318 //local pointers to song structures
319 const Row *rows;
320 const char ** patternNames;
321 Instrument *instruments;
322 const Subsong *subsongs;
323 const int8_t *arpTable;
324 const int16_t **samples;
325
326 uint bufflen;
327
328 uint loopCount;
329} Player;
330
331
332//---------------------------prototypes------------------------
333#ifdef __cplusplus
334extern "C" {
335#endif
336
337Player * playerCreate(int sampleFrequency);
338void playerDestroy(Player *);
339
340int loadSong(Player *, const Song *);
341void initSubsong(Player *, int num);
342
343void mixChunk(Player *, int16_t *outBuff, uint playbackBufferSize);
344
345void playInstrument(Player *, int chanNum, int instrNum, int note); //could be handy dandy
346
347bool playerGetSongEnded(Player *);
348uint playerGetLoopCount(Player *);
349
350typedef struct _stmi
351{
352 unsigned char coarse;
353 unsigned char fine;
354 unsigned char channelsPlaying;
355 char subsongName[33];
356 int selectedSubs;
357 int totalSubs;
358} syntrax_info;
359
360void playerGetInfo(Player *, syntrax_info *);
361
362#ifdef __cplusplus
363}
364#endif
365#endif
366

Built with git-ssb-web