From 0b07a5f484c6ec602625f8919df95ecbe4839b83 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 23 Oct 2004 20:33:39 +0000 Subject: o Turn BASE_FREQ constant into variable. MT-32 has to be run in lesser time slices. o Attempt to fix mi2, but that cure for symptom, not the cause. Under dosbox header is always valid, but here we get 0x41001612 instead of 0x41101612. svn-id: r15669 --- backends/midi/emumidi.h | 13 ++++++++----- backends/midi/mt32/mt32.cpp | 4 +++- backends/midi/mt32/synth.cpp | 7 +++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/backends/midi/emumidi.h b/backends/midi/emumidi.h index a7b3821e82..cdff7051d1 100644 --- a/backends/midi/emumidi.h +++ b/backends/midi/emumidi.h @@ -23,7 +23,6 @@ #include "sound/mididrv.h" #include "sound/mixer.h" -#define BASE_FREQ 250 #define FIXP_SHIFT 16 class MidiDriver_Emulated : public AudioStream, public MidiDriver { @@ -42,6 +41,8 @@ protected: virtual void generate_samples(int16 *buf, int len) = 0; virtual void on_timer() {} + int _baseFreq; + public: MidiDriver_Emulated(SoundMixer *mixer) : _mixer(mixer) { _isOpen = false; @@ -51,18 +52,20 @@ public: _next_tick = 0; _samples_per_tick = 0; + + _baseFreq = 250; } int open() { _isOpen = true; - int d = getRate() / BASE_FREQ; - int r = getRate() % BASE_FREQ; + int d = getRate() / _baseFreq; + int r = getRate() % _baseFreq; // This is equivalent to (getRate() << FIXP_SHIFT) / BASE_FREQ // but less prone to arithmetic overflow. - _samples_per_tick = (d << FIXP_SHIFT) + (r << FIXP_SHIFT) / BASE_FREQ; + _samples_per_tick = (d << FIXP_SHIFT) + (r << FIXP_SHIFT) / _baseFreq; return 0; } @@ -71,7 +74,7 @@ public: _timer_param = timer_param; } - uint32 getBaseTempo() { return 1000000 / BASE_FREQ; } + uint32 getBaseTempo() { return 1000000 / _baseFreq; } // AudioStream API diff --git a/backends/midi/mt32/mt32.cpp b/backends/midi/mt32/mt32.cpp index c8037e8ca5..d719dafc4e 100644 --- a/backends/midi/mt32/mt32.cpp +++ b/backends/midi/mt32/mt32.cpp @@ -72,6 +72,8 @@ MidiDriver_MT32::MidiDriver_MT32(SoundMixer *mixer, const char *path) _synth = new CSynthMT32(); rom_path = path; File::addDefaultDirectory(path); + + _baseFreq = 100; } MidiDriver_MT32::~MidiDriver_MT32() { @@ -83,7 +85,7 @@ int MidiDriver_MT32::open() { if (_isOpen) return MERR_ALREADY_OPEN; - + MidiDriver_Emulated::open(); prop.SampleRate = getRate(); // 32000; diff --git a/backends/midi/mt32/synth.cpp b/backends/midi/mt32/synth.cpp index 0af4832a69..d9272985ee 100644 --- a/backends/midi/mt32/synth.cpp +++ b/backends/midi/mt32/synth.cpp @@ -4075,16 +4075,15 @@ 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_LE_UINT32(header) != 0x12161041) { - if(READ_LE_UINT32(sysex) == 0x12161041) { + if(READ_BE_UINT32(header) != 0x41101612) { + 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_LE_UINT32(header) == 0x12161041) { + if((READ_BE_UINT32(header) == 0x41101612) || (READ_BE_UINT32(header) == 0x41001612)) { addr = (sysex[5] << 16) | (sysex[6] << 8) | (sysex[7]); //LOG_MSG("Sysex addr: %x", addr); if (addr<0x30000) { -- cgit v1.2.3