aboutsummaryrefslogtreecommitdiff
path: root/backends/midi/ym2612.cpp
diff options
context:
space:
mode:
authorMax Horn2003-10-06 13:02:06 +0000
committerMax Horn2003-10-06 13:02:06 +0000
commit5a1bd7574afa9e094a138c7b4e4eb17c196cd61b (patch)
tree6646b50bae5935b404b5c1916cf6af3b7ec00b35 /backends/midi/ym2612.cpp
parentca13989959ffda548060678043a3777d97fd814b (diff)
downloadscummvm-rg350-5a1bd7574afa9e094a138c7b4e4eb17c196cd61b.tar.gz
scummvm-rg350-5a1bd7574afa9e094a138c7b4e4eb17c196cd61b.tar.bz2
scummvm-rg350-5a1bd7574afa9e094a138c7b4e4eb17c196cd61b.zip
some more tweaks
svn-id: r10637
Diffstat (limited to 'backends/midi/ym2612.cpp')
-rw-r--r--backends/midi/ym2612.cpp20
1 files changed, 5 insertions, 15 deletions
diff --git a/backends/midi/ym2612.cpp b/backends/midi/ym2612.cpp
index 804be02a8f..8f9c4dfa79 100644
--- a/backends/midi/ym2612.cpp
+++ b/backends/midi/ym2612.cpp
@@ -324,6 +324,7 @@ void Operator2612::nextTick(uint16 rate, const int *phasebuf, int *outbuf, int b
int32 target;
State next_state;
const int32 zero_level = ((int32)0x7f << 15);
+ const int phaseIncrement = (_multiple > 0) ? (_frequency * _multiple) : (_frequency / 2);
while (buflen) {
switch (_state) {
@@ -355,19 +356,13 @@ void Operator2612::nextTick(uint16 rate, const int *phasebuf, int *outbuf, int b
if (next_state == _s_attacking) {
// Attack phase
++_tickCount;
- if (_attackTime <= 0) {
+ int i = (int) (_tickCount * _attackTime);
+ if (i >= 1024) {
_currentLevel = 0;
_state = _s_decaying;
switching = true;
} else {
- int i = (int) (_tickCount * _attackTime);
- if (i >= 1024) {
- _currentLevel = 0;
- _state = _s_decaying;
- switching = true;
- } else {
- _currentLevel = attackOut[i] << (31 - 8 - 16);
- }
+ _currentLevel = (attackOut[i] << (31 - 8 - 16));
}
} else {
// Decay, Sustain and Release phases
@@ -402,12 +397,7 @@ void Operator2612::nextTick(uint16 rate, const int *phasebuf, int *outbuf, int b
// Result varies from original code by max of 8.
output = ((output >> 4) * (powtbl[511-((level>>9)&511)] >> 3)) / 1024;
- if (_multiple > 0)
-// _phase += (_frequency * _multiple) / rate;
- _phase += _frequency * _multiple; // / rate; already included
- else
-// _phase += _frequency / (rate << 1);
- _phase += _frequency / 2;
+ _phase += phaseIncrement;
}
_lastOutput = output;