LMMS
Loading...
Searching...
No Matches
adlib.h
Go to the documentation of this file.
1/*
2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3 * Copyright (C) 1999 - 2005 Simon Peter <dn.tlp@gmx.net>, et al.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * adlib.h - AdLib Sound Driver by Stas'M <binarymaster@mail.ru> and Jepael
20 *
21 * Based on ADLIB.H by Marc Savary and Dale Glowinski, Ad Lib Inc.
22 */
23
24#ifndef H_ADPLUG_ADLIBDRV
25#define H_ADPLUG_ADLIBDRV
27#include "stdint.h"
28#include "player.h"
29
30/* Parameters of each voice: */
31#define nbLocParam 14
33#define prmKsl 0
34#define prmMulti 1
35#define prmFeedBack 2 /* use for opr. 0 only */
36#define prmAttack 3
37#define prmSustain 4
38#define prmStaining 5 /* Sustaining ... */
39#define prmDecay 6
40#define prmRelease 7
41#define prmLevel 8
42#define prmAm 9
43#define prmVib 10
44#define prmKsr 11
45#define prmFm 12 /* use for opr. 0 only */
46#define prmWaveSel 13 /* wave select */
47
48 /* globals parameters: */
49#define prmAmDepth 14
50#define prmVibDepth 15
51#define prmNoteSel 16
52#define prmPercussion 17
53
54 /* melodic voice numbers: */
55#define vMelo0 0
56#define vMelo1 1
57#define vMelo2 2
58#define vMelo3 3
59#define vMelo4 4
60#define vMelo5 5
61#define vMelo6 6
62#define vMelo7 7
63#define vMelo8 8
64
65 /* percussive voice numbers: */
66#define BD 6
67#define SD 7
68#define TOM 8
69#define CYMB 9
70#define HIHAT 10
71
72#define MAX_VOICES 11
73#define MAX_VOLUME 0x7f
74#define MAX_PITCH 0x3fff
75#define MID_PITCH 0x2000
76
77#define MID_C 60 /* MIDI standard mid C */
78#define CHIP_MID_C 48 /* sound chip mid C */
79#define NR_NOTES 96 /* # of notes we can play on chip */
80
81#define TOM_PITCH 24 /* best frequency, in range of 0 to 95 */
82#define TOM_TO_SD 7 /* 7 half-tones between voice 7 & 8 */
83#define SD_PITCH (TOM_PITCH + TOM_TO_SD)
84
85#define NR_STEP_PITCH 25 /* 25 steps within a half-tone for pitch bend */
86#define ADLIB_OPER_LEN 13 /* operator length */
87#define ADLIB_INST_LEN (ADLIB_OPER_LEN * 2 + 2) /* modulator, carrier, mod/car wave select */
89#define GetLocPrm(slot, prm) ( (uint8_t)paramSlot[slot][prm] )
90
92{
93public:
95 : opl(newopl)
96 {};
98 {};
99
100 void SoundWarmInit();
101 void SetMode(int mode);
102 void SetWaveSel(int state);
103 void SetPitchRange(uint8_t pR);
104 void SetGParam(int amD, int vibD, int nSel);
105 void SetVoiceTimbre(uint8_t voice, int16_t * paramArray);
107 void SetVoicePitch(uint8_t voice, uint16_t pitchBend);
108 void NoteOn(uint8_t voice, int pitch);
109 void NoteOff(uint8_t voice);
110
111private:
113
114 void InitSlotVolume();
115 void InitFNums();
116 void SoundChut(int voice);
117 void SetFreq(uint8_t voice, int pitch, uint8_t keyOn);
118 void SndSAmVibRhythm();
119 void SndSNoteSel();
120 void SndSKslLevel(uint8_t slot);
121 void SndSFeedFm(uint8_t slot);
122 void SndSAttDecay(uint8_t slot);
123 void SndSSusRelease(uint8_t slot);
124 void SndSAVEK(uint8_t slot);
125 void SndWaveSelect(uint8_t slot);
126 void SndSetAllPrm(uint8_t slot);
127 void SetSlotParam(uint8_t slot, int16_t * param, uint8_t waveSel);
128 void SetCharSlotParam(uint8_t slot, uint8_t * cParam, uint8_t waveSel);
129 void InitSlotParams();
130 void SetFNum(uint16_t * fNumVec, int num, int den);
131 void ChangePitch(int voice, int pitchBend);
132 long CalcPremFNum(int numDeltaDemiTon, int denDeltaDemiTon);
133
137 int pitchRange; /* pitch variation, half-tone [+1,+12] */
138 int pitchRangeStep; /* == pitchRange * NR_STEP_PITCH */
139 int modeWaveSel; /* != 0 if used with the 'wave-select' parameters */
140
141 uint8_t percBits; /* control bits of percussive voices */
142 uint8_t notePitch[MAX_VOICES]; /* pitch of last note-on of each voice */
143 uint8_t voiceKeyOn[MAX_VOICES]; /* state of keyOn bit of each voice */
144
145 uint8_t noteDIV12[96]; /* table of (0..95) DIV 12 */
146 uint8_t noteMOD12[96]; /* table of (0..95) MOD 12 */
147
148 uint8_t slotRelVolume[18]; /* relative volume of slots */
149
151 SLOT_PARAM paramSlot[18][nbLocParam]; /* all the parameters of slots... */
152
153 uint8_t amDepth; /* chip global parameters .. */
154 uint8_t vibDepth; /* ... */
155 uint8_t noteSel; /* ... */
156 uint8_t percussion; /* percussion mode parameter */
157
158protected:
159 static const uint8_t percMasks[5];
162 static uint8_t bdOpr0[nbLocParam];
163 static uint8_t bdOpr1[nbLocParam];
164 static uint8_t sdOpr[nbLocParam];
165 static uint8_t tomOpr[nbLocParam];
166 static uint8_t cymbOpr[nbLocParam];
167 static uint8_t hhOpr[nbLocParam];
168 static uint8_t slotVoice[9][2];
169 static uint8_t slotPerc[5][2];
170 static uint8_t offsetSlot[18];
171 static uint8_t operSlot[18];
172 static uint8_t voiceSlot[18];
173};
174
175#endif
#define NR_STEP_PITCH
Definition adlib.h:85
#define MAX_VOICES
Definition adlib.h:72
#define nbLocParam
Definition adlib.h:31
uint8_t SLOT_PARAM
Definition adlib.h:150
void SetMode(int mode)
Definition adlib.cpp:145
uint8_t percussion
Definition adlib.h:156
void InitSlotParams()
Definition adlib.cpp:611
void SndSetAllPrm(uint8_t slot)
Definition adlib.cpp:570
uint8_t amDepth
Definition adlib.h:153
uint8_t slotRelVolume[18]
Definition adlib.h:148
void SndSKslLevel(uint8_t slot)
Definition adlib.cpp:485
void SetFNum(uint16_t *fNumVec, int num, int den)
Definition adlib.cpp:635
void SetGParam(int amD, int vibD, int nSel)
Definition adlib.cpp:209
uint8_t vibDepth
Definition adlib.h:154
static uint8_t voiceSlot[18]
Definition adlib.h:101
~CadlibDriver()
Definition adlib.h:97
uint8_t voiceKeyOn[MAX_VOICES]
Definition adlib.h:143
static uint8_t bdOpr1[nbLocParam]
Definition adlib.h:38
CadlibDriver(Copl *newopl)
Definition adlib.h:94
void NoteOn(uint8_t voice, int pitch)
Definition adlib.cpp:353
SLOT_PARAM paramSlot[18][nbLocParam]
Definition adlib.h:151
void SetVoicePitch(uint8_t voice, uint16_t pitchBend)
Definition adlib.cpp:333
static uint8_t pianoParamsOp1[nbLocParam]
Definition adlib.h:32
void SetVoiceTimbre(uint8_t voice, int16_t *paramArray)
Definition adlib.cpp:248
void SndSAmVibRhythm()
Definition adlib.cpp:463
void ChangePitch(int voice, int pitchBend)
Definition adlib.cpp:654
void SetSlotParam(uint8_t slot, int16_t *param, uint8_t waveSel)
Definition adlib.cpp:588
Copl * opl
Definition adlib.h:112
void NoteOff(uint8_t voice)
Definition adlib.cpp:386
void InitSlotVolume()
Definition adlib.cpp:399
int modeWaveSel
Definition adlib.h:139
void SoundChut(int voice)
Definition adlib.cpp:433
void SndSSusRelease(uint8_t slot)
Definition adlib.cpp:528
long CalcPremFNum(int numDeltaDemiTon, int denDeltaDemiTon)
Definition adlib.cpp:697
void SetPitchRange(uint8_t pR)
Definition adlib.cpp:191
uint8_t percBits
Definition adlib.h:141
static uint8_t slotVoice[9][2]
Definition adlib.h:52
void SndSAVEK(uint8_t slot)
Definition adlib.cpp:540
uint8_t noteSel
Definition adlib.h:155
uint16_t fNumNotes[NR_STEP_PITCH][12]
Definition adlib.h:134
static uint8_t cymbOpr[nbLocParam]
Definition adlib.h:44
int pitchRange
Definition adlib.h:137
int halfToneOffset[MAX_VOICES]
Definition adlib.h:135
static uint8_t offsetSlot[18]
Definition adlib.h:79
uint16_t * fNumFreqPtr[MAX_VOICES]
Definition adlib.h:136
void SndSFeedFm(uint8_t slot)
Definition adlib.cpp:502
uint8_t notePitch[MAX_VOICES]
Definition adlib.h:142
static uint8_t hhOpr[nbLocParam]
Definition adlib.h:46
void SndSNoteSel()
Definition adlib.cpp:477
void SetWaveSel(int state)
Definition adlib.cpp:172
static uint8_t slotPerc[5][2]
Definition adlib.h:67
uint8_t noteMOD12[96]
Definition adlib.h:146
void SetFreq(uint8_t voice, int pitch, uint8_t keyOn)
Definition adlib.cpp:442
static uint8_t operSlot[18]
Definition adlib.h:88
void SetCharSlotParam(uint8_t slot, uint8_t *cParam, uint8_t waveSel)
Definition adlib.cpp:596
int pitchRangeStep
Definition adlib.h:138
void SndSAttDecay(uint8_t slot)
Definition adlib.cpp:516
void SoundWarmInit()
Definition adlib.cpp:112
static uint8_t bdOpr0[nbLocParam]
Definition adlib.h:36
static uint8_t sdOpr[nbLocParam]
Definition adlib.h:40
static uint8_t pianoParamsOp0[nbLocParam]
Definition adlib.h:30
static const uint8_t percMasks[5]
Definition adlib.h:26
static uint8_t tomOpr[nbLocParam]
Definition adlib.h:42
uint8_t noteDIV12[96]
Definition adlib.h:145
void SndWaveSelect(uint8_t slot)
Definition adlib.cpp:555
void InitFNums()
Definition adlib.cpp:410
void SetVoiceVolume(uint8_t voice, uint8_t volume)
Definition adlib.cpp:280
Definition opl.h:26
unsigned short uint16_t
Definition mid.cpp:99
short int16_t
Definition mid.cpp:96
unsigned char uint8_t
Definition mid.cpp:98
static float volume(float level)
Definition nekobee_voice_render.c:99
png_structrp int mode
Definition png.h:1139