[Scummvm-cvs-logs] CVS: scummvm/backends/midi/mt32 mt32.cpp,1.4,1.5 synth.cpp,1.13,1.14 synth.h,1.3,1.4
Eugene Sandulenko
sev at users.sourceforge.net
Sun Oct 24 06:04:01 CEST 2004
Update of /cvsroot/scummvm/scummvm/backends/midi/mt32
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28049
Modified Files:
mt32.cpp synth.cpp synth.h
Log Message:
o Check size of waveforms.raw so output rate could be adjusted
o Eliminate rom_path, as we use our File class
Index: mt32.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/midi/mt32/mt32.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- mt32.cpp 23 Oct 2004 20:56:53 -0000 1.4
+++ mt32.cpp 24 Oct 2004 13:03:42 -0000 1.5
@@ -33,7 +33,7 @@
private:
CSynthMT32 *_synth;
- const char *rom_path;
+ int _outputRate;
protected:
void generate_samples(int16 *buf, int len);
@@ -56,7 +56,7 @@
// AudioStream API
bool isStereo() const { return true; }
- int getRate() const { return 32000; }
+ int getRate() const { return _outputRate; }
};
@@ -69,11 +69,30 @@
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 @@
//prop.RevTime = 5;
//prop.RevLevel = 3;
- _synth->ClassicOpen(rom_path, prop);
+ _synth->ClassicOpen(prop);
_mixer->setupPremix(this);
Index: synth.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/midi/mt32/synth.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- synth.cpp 23 Oct 2004 20:33:39 -0000 1.13
+++ synth.cpp 24 Oct 2004 13:03:42 -0000 1.14
@@ -2761,7 +2761,7 @@
#endif
-bool CSynthMT32::InitTables(const char *baseDir ) {
+bool CSynthMT32::InitTables() {
#ifdef NOMANSLAND
@@ -2794,11 +2794,8 @@
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 @@
return true;
}
-bool RecalcWaveforms(char * baseDir, int sampRate, recalcStatusCallback callBack) {
+bool RecalcWaveforms(int sampRate, recalcStatusCallback callBack) {
#ifdef NOMANSLAND
@@ -3457,7 +3454,7 @@
return true;
}
-bool CSynthMT32::ClassicOpen(const char *baseDir, SynthProperties useProp) {
+bool CSynthMT32::ClassicOpen(SynthProperties useProp) {
#ifdef NOMANSLAND
@@ -3495,8 +3492,6 @@
// TODO : Fail driver init
error("Unable to open Preset1.syx");
return false;
-
- //exit(0);
}
break;
case 1:
@@ -3505,8 +3500,6 @@
// TODO : Fail driver init
error("Unable to open Preset2.syx");
return false;
-
- //exit(0);
}
break;
default:
@@ -3543,8 +3536,6 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
//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) {
Index: synth.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/midi/mt32/synth.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- synth.h 22 Oct 2004 15:56:39 -0000 1.3
+++ synth.h 24 Oct 2004 13:03:42 -0000 1.4
@@ -85,7 +85,7 @@
// 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 @@
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);
More information about the Scummvm-git-logs
mailing list