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