Mercurial > hg > dmlib
annotate minijss/jssmod.h @ 1178:f1bbac567942
Oops, forgot to commit this change to add the conversion table to
JSSExtInstrument structure.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Mar 2015 10:02:17 +0200 |
parents | aa3738b121d1 |
children | cb31e57982f2 |
rev | line source |
---|---|
0 | 1 /* |
2 * miniJSS - Module structure and handling routines | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
1163 | 4 * (C) Copyright 2006-2015 Tecnic Software productions (TNSP) |
0 | 5 */ |
6 #ifndef JSSMOD_H | |
7 #define JSSMOD_H | |
8 | |
9 #include "jss.h" | |
10 #include "dmres.h" | |
11 | |
358 | 12 #ifdef __cplusplus |
13 extern "C" { | |
14 #endif | |
0 | 15 |
16 // Max data size definitions | |
17 #define jsetMaxRows (256) // Max number of rows | |
18 #define jsetMaxPatterns (256) // Max patterns | |
19 #define jsetMaxTracks (jsetMaxPatterns * jsetMaxPatterns) // Max tracks | |
20 #define jsetMaxInstruments (512) | |
21 #define jsetMaxOrders (260) | |
22 #define jsetNNotes (11 * 12) | |
23 #define jsetMinNote (0) // Smallest note number | |
24 #define jsetMaxNote (jsetNNotes - 1) | |
25 #define jsetMaxEnvPoints (32) // Max number of envelope points | |
26 | |
27 | |
28 // Instrument envelope flags | |
29 #define jenvfUsed (0x01) // Envelope is used | |
30 #define jenvfSustain (0x02) // Envelope has a sustain point (XM) or has sustain loop (IT) | |
31 #define jenvfLooped (0x04) // Envelope is looped | |
32 | |
33 // Instrument vibrato waveform types | |
34 #define jvibSine (0) | |
35 #define jvibRamp (1) | |
36 #define jvibSquare (2) | |
37 #define jvibRandom (3) | |
38 | |
39 // General stuff | |
40 #define jsetNoteOff (-2) | |
41 #define jsetOrderEnd (-1) | |
42 #define jsetOrderSkip (-2) | |
43 | |
44 | |
45 // General module flags | |
46 #define jmdfAmigaPeriods (0x0001) // Use non-linear periods (Amiga) | |
47 #define jmdfAmigaLimits (0x0002) // Use Amiga-styled valuelimits | |
48 #define jmdfStereo (0x0008) // Use stereo output, if possible | |
49 | |
50 #define jmdfFT2Replay (0x0010) // Use FT2 replaying bugs/features | |
51 #define jmdfST300Slides (0x0020) // Use Scream Tracker 3.00 slides | |
52 #define jmdfByteLStart (0x0040) // LStart is in BYTES instead of WORDS (MOD only) | |
53 | |
54 | |
55 // Module format types | |
56 enum JMDT | |
57 { | |
58 jmdtMOD = 1, | |
59 jmdtS3M, | |
60 jmdtXM, | |
61 jmdtIT | |
62 }; | |
63 | |
64 | |
65 // Bits for sample conversion routines | |
66 #define jsampDelta (0x01) | |
67 #define jsampFlipSign (0x02) | |
68 #define jsampSwapEndianess (0x04) | |
69 #define jsampSplit (0x08) | |
70 | |
71 | |
72 // Internal instrument structure | |
73 typedef struct | |
74 { | |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
75 int size, // Length in units |
0 | 76 loopS, // Loop start position in units |
77 loopE; // Loop end position in units | |
78 int volume, // Volume [jsetMinVol...jsetMaxVol] | |
79 flags, // Flags - see jss.h jsfXXXX | |
80 C4BaseSpeed, // C4BaseSpeed | |
81 ERelNote, // Extended: Relative note value | |
82 EFineTune, // Extended: Fine-tune value | |
83 EPanning; // Extended: Panning | |
84 #ifndef JSS_LIGHT | |
85 char *desc; | |
86 #endif | |
87 void *data; // Sample data | |
88 | |
89 BOOL hasData; | |
90 int convFlags; | |
91 } JSSInstrument; | |
92 | |
93 | |
94 // Envelope point structure | |
95 typedef struct | |
96 { | |
97 int frame, value; | |
98 } JSSEnvelopePoint; | |
99 | |
100 | |
101 // Envelope structure | |
102 typedef struct | |
103 { | |
104 int flags, | |
105 npoints, | |
106 sustain, | |
107 loopS, | |
108 loopE; | |
109 JSSEnvelopePoint points[jsetMaxEnvPoints]; | |
110 } JSSEnvelope; | |
111 | |
112 | |
113 // Extended instrument | |
114 typedef struct | |
115 { | |
116 #ifndef JSS_LIGHT | |
117 char *desc; | |
118 #endif | |
1178
f1bbac567942
Oops, forgot to commit this change to add the conversion table to
Matti Hamalainen <ccr@tnsp.org>
parents:
1163
diff
changeset
|
119 int nsamples, |
f1bbac567942
Oops, forgot to commit this change to add the conversion table to
Matti Hamalainen <ccr@tnsp.org>
parents:
1163
diff
changeset
|
120 sNumForNotes[jsetNNotes], |
f1bbac567942
Oops, forgot to commit this change to add the conversion table to
Matti Hamalainen <ccr@tnsp.org>
parents:
1163
diff
changeset
|
121 instConvTable[jsetNNotes]; |
0 | 122 JSSEnvelope volumeEnv, panningEnv; |
123 int vibratoType, | |
124 vibratoSweep, | |
125 vibratoDepth, | |
126 vibratoRate, | |
127 fadeOut; | |
128 } JSSExtInstrument; | |
129 | |
130 | |
131 // Internal pattern structures | |
132 typedef struct | |
133 { | |
134 int note, | |
135 instrument, | |
136 volume, | |
137 effect, | |
138 param; | |
139 } JSSNote; | |
140 | |
141 | |
142 typedef struct | |
143 { | |
144 int nrows, nchannels; | |
145 JSSNote *data; | |
146 } JSSPattern; | |
147 | |
148 | |
149 // Module structure | |
150 typedef struct | |
151 { | |
152 int moduleType; // Type of the module | |
153 char *moduleName; // Title/name | |
154 char *trackerName; // Tracker software name | |
155 int defSpeed, // Initial values | |
156 defTempo, | |
157 defFlags, | |
158 defRestartPos, | |
159 intVersion, // Format's internal version | |
160 nchannels, | |
161 ninstruments, | |
162 nextInstruments, | |
163 npatterns, | |
164 norders; | |
165 | |
166 int defPanning[jsetNChannels]; | |
167 int orderList[jsetMaxOrders]; | |
168 JSSPattern *patterns[jsetMaxPatterns + 1]; | |
169 JSSInstrument *instruments[jsetMaxInstruments]; | |
170 JSSExtInstrument *extInstruments[jsetMaxInstruments]; | |
171 | |
172 #ifdef JSS_SUP_THREADS | |
173 DMMutex *mutex; | |
174 #endif | |
175 | |
176 } JSSModule; | |
177 | |
178 | |
179 #ifdef JSS_SUP_JSSMOD | |
180 | |
181 #define JSSMOD_VERSION (0x10) | |
182 | |
183 enum | |
184 { | |
185 PATMODE_RAW_HORIZ = 1, | |
186 PATMODE_COMP_HORIZ, | |
187 PATMODE_RAW_VERT, | |
188 PATMODE_COMP_VERT, | |
189 PATMODE_RAW_ELEM, | |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
190 PATMODE_LAST |
0 | 191 }; |
192 | |
193 /* JSSMOD typedefs | |
194 */ | |
865
fc5bd0ccc260
Use struct packing and specific types for JSSMOD data.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
195 typedef struct __attribute__((__packed__)) |
0 | 196 { |
197 char idMagic[2]; // "JM" | |
198 Uint8 idVersion; // 0x10 for 1.0, etc. | |
199 Sint16 | |
200 norders, // Number of orders in orderlist | |
201 npatterns, // Number of patterns | |
202 nchannels, // Number of channels | |
203 nextInstruments, // Number of extended instruments | |
204 ninstruments, // Number of sample-instruments | |
205 defFlags, // Flags field: see jmdf* flags | |
206 intVersion, // Internal version, format dependant | |
207 defRestartPos, // Default restart position in orderlist | |
208 defSpeed, // Default speed (ticks/row) | |
209 defTempo, // Default tempo (BPM) | |
210 patMode; // Pattern data format mode | |
211 | |
212 /* | |
213 - After this, norders long orders table will follow, of type: | |
214 Sint16 orderList[norders]; | |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
215 |
0 | 216 - Pattern data, format depends on patMode. |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
217 |
0 | 218 - Extended instruments (*) |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
219 |
0 | 220 - Sample instrument headers (*) |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
221 |
0 | 222 - Sample data (format depends) (*) |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
223 |
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
224 (*) Items are optional and may have been omitted. Fields in the |
0 | 225 module and other headers are used to indicate if these items exist. |
226 */ | |
227 } JSSMODHeader; | |
228 | |
229 | |
865
fc5bd0ccc260
Use struct packing and specific types for JSSMOD data.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
230 typedef struct __attribute__((__packed__)) |
0 | 231 { |
232 Uint16 frame, value; | |
233 } JSSMODEnvelopePoint; | |
234 | |
235 | |
865
fc5bd0ccc260
Use struct packing and specific types for JSSMOD data.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
236 typedef struct __attribute__((__packed__)) |
0 | 237 { |
865
fc5bd0ccc260
Use struct packing and specific types for JSSMOD data.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
238 Sint32 |
fc5bd0ccc260
Use struct packing and specific types for JSSMOD data.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
239 flags, |
0 | 240 npoints, |
241 sustain, | |
242 loopS, | |
243 loopE; | |
244 JSSMODEnvelopePoint points[jsetMaxEnvPoints]; | |
245 } JSSMODEnvelope; | |
246 | |
247 | |
865
fc5bd0ccc260
Use struct packing and specific types for JSSMOD data.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
248 typedef struct __attribute__((__packed__)) |
0 | 249 { |
250 Sint16 nsamples; | |
251 Uint8 sNumForNotes[jsetNNotes]; | |
252 JSSMODEnvelope volumeEnv, panningEnv; | |
253 Sint16 vibratoType, | |
254 vibratoSweep, | |
255 vibratoDepth, | |
256 vibratoRate; | |
865
fc5bd0ccc260
Use struct packing and specific types for JSSMOD data.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
257 Sint32 fadeOut; |
0 | 258 } JSSMODExtInstrument; |
259 | |
260 | |
865
fc5bd0ccc260
Use struct packing and specific types for JSSMOD data.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
261 typedef struct __attribute__((__packed__)) |
0 | 262 { |
865
fc5bd0ccc260
Use struct packing and specific types for JSSMOD data.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
263 Sint32 size, // Length in units |
0 | 264 loopS, // Loop start position in units |
265 loopE; // Loop end position in units | |
266 Sint16 volume, // Volume [jsetMinVol...jsetMaxVol] | |
267 flags, // Flags - see jss.h jsfXXXX | |
268 C4BaseSpeed, // C4BaseSpeed | |
269 ERelNote, // Extended: Relative note value | |
270 EFineTune, // Extended: Fine-tune value | |
271 EPanning; // Extended: Panning | |
272 Uint8 convFlags, // Conversion flags .. jsampXXXX | |
273 hasData; // != 0 if there is sample data | |
274 } JSSMODInstrument; | |
275 | |
276 | |
277 #define COMP_NOTE (0x01) | |
278 #define COMP_INSTRUMENT (0x02) | |
279 #define COMP_VOLUME (0x04) | |
280 #define COMP_EFFECT (0x08) | |
281 #define COMP_PARAM (0x10) | |
282 #define COMP_ALL (COMP_NOTE | COMP_INSTRUMENT | COMP_VOLUME | COMP_EFFECT | COMP_PARAM) | |
283 | |
284 | |
865
fc5bd0ccc260
Use struct packing and specific types for JSSMOD data.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
285 typedef struct __attribute__((__packed__)) |
0 | 286 { |
865
fc5bd0ccc260
Use struct packing and specific types for JSSMOD data.
Matti Hamalainen <ccr@tnsp.org>
parents:
796
diff
changeset
|
287 Uint32 nrows, size; |
0 | 288 } JSSMODPattern; |
289 | |
290 #endif | |
291 | |
292 #ifndef JSS_LIGHT | |
948 | 293 char * jssASCIItoStr(const char *src, const char endByte, const size_t len); |
0 | 294 BOOL jssEncodeSample8(Uint8 *, const size_t, const int); |
295 BOOL jssEncodeSample16(Uint16 *, const size_t, const int); | |
296 #endif | |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
297 int jssDecodeSample8(Uint8 *, const size_t, const int); |
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
298 int jssDecodeSample16(Uint16 *, const size_t, const int); |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
299 int jssConvertModuleForPlaying(JSSModule *module); |
0 | 300 JSSModule * jssAllocateModule(void); |
301 int jssFreeModule(JSSModule *); | |
743 | 302 JSSPattern * jssAllocatePattern(const int, const int); |
0 | 303 JSSInstrument * jssAllocateInstrument(void); |
304 JSSExtInstrument * jssAllocateExtInstrument(void); | |
305 | |
306 #ifdef JSS_SUP_XM | |
796 | 307 int jssLoadXM(DMResource *, JSSModule **, BOOL); |
0 | 308 #endif |
309 | |
310 #ifdef JSS_SUP_JSSMOD | |
796 | 311 int jssLoadJSSMOD(DMResource *, JSSModule **, BOOL); |
0 | 312 #endif |
313 | |
358 | 314 #ifdef __cplusplus |
315 } | |
316 #endif | |
317 | |
0 | 318 #endif // JSSMOD_H |