Mercurial > hg > dmlib
annotate jssplr.h @ 191:0e02b81b05e1
Initial fadeout volume changed to 32767.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 06 Oct 2012 17:49:13 +0300 |
parents | 47c327fb321a |
children | b778cc2fe7c8 |
rev | line source |
---|---|
0 | 1 /* |
2 * miniJSS - Module playing routines | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
142 | 4 * (C) Copyright 2006-2012 Tecnic Software productions (TNSP) |
0 | 5 */ |
6 #ifndef JSSPLR_H | |
7 #define JSSPLR_H | |
8 | |
9 #include "jss.h" | |
10 #include "jssmod.h" | |
11 #include "jssmix.h" | |
12 | |
13 | |
14 // Player general constants | |
15 #define mpMinVol (0) | |
16 #define mpMaxVol (64) | |
17 #define mpPanCenter (0) | |
143
17a1c46db7eb
It would seem, based on tests, that the actual starting value for XM ext
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
18 //#define mpMaxFadeoutVol (65535) |
191
0e02b81b05e1
Initial fadeout volume changed to 32767.
Matti Hamalainen <ccr@tnsp.org>
parents:
188
diff
changeset
|
19 #define mpMaxFadeoutVol (32767) |
0 | 20 |
21 | |
22 // Channel New-Data flags | |
23 #define cdfNONE (0x00) // Set nothing | |
24 #define cdfNewInstr (0x01) // Set a new instrument | |
25 #define cdfNewPitch (0x02) // Set a new pitch | |
26 #define cdfNewPos (0x04) // Set a new position | |
27 #define cdfNewVolume (0x08) // Set a new volume | |
28 #define cdfNewPanPos (0x10) // Set a new panning position | |
29 #define cdfNewGlobalVol (0x20) // Set a new global volume | |
180
bc8019c38ba5
Refactoring of the note triggering and other player logic, fixes various
Matti Hamalainen <ccr@tnsp.org>
parents:
144
diff
changeset
|
30 #define cdfPlay (0x40) // Start or restart playing sample |
0 | 31 #define cdfStop (0x80) // Stop channel playing |
32 | |
33 | |
183
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
34 // Player envelope data |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
35 typedef struct |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
36 { |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
37 int frame, value; |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
38 BOOL exec; |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
39 } JSSPlayerEnvelope; |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
40 |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
41 |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
42 typedef struct |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
43 { |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
44 int pos, speed, depth, wc; |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
45 } JSSPlayerVData; |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
46 |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
47 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
48 // Player channel structure |
0 | 49 typedef struct |
50 { | |
183
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
51 JSSPlayerEnvelope volumeEnv, panningEnv; |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
52 |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
53 JSSPlayerVData vibrato, tremolo; |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
54 |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
55 BOOL keyOff; |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
56 |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
57 JSSInstrument *instrument; // Instrument |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
58 JSSExtInstrument *extInstrument; // ExtInstrument |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
59 int ninstrument, |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
60 nextInstrument, |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
61 note, // Current note |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
62 pitch, // Pitch (NOT actual frequency!) |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
63 oldPitch, |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
64 position, // Sample position |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
65 volume, // Volume |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
66 panning, // Panning position |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
67 |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
68 newDataFlags, // New data flags |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
69 |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
70 fadeOutVol, |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
71 |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
72 iCAutoVib_Frame, |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
73 |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
74 iCLastFineVolumeslideUpParam, |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
75 iCLastFineVolumeslideDownParam, |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
76 iCLastExtraFinePortamentoUpParam, |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
77 iCLastExtraFinePortamentoDownParam, |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
78 iCLastFinePortamentoUpParam, |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
79 iCLastFinePortamentoDownParam, |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
80 |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
81 iPatLoopRow, // Pattern loop start row |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
82 iPatLoopCount, // Pattern loop count |
0 | 83 |
84 iLastPortaParam, // Last portamento effect parameter | |
85 iLastPortaToNoteParam, // Last porta-to-note parameter | |
86 iLastPortaToNotePitch, // Last porta-to-note pitch | |
87 | |
88 iLastTremorParam, | |
89 iTremorCount, | |
90 iLastSampleOffset, | |
91 iLastRetrigParam, | |
92 iLastVolSlideParam, | |
93 | |
94 iRetrigNDFlags, // For retrig-effect | |
95 iSaveNDFlags; // For notedelay-effect | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
96 } JSSPlayerChannel; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
97 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
98 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
99 // Struct holding all player related information |
136 | 100 typedef struct _JSSPlayer |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
101 { |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
102 // General variables |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
103 int tempo, // Current values |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
104 speed, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
105 tick, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
106 order, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
107 npattern, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
108 row, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
109 globalVol, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
110 options; // Playing option flags |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
111 BOOL isPlaying; // Are we playing? |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
112 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
113 int newOrder, // NEW order number |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
114 newRow; // NEW row number |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
115 BOOL newOrderSet, // TRUE if new order has been set |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
116 newRowSet; // TRUE if new row has been set |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
117 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
118 int patternDelay, // Pattern delay tick-counter |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
119 lastPatLoopRow; // Latest set pattern loop row (any channel) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
120 |
183
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
121 BOOL jumpFlag, // Pattern jump flag |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
122 breakFlag; // Pattern break flag |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
123 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
124 // All channels for this player |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
125 // int nchannels; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
126 JSSPlayerChannel channels[jsetNChannels]; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
127 |
0 | 128 |
129 // Module and sounddevice specific | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
130 JSSModule *module; // Current module in this player |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
131 JSSPattern *pattern; // Current pattern |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
132 JSSMixer *device; // Pointer to mixing device structure |
0 | 133 |
134 #ifdef JSS_SUP_THREADS | |
135 DMMutex *mutex; | |
136 #endif | |
137 | |
138 } JSSPlayer; | |
139 | |
140 | |
141 /* External functions for end users | |
142 */ | |
143 int jmpPlayOrder(JSSPlayer *, int); | |
182
9024d249e47a
Add a new function jmpChangeOrder() to change orderlist position "on fly",
Matti Hamalainen <ccr@tnsp.org>
parents:
180
diff
changeset
|
144 int jmpChangeOrder(JSSPlayer *, int); |
0 | 145 int jmpPlayPattern(JSSPlayer *, int); |
146 void jmpStop(JSSPlayer *); | |
147 void jmpResume(JSSPlayer *); | |
148 void jmpSetModule(JSSPlayer *, JSSModule *); | |
149 JSSPlayer * jmpInit(JSSMixer *); | |
150 int jmpClose(JSSPlayer *); | |
151 void jmpExec(void *, void *); | |
152 | |
153 | |
154 /* Helper macros | |
155 */ | |
156 #define JMPMAKEPARAM(AIVAL, AVALX, AVALY) { AVALX = (((AIVAL) >> 4) & 0x0f); AVALY = ((AIVAL) & 0x0f); } | |
183
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
157 #define JMPSETNDFLAGS(IVAL) chn->newDataFlags |= IVAL |
a65f0c3deaa7
Some more player logic cleanups and variable renames.
Matti Hamalainen <ccr@tnsp.org>
parents:
182
diff
changeset
|
158 #define JMPUNSETNDFLAGS(IVAL) chn->newDataFlags &= (~(IVAL)) |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
159 #define JMPGETNOTE(MNOTE, MROW, MCHAN) assert(mp); assert(mp->pattern); assert((MROW) >= 0); assert((MROW) < mp->pattern->nrows); MNOTE = &mp->pattern->data[(mp->pattern->nchannels * MROW) + (MCHAN)] |
0 | 160 #define JMPGETEFFECT(MEFF, MIEFF) if ((MIEFF >= 0) && (MIEFF < jmpNMODEffectTable)) MEFF = jmpMODEffectTable[MIEFF]; else MEFF = 0 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
161 #define JMPGETMODFLAGS(Q, Z) ((Q->module->defFlags & (Z)) == (Z)) |
0 | 162 |
163 | |
164 /* Debugging macros | |
165 */ | |
166 #if !defined(JSS_LIGHT) && defined(JSS_DEBUG) | |
97
2884a611042b
Fix building with debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
167 # define JMPDEBUG(QQ) { fprintf(stderr, "[o=%03d:p=%03d:r=%03d] (%c/%x:%x) %s\n", mp->order, mp->npattern, mp->row, effect, currNote->effect, currNote->param, QQ ); } |
0 | 168 #else |
169 # define JMPDEBUG(QQ) // stub | |
170 #endif | |
171 | |
172 #endif // JSSPLR_H |