-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_player.h
122 lines (106 loc) · 2.82 KB
/
mod_player.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* REminiscence - Flashback interpreter
* Copyright (C) 2005-2007 Gregory Montoir
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __MOD_PLAYER_H__
#define __MOD_PLAYER_H__
#include "intern.h"
struct File;
struct Mixer;
struct ModPlayer {
enum {
NUM_SAMPLES = 31,
NUM_TRACKS = 4,
NUM_PATTERNS = 128,
FRAC_BITS = 12,
PAULA_FREQ = 3546897
};
struct SampleInfo {
char name[23];
uint16 len;
uint8 fineTune;
uint8 volume;
uint16 repeatPos;
uint16 repeatLen;
int8 *data;
int8 getPCM(int offset) const {
if (offset < 0) {
offset = 0;
} else if (offset >= (int)len) {
offset = len - 1;
}
return data[offset];
}
};
struct ModuleInfo {
char songName[21];
SampleInfo samples[NUM_SAMPLES];
uint8 numPatterns;
uint8 patternOrderTable[NUM_PATTERNS];
uint8 *patternsTable;
};
struct Track {
SampleInfo *sample;
uint8 volume;
int pos;
int freq;
uint16 period;
uint16 periodIndex;
uint16 effectData;
int vibratoSpeed;
int vibratoAmp;
int vibratoPos;
int portamento;
int portamentoSpeed;
int retriggerCounter;
int delayCounter;
int cutCounter;
};
static const int8 _sineWaveTable[];
static const uint16 _periodTable[];
static const char *_modulesFiles[][2];
static const int _modulesFilesCount;
ModuleInfo _modInfo;
uint8 _currentPatternOrder;
uint8 _currentPatternPos;
uint8 _currentTick;
uint8 _songSpeed;
uint8 _songTempo;
int _patternDelay;
int _patternLoopPos;
int _patternLoopCount;
int _samplesLeft;
uint8 _songNum;
bool _introSongHack;
bool _playing;
Track _tracks[NUM_TRACKS];
Mixer *_mix;
const char *_dataPath;
ModPlayer(Mixer *mixer, const char *dataPath);
uint16 findPeriod(uint16 period, uint8 fineTune) const;
void load(File *f);
void unload();
void play(uint8 num);
void stop();
void handleNote(int trackNum, uint32 noteData);
void handleTick();
void applyVolumeSlide(int trackNum, int amount);
void applyVibrato(int trackNum);
void applyPortamento(int trackNum);
void handleEffect(int trackNum, bool tick);
void mixSamples(int8 *buf, int len);
bool mix(int8 *buf, int len);
static bool mixCallback(void *param, int8 *buf, int len);
};
#endif // __MOD_PLAYER_H__