fixed (and inlined) the "Antilog" function

svn-id: r42274
This commit is contained in:
Norbert Lange 2009-07-09 00:02:12 +00:00
parent a9d9de7db4
commit d25f481421
2 changed files with 2 additions and 9 deletions

View File

@ -165,13 +165,6 @@ void MaxTrax::interrupt() {
}
int32 MaxTrax::omgItsAntiLog(uint32 val) {
// some really weird exponential function, and some also very nonstandard "standard format" floats
// format is 16? bit exponent, 16 bit mantissa. and we need to scale with log(2)
const float v = ldexp((float)((val & 0xFFFF) + 0x10000) * (float)(0.69314718055994530942 / 65536), val >> 16);
return (uint32)exp(v);
}
void MaxTrax::stopMusic() {
}
@ -249,7 +242,8 @@ int MaxTrax::calcNote(VoiceContext &voice) {
tone -= voice.periodOffset;
}
if (tone < PERIOD_LIMIT)
voice.lastPeriod = (uint16)omgItsAntiLog((float)tone);
// we need to scale with log(2)
voice.lastPeriod = (uint16)exp((float)tone * (float)(0.69314718055994530942 / 65536));
return octave;
}

View File

@ -205,7 +205,6 @@ public:
void freePatches();
void freeScores();
static int32 omgItsAntiLog(uint32 val);
int calcNote(VoiceContext &voice);
int8 noteOn(ChannelContext &channel, byte note, uint16 volume, uint16 pri);
void noteOff(ChannelContext &channel, byte note);