2013-09-10 17:30:05 +00:00
|
|
|
#include <map>
|
|
|
|
|
2013-09-04 13:37:36 +00:00
|
|
|
#include "adlib.h"
|
|
|
|
#include "dbopl.h"
|
|
|
|
|
|
|
|
enum Waveform
|
|
|
|
{
|
|
|
|
SIN = 0, HALF_SIN = 1, ABS_SIN = 2, QUART_SIN = 3
|
|
|
|
};
|
|
|
|
|
2013-09-10 17:30:05 +00:00
|
|
|
enum FreqMultiple
|
2013-09-04 13:37:36 +00:00
|
|
|
{
|
2013-09-10 17:30:05 +00:00
|
|
|
xHALF=0, x1=1, x2=2, x3=3, x4=4, x5=5, x6=6, x7=7, x8=8, x9=9, x10=10, x12=12, x15=15
|
2013-09-04 13:37:36 +00:00
|
|
|
};
|
|
|
|
|
2013-09-10 17:30:05 +00:00
|
|
|
|
2013-09-04 13:37:36 +00:00
|
|
|
class Hiopl {
|
|
|
|
public:
|
2013-09-12 15:21:30 +00:00
|
|
|
static const int CHANNELS = 9;
|
|
|
|
static const int OSCILLATORS = 2;
|
2013-09-04 13:37:36 +00:00
|
|
|
Hiopl(int buflen);
|
|
|
|
void Generate(int length, short* buffer);
|
2013-09-04 14:19:22 +00:00
|
|
|
void Generate(int length, float* buffer);
|
2013-09-04 13:37:36 +00:00
|
|
|
void SetSampleRate(int hz);
|
2013-09-12 13:58:22 +00:00
|
|
|
void EnableWaveformControl();
|
2013-09-12 15:52:06 +00:00
|
|
|
void EnableKeyscaling(int ch, int osc);
|
2013-09-04 13:37:36 +00:00
|
|
|
void SetWaveform(int ch, int osc, Waveform wave);
|
2013-09-10 17:30:05 +00:00
|
|
|
void SetAttenuation(int ch, int osc, int level);
|
2013-09-12 15:52:06 +00:00
|
|
|
void SetKsr(int ch, int osc, int level);
|
2013-09-10 17:30:05 +00:00
|
|
|
void SetFrequencyMultiple(int ch, int osc, FreqMultiple mult);
|
2013-09-12 12:17:31 +00:00
|
|
|
void SetEnvelopeAttack(int ch, int osc, int t);
|
|
|
|
void SetEnvelopeDecay(int ch, int osc, int t);
|
|
|
|
void SetEnvelopeSustain(int ch, int osc, int level);
|
|
|
|
void SetEnvelopeRelease(int ch, int osc, int t);
|
2013-09-12 13:10:19 +00:00
|
|
|
void EnableSustain(int ch, int osc);
|
2013-09-12 13:58:22 +00:00
|
|
|
void SetModulatorFeedback(int ch, int level);
|
2013-09-04 15:36:55 +00:00
|
|
|
void KeyOn(int ch, float frqHz);
|
|
|
|
void KeyOff(int ch);
|
2013-09-10 17:30:05 +00:00
|
|
|
void _WriteReg(Bit32u reg, Bit8u value, Bit8u mask=0x0);
|
2013-09-04 15:36:55 +00:00
|
|
|
void _ClearRegBits(Bit32u reg, Bit8u mask);
|
2013-09-04 13:37:36 +00:00
|
|
|
~Hiopl();
|
|
|
|
private:
|
|
|
|
Adlib::Handler *adlib;
|
|
|
|
Bit8u regCache[256];
|
|
|
|
Bit32s *Buf32;
|
|
|
|
bool _CheckParams(int ch, int osc);
|
2013-09-10 17:30:05 +00:00
|
|
|
int _GetOffset(int ch, int osc);
|
2013-09-12 13:58:22 +00:00
|
|
|
int _GetOffset(int ch);
|
2013-09-04 15:36:55 +00:00
|
|
|
void _milliHertzToFnum(unsigned int milliHertz, unsigned int *fnum, unsigned int *block, unsigned int conversionFactor=49716);
|
2013-09-10 17:30:05 +00:00
|
|
|
std::map<int, int> _op1offset;
|
|
|
|
std::map<int, int> _op2offset;
|
2013-09-04 13:37:36 +00:00
|
|
|
};
|