diff options
author | Eugene Sandulenko | 2004-10-24 13:03:42 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2004-10-24 13:03:42 +0000 |
commit | 7b8469312553d20999e4ae50566716f6ccb7a7a6 (patch) | |
tree | 1e7860e6e3474eaaa6d51c1caa9ab3a5ec4dadc6 | |
parent | dc89fe8e514227de42cf6573d5df1c1089b15314 (diff) | |
download | scummvm-rg350-7b8469312553d20999e4ae50566716f6ccb7a7a6.tar.gz scummvm-rg350-7b8469312553d20999e4ae50566716f6ccb7a7a6.tar.bz2 scummvm-rg350-7b8469312553d20999e4ae50566716f6ccb7a7a6.zip |
o Check size of waveforms.raw so output rate could be adjusted
o Eliminate rom_path, as we use our File class
svn-id: r15679
-rw-r--r-- | backends/midi/mt32/mt32.cpp | 27 | ||||
-rw-r--r-- | backends/midi/mt32/synth.cpp | 32 | ||||
-rw-r--r-- | backends/midi/mt32/synth.h | 9 |
3 files changed, 38 insertions, 30 deletions
diff --git a/backends/midi/mt32/mt32.cpp b/backends/midi/mt32/mt32.cpp index 869acacbc0..9faaa923ad 100644 --- a/backends/midi/mt32/mt32.cpp +++ b/backends/midi/mt32/mt32.cpp @@ -33,7 +33,7 @@ class MidiDriver_MT32 : public MidiDriver_Emulated { private: CSynthMT32 *_synth; - const char *rom_path; + int _outputRate; protected: void generate_samples(int16 *buf, int len); @@ -56,7 +56,7 @@ public: // AudioStream API bool isStereo() const { return true; } - int getRate() const { return 32000; } + int getRate() const { return _outputRate; } }; @@ -69,11 +69,30 @@ public: MidiDriver_MT32::MidiDriver_MT32(SoundMixer *mixer, const char *path) : MidiDriver_Emulated(mixer) { + File fp; + _synth = new CSynthMT32(); - rom_path = path; File::addDefaultDirectory(path); _baseFreq = 1000; + + fp.open("waveforms.raw"); + + if(!fp.isOpen()) { + error("Unable to open waveforms.raw"); + } + + switch(fp.size()) { + case 1410000: + _outputRate = 32000; + break; + case 1944040: + _outputRate = 44100; + break; + default: + error("MT-32: Unknown waveforms.raw file sample rate"); + } + fp.close(); } MidiDriver_MT32::~MidiDriver_MT32() { @@ -95,7 +114,7 @@ int MidiDriver_MT32::open() { //prop.RevTime = 5; //prop.RevLevel = 3; - _synth->ClassicOpen(rom_path, prop); + _synth->ClassicOpen(prop); _mixer->setupPremix(this); diff --git a/backends/midi/mt32/synth.cpp b/backends/midi/mt32/synth.cpp index d9272985ee..a319b261da 100644 --- a/backends/midi/mt32/synth.cpp +++ b/backends/midi/mt32/synth.cpp @@ -2761,7 +2761,7 @@ MidiChannel *mchan[16]; #endif -bool CSynthMT32::InitTables(const char *baseDir ) { +bool CSynthMT32::InitTables() { #ifdef NOMANSLAND @@ -2794,11 +2794,8 @@ bool CSynthMT32::InitTables(const char *baseDir ) { fp.open("waveforms.raw"); #endif if(!fp.isOpen()) { - // TODO : Fail driver init - return false; - error("Unable to open waveforms.raw"); - exit(0); + return false; } for(f=12;f<109;f++) { @@ -3352,7 +3349,7 @@ bool CSynthMT32::InitTables(const char *baseDir ) { return true; } -bool RecalcWaveforms(char * baseDir, int sampRate, recalcStatusCallback callBack) { +bool RecalcWaveforms(int sampRate, recalcStatusCallback callBack) { #ifdef NOMANSLAND @@ -3457,7 +3454,7 @@ bool RecalcWaveforms(char * baseDir, int sampRate, recalcStatusCallback callBack return true; } -bool CSynthMT32::ClassicOpen(const char *baseDir, SynthProperties useProp) { +bool CSynthMT32::ClassicOpen(SynthProperties useProp) { #ifdef NOMANSLAND @@ -3495,8 +3492,6 @@ bool CSynthMT32::ClassicOpen(const char *baseDir, SynthProperties useProp) { // TODO : Fail driver init error("Unable to open Preset1.syx"); return false; - - //exit(0); } break; case 1: @@ -3505,8 +3500,6 @@ bool CSynthMT32::ClassicOpen(const char *baseDir, SynthProperties useProp) { // TODO : Fail driver init error("Unable to open Preset2.syx"); return false; - - //exit(0); } break; default: @@ -3543,8 +3536,6 @@ bool CSynthMT32::ClassicOpen(const char *baseDir, SynthProperties useProp) { // printf("MT-32 Init Error - Missing drumpat.rom\n"); error("Unable to open drumpat.rom"); return false; - - //exit(0); } int drumnum=0; while(!fDrums.eof()) { @@ -3615,8 +3606,6 @@ bool CSynthMT32::ClassicOpen(const char *baseDir, SynthProperties useProp) { // printf("MT-32 Init Error - Missing patchlog.cfg\n"); error("Unable to open patchlog.cfg"); return false; - - //exit(0); } for(i=0;i<54;i++) { @@ -3770,8 +3759,6 @@ bool CSynthMT32::ClassicOpen(const char *baseDir, SynthProperties useProp) { // printf("MT-32 Init Error - Missing MT32_PCM.ROM\n"); error("Unable to open MT32_PCM.ROM"); return false; - - //exit(0); } i=0; //int32 maxamp = 0; @@ -3881,7 +3868,7 @@ bool CSynthMT32::ClassicOpen(const char *baseDir, SynthProperties useProp) { // For resetting mt32 mid-execution memcpy(&mt32default, &mt32ram, sizeof(mt32ram)); - if (!InitTables(baseDir)) return false; + if (!InitTables()) return false; if(myProp.UseDefault) { InitReverb(0,5,SETRATE); } else { @@ -4075,15 +4062,18 @@ void CSynthMT32::PlaySysex(uint8 * sysex,uint32 len) { //int dummy = 0; int32 lens = len; - // For some reason commands in IMuseInternal::initMT32 do not have prefix byte - if(READ_BE_UINT32(header) != 0x41101612) { + // HACK: For some reason commands in IMuseInternal::initMT32 do not have prefix byte + // Also in some cases, particularly in mi2 "glop" sound at difficulty select screen + // header is wrong. I don't know what causes this as original has neither of these + // problems. + if((READ_BE_UINT32(header) != 0x41101612) || (READ_BE_UINT32(header) == 0x41001612)) { if((READ_LE_UINT32(sysex) == 0x41101612) || (READ_BE_UINT32(sysex) == 0x41001612)) { header = (uint32 *)sysex; sysex--; // We don't access sysex[0], so it's safe } } - if((READ_BE_UINT32(header) == 0x41101612) || (READ_BE_UINT32(header) == 0x41001612)) { + if(READ_BE_UINT32(header) == 0x41101612) { addr = (sysex[5] << 16) | (sysex[6] << 8) | (sysex[7]); //LOG_MSG("Sysex addr: %x", addr); if (addr<0x30000) { diff --git a/backends/midi/mt32/synth.h b/backends/midi/mt32/synth.h index 106fc7f020..da2c685d34 100644 --- a/backends/midi/mt32/synth.h +++ b/backends/midi/mt32/synth.h @@ -85,7 +85,7 @@ typedef void (*recalcStatusCallback)(int percDone); // sampling rate. The callback routine provides interactivity to let the user know what // percentage is complete in regenerating the waveforms. When a NULL pointer is used as the // callback routine, no status is reported. -bool RecalcWaveforms(char * baseDir, int sampRate, recalcStatusCallback callBack); +bool RecalcWaveforms(int sampRate, recalcStatusCallback callBack); typedef float (*iir_filter_type)(float input,float *hist1_ptr, float *coef_ptr, int revLevel); extern iir_filter_type usefilter; @@ -125,16 +125,15 @@ private: bool isOpen; SynthProperties myProp; - bool InitTables(const char * baseDir); + bool InitTables(); public: CSynthMT32() : isOpen(false) {}; - // Used to initialized the MT-32. The baseDir parameter points to the location in the - // filesystem where the ROM and data files are located. The second parameter specifies + // Used to initialized the MT-32. The useProp parameter specifies // properties for the synthesizer, as outlined in the structure above. // Returns TRUE if initialization was sucessful, otherwise returns FALSE. - bool ClassicOpen(const char *baseDir, SynthProperties useProp); + bool ClassicOpen(SynthProperties useProp); // Closes the MT-32 and deallocates any memory used by the synthesizer void Close(void); |