-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModPlayer.h
125 lines (102 loc) · 3.06 KB
/
ModPlayer.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
123
124
125
/**
* Copyright (C) 2009 Sami Kyostila <[email protected]>
*/
#ifndef MODPLAYER_H
#define MODPLAYER_H
// PAL
#define MOD_FREQ_BASE (int)(7159090.5)
// NTSC
//#define MOD_FREQ_BASE (int)(7093789.2)
//#define MOD_USE_TAGFILE
//#define MOD_USE_TAGFILE_SAVING
//#define MOD_USE_FINETUNING
#include "Mixer.h"
#include "Engine.h"
class ModPlayer: private Ticker
{
public:
ModPlayer(Mixer *_mixer);
virtual ~ModPlayer();
bool load(const char *file);
void unload();
void play();
void stop();
#ifdef MOD_USE_TAGFILE
bool loadTagFile(const char *fileName);
#ifdef MOD_USE_TAGFILE_SAVING
bool save(const char *fileName) const;
#endif
#endif
//! \param vol is in the range [0, 64]
void setVolume(int vol);
Mixer *mixer;
protected:
unsigned short bigEndian16(unsigned short b);
int amigaToHz(int period);
int calcVolume(int v);
class ModSample
{
public:
ModSample(int _length, char _fineTune, char _volume, unsigned short _loopStart, unsigned short _loopLength);
~ModSample();
SampleChunk *sample;
signed char fineTune, volume;
unsigned short loopStart, loopLength;
char padding[6];
};
class ModNote
{
public:
unsigned char sampleNumber;
unsigned short amigaPeriod;
signed short note;
unsigned char effectNumber;
unsigned char effectParameter;
char padding[1];
};
class ModChannel
{
public:
ModChannel();
ModSample *sample;
signed char volume;
unsigned short amigaPeriod;
short note;
unsigned char portaSpeed;
unsigned short portaTarget; // amiga period
bool glissando;
// char vibratoWaveform;
// char vibratoWaveformRetrig; // four bits
signed char vibratoDepth;
signed char vibratoSpeed;
signed char vibratoPos;
signed char vibratoNeg;
// char tremoloWaveform;
// char tremoloWaveformRetrig; // four bits
signed char tremoloDepth;
signed char tremoloSpeed;
signed char tremoloPos;
signed char tremoloNeg;
signed char arpeggioCounter;
signed char loopRow;
signed char loopCounter;
char padding[3];
};
ModSample *sample[31];
ModNote *note;
ModChannel *channel;
int channels;
signed char *order;
signed char songLength, songSpeed;
signed char patternCount;
signed char currentOrder;
signed char currentTick;
signed char currentRow;
signed char patternDelay;
bool playing;
signed char volume;
private:
void tick();
void playNote(int ch, ModNote *n);
};
#endif