diff options
| author | Dreammaster | 2013-02-15 08:25:09 -0500 |
|---|---|---|
| committer | Dreammaster | 2013-02-15 08:25:09 -0500 |
| commit | bb3285d933419b6bdefadc55a6e320855ff0dd27 (patch) | |
| tree | 2df613c52f854c33cff660ed1b064e2996ed80bb /audio/softsynth/mt32/Tables.cpp | |
| parent | d1a19a1d4c3e20b57250e73141d81e8d9b44a2a1 (diff) | |
| parent | adc338cd719179a94ff470b28e9584262d7b47e8 (diff) | |
| download | scummvm-rg350-bb3285d933419b6bdefadc55a6e320855ff0dd27.tar.gz scummvm-rg350-bb3285d933419b6bdefadc55a6e320855ff0dd27.tar.bz2 scummvm-rg350-bb3285d933419b6bdefadc55a6e320855ff0dd27.zip | |
Merge branch 'master' into hopkins
Diffstat (limited to 'audio/softsynth/mt32/Tables.cpp')
| -rw-r--r-- | audio/softsynth/mt32/Tables.cpp | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/audio/softsynth/mt32/Tables.cpp b/audio/softsynth/mt32/Tables.cpp index c9bd40b7a4..5353a74079 100644 --- a/audio/softsynth/mt32/Tables.cpp +++ b/audio/softsynth/mt32/Tables.cpp @@ -22,18 +22,14 @@ #include "mt32emu.h" #include "mmath.h" -using namespace MT32Emu; +namespace MT32Emu { -Tables::Tables() { - initialised = false; +const Tables &Tables::getInstance() { + static const Tables instance; + return instance; } -void Tables::init() { - if (initialised) { - return; - } - initialised = true; - +Tables::Tables() { int lf; for (lf = 0; lf <= 100; lf++) { // CONFIRMED:KG: This matches a ROM table found by Mok @@ -76,31 +72,9 @@ void Tables::init() { //synth->printDebug("%d: %d", i, pulseWidth100To255[i]); } - // Ratio of negative segment to wave length - for (int i = 0; i < 128; i++) { - // Formula determined from sample analysis. - float pt = 0.5f / 127.0f * i; - pulseLenFactor[i] = (1.241857812f - pt) * pt; // seems to be 2 ^ (5 / 16) = 1.241857812f - } - - for (int i = 0; i < 65536; i++) { - // Aka (slightly slower): EXP2F(pitchVal / 4096.0f - 16.0f) * 32000.0f - pitchToFreq[i] = EXP2F(i / 4096.0f - 1.034215715f); - } - - // found from sample analysis - for (int i = 0; i < 1024; i++) { - cutoffToCosineLen[i] = EXP2F(i / -128.0f); - } - - // found from sample analysis - for (int i = 0; i < 1024; i++) { - cutoffToFilterAmp[i] = EXP2F(-0.125f * (128.0f - i / 8.0f)); - } - - // found from sample analysis - for (int i = 0; i < 32; i++) { - resAmpMax[i] = EXP2F(1.0f - (32 - i) / 4.0f); + // The LA32 chip presumably has such a table inside as the internal computaions seem to be performed using fixed point math with 12-bit fractions + for (int i = 0; i < 4096; i++) { + exp2[i] = EXP2F(i / 4096.0f); } // found from sample analysis @@ -117,3 +91,5 @@ void Tables::init() { sinf10[i] = sin(FLOAT_PI * i / 2048.0f); } } + +} |
