-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathOPL2Sound.cpp
More file actions
54 lines (45 loc) · 939 Bytes
/
Copy pathOPL2Sound.cpp
File metadata and controls
54 lines (45 loc) · 939 Bytes
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
#include "OPL2Sound.h"
OPL2Sound::OPL2Sound(unsigned int sampleRate_)
{
chip = new opl3_chip;
sampleRate = sampleRate_;
reset();
}
OPL2Sound::~OPL2Sound()
{
delete chip;
chip = NULL;
}
void OPL2Sound::reset(bool hard)
{
OPL3_Reset(chip, sampleRate);
}
void OPL2Sound::setFrequency(unsigned int frequency)
{
sampleRate = frequency;
OPL3_Reset(chip, sampleRate);
}
void OPL2Sound::setSampleRate(unsigned int sampleRate_)
{
sampleRate = sampleRate_;
OPL3_Reset(chip, sampleRate);
}
void OPL2Sound::calcSamples(short* buf, unsigned int count)
{
OPL3_GenerateStreamMono(chip, buf, count);
}
void OPL2Sound::write(unsigned int reg, unsigned char value)
{
if (reg >= (isOPL3model | 0xFF))
return;
if (reg & 1)
OPL3_WriteRegBuffered(chip, oplRegSelect, value);
else
oplRegSelect = value;
}
unsigned char OPL2Sound::read(unsigned int reg)
{
if (!(reg & 1) || isOPL3model)
return OPL3_ReadReg(chip, reg);
return 0;
}