Mercurial > hg > dmlib
annotate jssplr.h @ 182:9024d249e47a
Add a new function jmpChangeOrder() to change orderlist position "on fly",
and use it in PPL.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 06 Oct 2012 13:25:37 +0300 |
parents | bc8019c38ba5 |
children | a65f0c3deaa7 |
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) |
17a1c46db7eb
It would seem, based on tests, that the actual starting value for XM ext
Matti Hamalainen <ccr@tnsp.org>
parents:
142
diff
changeset
|
19 #define mpMaxFadeoutVol (32768) |
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 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
34 // Player channel structure |
0 | 35 typedef struct |
36 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
37 int iPatLoopRow, // Pattern loop start row |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
38 iPatLoopCount, // Pattern loop count |
0 | 39 |
40 iLastPortaParam, // Last portamento effect parameter | |
41 iLastPortaToNoteParam, // Last porta-to-note parameter | |
42 iLastPortaToNotePitch, // Last porta-to-note pitch | |
43 | |
44 iVibratoPos, // Vibrato waveform position | |
45 iVibratoSpeed, // Vibrato speed | |
46 iVibratoDepth, // Vibrato depth | |
47 iVibratoWC, // Vibrato wave control | |
48 | |
49 iTremoloPos, // Tremolo waveform position | |
50 iTremoloSpeed, // Tremolo speed | |
51 iTremoloDepth, // Tremolo depth | |
52 | |
53 iTremoloWC, // Tremolo wave control | |
54 | |
55 iLastTremorParam, | |
56 iTremorCount, | |
57 iLastSampleOffset, | |
58 iLastRetrigParam, | |
59 iLastVolSlideParam, | |
60 | |
61 iRetrigNDFlags, // For retrig-effect | |
62 iSaveNDFlags; // For notedelay-effect | |
63 | |
64 // Current channel data | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
65 JSSInstrument *iCInstrument; // Instrument |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
66 JSSExtInstrument *iCExtInstrument; // ExtInstrument |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
67 int iCInstrumentN, |
0 | 68 iCExtInstrumentN, |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
69 iCNote, // Current note |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
70 iCPitch, // Pitch (NOT actual frequency!) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
71 iCOldPitch, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
72 iCPosition, // Sample position |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
73 iCVolume, // Volume |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
74 iCPanning, // Panning position |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
75 |
0 | 76 iCNewDataFlags, // New data flags |
77 | |
78 iCFadeOutVol, | |
79 | |
80 iCPanEnv, | |
81 iCVolEnv, | |
82 | |
83 iCAutoVib_Frames, | |
84 iCPanEnv_Frames, | |
85 iCVolEnv_Frames, | |
86 | |
87 iCLastFineVolumeslideUpParam, | |
88 iCLastFineVolumeslideDownParam, | |
89 iCLastExtraFinePortamentoUpParam, | |
90 iCLastExtraFinePortamentoDownParam, | |
91 iCLastFinePortamentoUpParam, | |
92 iCLastFinePortamentoDownParam; | |
93 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
94 BOOL iCPanEnv_Exec, |
0 | 95 iCVolEnv_Exec, |
96 iCKeyOff; | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
97 } JSSPlayerChannel; |
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 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
100 // Struct holding all player related information |
136 | 101 typedef struct _JSSPlayer |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
102 { |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
103 // General variables |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
104 int tempo, // Current values |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
105 speed, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
106 tick, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
107 order, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
108 npattern, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
109 row, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
110 globalVol, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
111 options; // Playing option flags |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
112 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
|
113 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
114 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
|
115 newRow; // NEW row number |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
116 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
|
117 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
|
118 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
119 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
|
120 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
|
121 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
122 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
123 // 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
|
124 // int nchannels; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
125 JSSPlayerChannel channels[jsetNChannels]; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
126 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
127 // Parameters for effects, etc |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
128 BOOL jumpFlag, // Pattern jump flag |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
129 breakFlag; // Pattern break flag |
0 | 130 |
131 // 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
|
132 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
|
133 JSSPattern *pattern; // Current pattern |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
134 JSSMixer *device; // Pointer to mixing device structure |
0 | 135 |
144
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
136 struct _JSSPlayer *future; |
22e1be63f6af
Various improvements in XM replay: implement the 5ms volume fadein and
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
137 |
0 | 138 #ifdef JSS_SUP_THREADS |
139 DMMutex *mutex; | |
140 #endif | |
141 | |
142 } JSSPlayer; | |
143 | |
144 | |
145 /* External functions for end users | |
146 */ | |
147 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
|
148 int jmpChangeOrder(JSSPlayer *, int); |
0 | 149 int jmpPlayPattern(JSSPlayer *, int); |
150 void jmpStop(JSSPlayer *); | |
151 void jmpResume(JSSPlayer *); | |
152 void jmpSetModule(JSSPlayer *, JSSModule *); | |
153 JSSPlayer * jmpInit(JSSMixer *); | |
154 int jmpClose(JSSPlayer *); | |
155 void jmpExec(void *, void *); | |
156 | |
157 | |
158 /* Helper macros | |
159 */ | |
160 #define JMPMAKEPARAM(AIVAL, AVALX, AVALY) { AVALX = (((AIVAL) >> 4) & 0x0f); AVALY = ((AIVAL) & 0x0f); } | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
161 #define JMPSETNDFLAGS(IVAL) chn->iCNewDataFlags |= IVAL |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
162 #define JMPUNSETNDFLAGS(IVAL) chn->iCNewDataFlags &= (~(IVAL)) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
163 #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 | 164 #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
|
165 #define JMPGETMODFLAGS(Q, Z) ((Q->module->defFlags & (Z)) == (Z)) |
0 | 166 |
167 | |
168 /* Debugging macros | |
169 */ | |
170 #if !defined(JSS_LIGHT) && defined(JSS_DEBUG) | |
97
2884a611042b
Fix building with debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
171 # 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 | 172 #else |
173 # define JMPDEBUG(QQ) // stub | |
174 #endif | |
175 | |
176 #endif // JSSPLR_H |