diff options
author | Jerome Fisher | 2005-03-20 16:24:55 +0000 |
---|---|---|
committer | Jerome Fisher | 2005-03-20 16:24:55 +0000 |
commit | 7f83c4786045bd438ff76cea2c6189a62774798b (patch) | |
tree | 0f9a2500a01a19102f386ecd2dddbb8147300292 /sound/softsynth/mt32/tables.h | |
parent | 9880288669414537d290aef70199e213fe868df1 (diff) | |
download | scummvm-rg350-7f83c4786045bd438ff76cea2c6189a62774798b.tar.gz scummvm-rg350-7f83c4786045bd438ff76cea2c6189a62774798b.tar.bz2 scummvm-rg350-7f83c4786045bd438ff76cea2c6189a62774798b.zip |
Merged with latest Munt CVS.
* Added support for most of the extended capabilities of the CM-32L/LAPC-I (more rhythm timbres, more rhythm key mappings, more PCM samples).
* The control ROM is now identified by searching for matching ID strings at various locations in the file. There are now a lot of safety checks to help ensure that a bad ROM will not crash the emulator.
* Three control ROM versions are now identified and mapped out - an original MT-32 control ROM, an original CM-32L ROM, and the Blue Ridge modified MT-32 ROM.
* Now supports the expression controller properly.
* Sustain is now turned off correctly again.
* "All Notes Off" no longer stops notes held by the sustain controller.
* Implemented "Reset all controllers".
* Stereo pan positions are no longer inverted.
* Volume, pitch, filter and envelopes are now more accurately calculated. Overall, the sound emulation is much more accurate.
* Waveforms are now slightly more accurate (in terms of pitch), necessitating a regeneration.
* Handling of unusual sysex messages has been improved (fixes sysex messages from Java's MIDI classes on Windows).
* Fixed a reverb bug during periods of silence.
svn-id: r17188
Diffstat (limited to 'sound/softsynth/mt32/tables.h')
-rw-r--r-- | sound/softsynth/mt32/tables.h | 101 |
1 files changed, 58 insertions, 43 deletions
diff --git a/sound/softsynth/mt32/tables.h b/sound/softsynth/mt32/tables.h index 0c85796f4f..2858716587 100644 --- a/sound/softsynth/mt32/tables.h +++ b/sound/softsynth/mt32/tables.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2003-2004 Various contributors +/* Copyright (c) 2003-2005 Various contributors * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -33,67 +33,82 @@ const float FLOAT_LN = 2.3025850929940456840179914546844f; // Filter settings const int FILTERGRAN = 512; +// Amplitude of waveform generator +// FIXME: This value is the amplitude possible whilst avoiding +// overdriven values immediately after filtering when playing +// back SQ3MT.MID. Needs to be checked. +const int WGAMP = 12382; + const int MIDDLEC = 60; const int MIDDLEA = 69; // By this I mean "A above middle C" -//FIXME:KG: may only need to do 12 to 108 -//12..108 is the range allowed by note on commands, but the key can be modified by pitch keyfollow -//and adjustment for timbre pitch, so the results can be outside that range. Do move it (by octave) into -// the 12..108 range, or keep it in 0..127 range, or something else altogether? +// FIXME:KG: may only need to do 12 to 108 +// 12..108 is the range allowed by note on commands, but the key can be modified by pitch keyfollow +// and adjustment for timbre pitch, so the results can be outside that range. +// Should we move it (by octave) into the 12..108 range, or keep it in 0..127 range, +// or something else altogether? const int LOWEST_NOTE = 12; const int HIGHEST_NOTE = 127; const int NUM_NOTES = HIGHEST_NOTE - LOWEST_NOTE + 1; // Number of slots for note LUT -// Amplitude of waveform generator -const int WGAMP = 7168; // 8192? - class Synth; -extern Bit16s smallnoise[MAX_SAMPLE_OUTPUT]; - -// Some optimization stuff -extern Bit32s keytable[217]; -extern Bit16s sintable[65536]; -extern Bit32u lfotable[101]; -extern Bit32s penvtable[16][101]; -extern Bit32s filveltable[128][101]; -extern Bit32s veltkeytable[5][128]; -extern Bit32s pulsetable[101]; -extern Bit32s ampbiastable[13][128]; -extern Bit32s fbiastable[15][128]; -extern float filtcoeff[FILTERGRAN][31][8]; -extern Bit32s finetable[201]; -extern Bit32u lfoptable[101][101]; -extern Bit32s ampveltable[128][64]; -extern Bit32s pwveltable[15][128]; -extern Bit32s envtimetable[101]; -extern Bit32s decaytimetable[101]; -extern Bit32s lasttimetable[101]; -extern Bit32s voltable[128]; -extern float ResonInv[31]; - struct NoteLookup { - Bit32u div; - Bit32u wavTable[128]; + Bit32u div2; + Bit32u *wavTable; Bit32s sawTable[101]; - Bit32s fildepTable[5]; - Bit32s timekeyTable[5]; int filtTable[2][201]; int nfiltTable[101][101]; Bit16s *waveforms[3]; Bit32u waveformSize[3]; }; -extern NoteLookup noteLookups[NUM_NOTES]; +struct KeyLookup { + Bit32s envTimeMult[5]; // For envelope time adjustment for key pressed + Bit32s envDepthMult[5]; +}; -class TableInitialiser { - static void initMT32ConstantTables(Synth *synth); - static File *initWave(Synth *synth, NoteLookup *noteLookup, float ampsize, float div, File *file); - static bool initNotes(Synth *synth, PCMWaveEntry pcmWaves[128], float rate, float tuning); +class Tables { + float initialisedSampleRate; + float initialisedMasterTune; + void initMT32ConstantTables(Synth *synth); + static Bit16s clampWF(Synth *synth, const char *n, float ampVal, double input); + static File *initWave(Synth *synth, NoteLookup *noteLookup, float ampsize, float div2, File *file); + bool initNotes(Synth *synth, PCMWaveEntry pcmWaves[128], float rate, float tuning); + void initEnvelopes(float sampleRate); + void initFiltCoeff(float samplerate); public: - static bool initMT32Tables(Synth *synth, PCMWaveEntry pcmWaves[128], float sampleRate, float masterTune); - static File *initNote(Synth *synth, NoteLookup *noteLookup, float note, float rate, float tuning, PCMWaveEntry pcmWaves[128], File *file); - static void freeNotes(); + // Constant LUTs + Bit32s tvfKeyfollowMult[217]; + Bit32s tvfVelfollowMult[128][101]; + Bit32s tvfBiasMult[15][128]; + Bit32u tvaVelfollowMult[128][101]; + Bit32s tvaBiasMult[13][128]; + Bit16s noiseBuf[MAX_SAMPLE_OUTPUT]; + Bit16s sintable[65536]; + Bit32s pitchEnvVal[16][101]; + Bit32s envTimeVelfollowMult[5][128]; + Bit32s pwVelfollowAdd[15][128]; + float resonanceFactor[31]; + Bit32u lfoShift[101][101]; + Bit32s pwFactor[101]; + Bit32s volumeMult[101]; + + // LUTs varying with sample rate + Bit32u envTime[101]; + Bit32u envDeltaMaxTime[101]; + Bit32u envDecayTime[101]; + Bit32u lfoPeriod[101]; + float filtCoeff[FILTERGRAN][31][8]; + + // Various LUTs for each note and key + NoteLookup noteLookups[NUM_NOTES]; + KeyLookup keyLookups[97]; + + Tables(); + bool init(Synth *synth, PCMWaveEntry pcmWaves[128], float sampleRate, float masterTune); + File *initNote(Synth *synth, NoteLookup *noteLookup, float note, float rate, float tuning, PCMWaveEntry pcmWaves[128], File *file); + void freeNotes(); }; } |