126
|
1 #pragma once
|
|
2
|
|
3 #include <stdint.h>
|
|
4 #include <stdbool.h>
|
|
5
|
|
6 // AUDIO DRIVERS
|
|
7 #if defined AUDIODRIVER_SDL
|
|
8 #include "audiodrivers/sdl/sdldriver.h"
|
|
9 #elif defined AUDIODRIVER_WINMM
|
|
10 #include "audiodrivers/winmm/winmm.h"
|
|
11 #else
|
|
12 // Read "audiodrivers/how_to_write_drivers.txt"
|
|
13 #endif
|
|
14
|
|
15 enum // voice flags
|
|
16 {
|
|
17 IS_Vol = 1,
|
|
18 IS_Period = 2,
|
|
19 IS_NyTon = 4,
|
|
20 IS_Pan = 8,
|
|
21 IS_QuickVol = 16
|
|
22 };
|
|
23
|
|
24 enum // note
|
|
25 {
|
|
26 NOTE_KEYOFF = 97
|
|
27 };
|
|
28
|
|
29 enum // header flags
|
|
30 {
|
|
31 LINEAR_FREQUENCIES = 1
|
|
32 };
|
|
33
|
|
34 enum // sample flags
|
|
35 {
|
|
36 LOOP_OFF = 0,
|
|
37 LOOP_FORWARD = 1,
|
|
38 LOOP_PINGPONG = 2,
|
|
39 SAMPLE_16BIT = 16
|
|
40 };
|
|
41
|
|
42 enum // envelope flags
|
|
43 {
|
|
44 ENV_ENABLED = 1,
|
|
45 ENV_SUSTAIN = 2,
|
|
46 ENV_LOOP = 4
|
|
47 };
|
|
48
|
|
49 typedef struct songTyp_t
|
|
50 {
|
|
51 char name[20+1];
|
|
52 uint8_t antChn, pattDelTime, pattDelTime2, pBreakPos, songTab[256];
|
|
53 bool pBreakFlag, posJumpFlag;
|
|
54 int16_t songPos, pattNr, pattPos, pattLen;
|
|
55 uint16_t len, repS, speed, tempo, globVol, timer, ver;
|
|
56
|
|
57 uint16_t antInstrs; // 8bb: added this
|
|
58 } songTyp;
|
|
59
|
|
60 typedef struct sampleTyp_t
|
|
61 {
|
|
62 char name[22+1];
|
|
63 int32_t len, repS, repL;
|
|
64 uint8_t vol;
|
|
65 int8_t fine;
|
|
66 uint8_t typ, pan;
|
|
67 int8_t relTon;
|
|
68 int8_t *pek;
|
|
69 } sampleTyp;
|
|
70
|
|
71 typedef struct instrTyp_t
|
|
72 {
|
|
73 char name[22+1];
|
|
74 uint8_t ta[96];
|
|
75 int16_t envVP[12][2], envPP[12][2];
|
|
76 uint8_t envVPAnt, envPPAnt;
|
|
77 uint8_t envVSust, envVRepS, envVRepE;
|
|
78 uint8_t envPSust, envPRepS, envPRepE;
|
|
79 uint8_t envVTyp, envPTyp;
|
|
80 uint8_t vibTyp, vibSweep, vibDepth, vibRate;
|
|
81 uint16_t fadeOut;
|
|
82 uint8_t mute;
|
|
83 int16_t antSamp;
|
|
84 sampleTyp samp[16];
|
|
85 } instrTyp;
|
|
86
|
|
87 typedef struct stmTyp_t
|
|
88 {
|
|
89 volatile uint8_t status;
|
|
90 int8_t relTonNr, fineTune;
|
|
91 uint8_t sampleNr, instrNr, effTyp, eff, smpOffset, tremorSave, tremorPos;
|
|
92 uint8_t globVolSlideSpeed, panningSlideSpeed, mute, waveCtrl, portaDir;
|
|
93 uint8_t glissFunk, vibPos, tremPos, vibSpeed, vibDepth, tremSpeed, tremDepth;
|
|
94 uint8_t pattPos, loopCnt, volSlideSpeed, fVolSlideUpSpeed, fVolSlideDownSpeed;
|
|
95 uint8_t fPortaUpSpeed, fPortaDownSpeed, ePortaUpSpeed, ePortaDownSpeed;
|
|
96 uint8_t portaUpSpeed, portaDownSpeed, retrigSpeed, retrigCnt, retrigVol;
|
|
97 uint8_t volKolVol, tonNr, envPPos, eVibPos, envVPos, realVol, oldVol, outVol;
|
|
98 uint8_t oldPan, outPan, finalPan;
|
|
99 bool envSustainActive;
|
|
100 int16_t envVIPValue, envPIPValue;
|
|
101 uint16_t outPeriod, realPeriod, finalPeriod, finalVol, tonTyp, wantPeriod, portaSpeed;
|
|
102 uint16_t envVCnt, envVAmp, envPCnt, envPAmp, eVibAmp, eVibSweep;
|
|
103 uint16_t fadeOutAmp, fadeOutSpeed;
|
|
104 int32_t smpStartPos;
|
|
105 instrTyp *instrSeg;
|
|
106 } stmTyp;
|
|
107
|
|
108 #ifdef _MSC_VER
|
|
109 #pragma pack(push)
|
|
110 #pragma pack(1)
|
|
111 #endif
|
|
112 typedef struct tonTyp_t // this one must be packed on some systems
|
|
113 {
|
|
114 uint8_t ton, instr, vol, effTyp, eff;
|
|
115 }
|
|
116 #ifdef __GNUC__
|
|
117 __attribute__ ((packed))
|
|
118 #endif
|
|
119 tonTyp;
|
|
120 #ifdef _MSC_VER
|
|
121 #pragma pack(pop)
|
|
122 #endif
|
|
123
|
|
124 // globalized
|
|
125 extern volatile bool interpolationFlag, volumeRampingFlag, moduleLoaded, musicPaused, WAVDump_Flag;
|
|
126 extern bool linearFrqTab;
|
|
127 extern volatile const uint16_t *note2Period;
|
|
128 extern uint16_t pattLens[256];
|
|
129 extern int16_t PMPTmpActiveChannel, boostLevel;
|
|
130 extern int32_t masterVol, PMPLeft;
|
|
131 extern int32_t realReplayRate, quickVolSizeVal, speedVal;
|
|
132 extern uint32_t frequenceDivFactor, frequenceMulFactor;
|
|
133 extern uint32_t CDA_Amp;
|
|
134 extern tonTyp *patt[256];
|
|
135 extern instrTyp *instr[1+128];
|
|
136 extern songTyp song;
|
|
137 extern stmTyp stm[32];
|
|
138
|
|
139 #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
|
|
140
|
|
141 bool initMusic(int32_t audioFrequency, int32_t audioBufferSize, bool interpolation, bool volumeRamping);
|
|
142 bool loadMusicFromData(const uint8_t *data, uint32_t dataLength); // .XM/.MOD/.FT
|
|
143 bool loadMusic(const char *filename); // .XM/.MOD/.FT
|
|
144 void freeMusic(void);
|
|
145 bool startMusic(void);
|
|
146 void stopMusic();
|
|
147 void pauseMusic(void);
|
|
148 void resumeMusic(void);
|
|
149 void setMasterVol(int32_t v); // 0..256
|
|
150 void setAmp(int32_t level); // 1..32
|
|
151 void setPos(int32_t pos, int32_t row); // input of -1 = don't change
|
|
152 void stopVoices(void);
|
|
153 void updateReplayRate(void);
|
|
154 void startPlaying(void);
|
|
155 void stopPlaying(void);
|
|
156
|
|
157 bool WAVDump_Record(const char *filenameOut);
|
|
158
|
|
159 // 8bb: added these three, handy
|
|
160 void WAVDump_Abort(void);
|
|
161 int32_t getMasterVol(void);
|
|
162 int32_t getAmp(void);
|
|
163 uint8_t getNumActiveVoices(void);
|
|
164 void toggleMusic(void);
|
|
165 void setInterpolation(bool on);
|
|
166 void setVolumeRamping(bool on);
|