0
|
1 /*
|
|
2 * miniJSS - Module playing routines
|
|
3 * Programmed and designed by Matti 'ccr' Hamalainen
|
|
4 * (C) Copyright 2006-2007 Tecnic Software productions (TNSP)
|
|
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)
|
|
18 #define mpMaxFadeoutVol (65535)
|
|
19
|
|
20
|
|
21 // Channel New-Data flags
|
|
22 #define cdfNONE (0x00) // Set nothing
|
|
23 #define cdfNewInstr (0x01) // Set a new instrument
|
|
24 #define cdfNewPitch (0x02) // Set a new pitch
|
|
25 #define cdfNewPos (0x04) // Set a new position
|
|
26 #define cdfNewVolume (0x08) // Set a new volume
|
|
27 #define cdfNewPanPos (0x10) // Set a new panning position
|
|
28 #define cdfNewGlobalVol (0x20) // Set a new global volume
|
|
29 #define cdfStop (0x80) // Stop channel playing
|
|
30
|
|
31
|
|
32 // Typedefs for channel structures
|
|
33 typedef int JDInt[jsetNChannels];
|
|
34 typedef BOOL JDBool[jsetNChannels];
|
|
35 typedef JSSInstrument * JDInst[jsetNChannels];
|
|
36 typedef JSSExtInstrument * JDEInst[jsetNChannels];
|
|
37
|
|
38
|
|
39 // Struct holding all player related information
|
|
40 typedef struct
|
|
41 {
|
|
42 // General variables
|
|
43 int iTempo, // Current values
|
|
44 iSpeed,
|
|
45 iTick,
|
|
46 iOrder,
|
|
47 iPattern,
|
|
48 iRow,
|
|
49 iGlobalVol,
|
|
50 iOptions; // Playing option flags
|
|
51 BOOL isPlaying; // Are we playing?
|
|
52
|
|
53 int iNewOrder, // NEW order number
|
|
54 iNewRow; // NEW row number
|
|
55 BOOL newOrderSet, // TRUE if new order has been set
|
|
56 newRowSet; // TRUE if new row has been set
|
|
57
|
|
58 // Parameters for effects, etc
|
|
59 BOOL jumpFlag, // Pattern jump flag
|
|
60 breakFlag; // Pattern break flag
|
|
61 int iPatternDelay, // Pattern delay tick-counter
|
|
62 iLastPatLoopRow; // Latest set pattern loop row (any channel)
|
|
63
|
|
64 JDInt iPatLoopRow, // Pattern loop start row for each channel
|
|
65 iPatLoopCount, // Pattern loop count for each channel
|
|
66
|
|
67 iLastPortaParam, // Last portamento effect parameter
|
|
68 iLastPortaToNoteParam, // Last porta-to-note parameter
|
|
69 iLastPortaToNotePitch, // Last porta-to-note pitch
|
|
70
|
|
71 iVibratoPos, // Vibrato waveform position
|
|
72 iVibratoSpeed, // Vibrato speed
|
|
73 iVibratoDepth, // Vibrato depth
|
|
74 iVibratoWC, // Vibrato wave control
|
|
75
|
|
76 iTremoloPos, // Tremolo waveform position
|
|
77 iTremoloSpeed, // Tremolo speed
|
|
78 iTremoloDepth, // Tremolo depth
|
|
79
|
|
80 iTremoloWC, // Tremolo wave control
|
|
81
|
|
82 iLastTremorParam,
|
|
83 iTremorCount,
|
|
84 iLastSampleOffset,
|
|
85 iLastRetrigParam,
|
|
86 iLastVolSlideParam,
|
|
87
|
|
88 iRetrigNDFlags, // For retrig-effect
|
|
89 iSaveNDFlags; // For notedelay-effect
|
|
90
|
|
91 // Current channel data
|
|
92 JDInst iCInstrument; // Instruments
|
|
93 JDEInst iCExtInstrument; // ExtInstruments
|
|
94 JDInt iCInstrumentN,
|
|
95 iCExtInstrumentN,
|
|
96 iCNewDataFlags, // New data flags
|
|
97 iCNote, // Current notes
|
|
98 iCPitch, // Pitches (NOT actual frequencies!)
|
|
99 iCOldPitch,
|
|
100 iCPosition, // Sample positions
|
|
101 iCVolume, // Volumes
|
|
102 iCPanning, // Panning positions
|
|
103
|
|
104 iCFadeOutVol,
|
|
105
|
|
106 iCPanEnv,
|
|
107 iCVolEnv,
|
|
108
|
|
109 iCAutoVib_Frames,
|
|
110 iCPanEnv_Frames,
|
|
111 iCVolEnv_Frames,
|
|
112
|
|
113 iCLastFineVolumeslideUpParam,
|
|
114 iCLastFineVolumeslideDownParam,
|
|
115 iCLastExtraFinePortamentoUpParam,
|
|
116 iCLastExtraFinePortamentoDownParam,
|
|
117 iCLastFinePortamentoUpParam,
|
|
118 iCLastFinePortamentoDownParam;
|
|
119
|
|
120 JDBool iCPanEnv_Exec,
|
|
121 iCVolEnv_Exec,
|
|
122 iCKeyOff;
|
|
123
|
|
124 // Module and sounddevice specific
|
|
125 JSSModule *pModule; // Current module in this player
|
|
126 JSSPattern *pPattern; // Current pattern
|
|
127 JSSMixer *pDevice; // Pointer to mixing device structure
|
|
128
|
|
129 #ifdef JSS_SUP_THREADS
|
|
130 DMMutex *mutex;
|
|
131 #endif
|
|
132
|
|
133 } JSSPlayer;
|
|
134
|
|
135
|
|
136 /* External functions for end users
|
|
137 */
|
|
138 int jmpPlayOrder(JSSPlayer *, int);
|
|
139 int jmpPlayPattern(JSSPlayer *, int);
|
|
140 void jmpStop(JSSPlayer *);
|
|
141 void jmpResume(JSSPlayer *);
|
|
142 void jmpSetModule(JSSPlayer *, JSSModule *);
|
|
143 JSSPlayer * jmpInit(JSSMixer *);
|
|
144 int jmpClose(JSSPlayer *);
|
|
145 void jmpExec(void *, void *);
|
|
146
|
|
147
|
|
148 /* Helper macros
|
|
149 */
|
|
150 #define JMPMAKEPARAM(AIVAL, AVALX, AVALY) { AVALX = (((AIVAL) >> 4) & 0x0f); AVALY = ((AIVAL) & 0x0f); }
|
|
151 #define JMPSETNDFLAGS(IVAL) mp->iCNewDataFlags[channel] |= IVAL
|
|
152 #define JMPUNSETNDFLAGS(IVAL) mp->iCNewDataFlags[channel] &= (~(IVAL))
|
|
153 #define JMPGETNOTE(MNOTE, MROW, MCHAN) assert(mp); assert(mp->pPattern); assert((MROW) >= 0); assert((MROW) < mp->pPattern->nrows); MNOTE = &mp->pPattern->data[(mp->pPattern->nchannels * MROW) + (MCHAN)]
|
|
154 #define JMPGETEFFECT(MEFF, MIEFF) if ((MIEFF >= 0) && (MIEFF < jmpNMODEffectTable)) MEFF = jmpMODEffectTable[MIEFF]; else MEFF = 0
|
|
155 #define JMPGETMODFLAGS(Q, Z) ((Q->pModule->defFlags & (Z)) == (Z))
|
|
156
|
|
157
|
|
158 /* Debugging macros
|
|
159 */
|
|
160 #if !defined(JSS_LIGHT) && defined(JSS_DEBUG)
|
|
161 # define JMPDEBUG(QQ) { fprintf(stderr, "[o=%03d:p=%03d:r=%03d] (%c/%x:%x) %s\n", mp->iOrder, mp->iPattern, mp->iRow, effect, currNote->effect, currNote->param, QQ ); }
|
|
162 #else
|
|
163 # define JMPDEBUG(QQ) // stub
|
|
164 #endif
|
|
165
|
|
166 #endif // JSSPLR_H
|