diff --git a/src/sound/i_music.cpp b/src/sound/i_music.cpp index 47fdcc04a0..9c760cc25c 100644 --- a/src/sound/i_music.cpp +++ b/src/sound/i_music.cpp @@ -268,10 +268,6 @@ void MusInfo::MusicVolumeChanged() { } -void MusInfo::TimidityVolumeChanged() -{ -} - void MusInfo::GMEDepthChanged(float val) { } diff --git a/src/sound/i_musicinterns.h b/src/sound/i_musicinterns.h index b3dadb8747..544bfd1887 100644 --- a/src/sound/i_musicinterns.h +++ b/src/sound/i_musicinterns.h @@ -75,7 +75,6 @@ public: virtual void InitPlayback(); virtual bool Update(); virtual void PrecacheInstruments(const uint16_t *instruments, int count); - virtual void TimidityVolumeChanged(); virtual void FluidSettingInt(const char *setting, int value); virtual void FluidSettingNum(const char *setting, double value); virtual void FluidSettingStr(const char *setting, const char *value); @@ -314,7 +313,6 @@ public: ~MIDIStreamer(); void MusicVolumeChanged() override; - void TimidityVolumeChanged() override; void Play(bool looping, int subsong) override; void Pause() override; void Resume() override; diff --git a/src/sound/mididevices/music_timiditypp_mididevice.cpp b/src/sound/mididevices/music_timiditypp_mididevice.cpp index a75a4e0876..11cc389121 100644 --- a/src/sound/mididevices/music_timiditypp_mididevice.cpp +++ b/src/sound/mididevices/music_timiditypp_mididevice.cpp @@ -63,7 +63,6 @@ public: void PrecacheInstruments(const uint16_t *instruments, int count); //FString GetStats(); int GetDeviceType() const override { return MDEV_TIMIDITY; } - void TimidityVolumeChanged(); static void ClearInstruments() { if (instruments != nullptr) delete instruments; @@ -82,9 +81,14 @@ protected: TimidityPlus::Instruments *TimidityPPMIDIDevice::instruments; // Config file to use -CVAR(String, timidity_config, "timidity.cfg", CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(String, timidity_config, "timidity.cfg", CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (currSong != nullptr && currSong->GetDeviceType() == MDEV_TIMIDITY) + { + MIDIDeviceChanged(-1, true); + } +} -// added because Timidity's output is rather loud. CUSTOM_CVAR (Int, timidity_frequency, 44100, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { // Clamp frequency to Timidity's limits @@ -113,11 +117,11 @@ TimidityPPMIDIDevice::TimidityPPMIDIDevice(const char *args) if (instruments == nullptr) { instruments = new TimidityPlus::Instruments; - } - if (!instruments->load(args)) - { - delete instruments; - instruments = nullptr; + if (!instruments->load(args)) + { + delete instruments; + instruments = nullptr; + } } if (instruments != nullptr) { @@ -157,7 +161,6 @@ int TimidityPPMIDIDevice::Open(MidiCallback callback, void *userdata) } // No instruments loaded means we cannot play... if (instruments == nullptr) return 0; - TimidityVolumeChanged(); return ret; } diff --git a/src/sound/musicformats/music_midistream.cpp b/src/sound/musicformats/music_midistream.cpp index 45a25d9267..d90c88a87f 100644 --- a/src/sound/musicformats/music_midistream.cpp +++ b/src/sound/musicformats/music_midistream.cpp @@ -478,20 +478,6 @@ void MIDIStreamer::MusicVolumeChanged() } } -//========================================================================== -// -// MIDIStreamer :: TimidityVolumeChanged -// -//========================================================================== - -void MIDIStreamer::TimidityVolumeChanged() -{ - if (MIDI != NULL) - { - MIDI->TimidityVolumeChanged(); - } -} - //========================================================================== // // MIDIStreamer :: FluidSettingInt @@ -971,16 +957,6 @@ bool MIDIDevice::Update() return true; } -//========================================================================== -// -// MIDIDevice :: TimidityVolumeChanged -// -//========================================================================== - -void MIDIDevice::TimidityVolumeChanged() -{ -} - //========================================================================== // // MIDIDevice :: FluidSettingInt diff --git a/src/sound/timiditypp/instrum.cpp b/src/sound/timiditypp/instrum.cpp index cbda244ba1..5b51faea2e 100644 --- a/src/sound/timiditypp/instrum.cpp +++ b/src/sound/timiditypp/instrum.cpp @@ -620,22 +620,27 @@ Instrument *Instruments::load_gus_instrument(char *name, ToneBank *bank, int dr, return ip; } /* Open patch file */ - if (!(tf = open_file(name, sfreader))) { + tf = open_file(name, sfreader); + if (!tf) + { int name_len, ext_len; static const char *patch_ext[] = { ".pat", 0 }; noluck = 1; name_len = (int)strlen(name); /* Try with various extensions */ - for (i = 0; patch_ext[i]; i++) { + for (i = 0; patch_ext[i]; i++) + { ext_len = (int)strlen(patch_ext[i]); - if (name_len + ext_len < 1024) { + if (name_len + ext_len < 1024) + { if (name_len >= ext_len && strcmp(name + name_len - ext_len, patch_ext[i]) == 0) continue; /* duplicated ext. */ strcpy((char *)tmp, name); strcat((char *)tmp, patch_ext[i]); - if ((tf = open_file((char *)tmp, sfreader))) + tf = open_file((char *)tmp, sfreader); + if (tf) { noluck = 0; break; diff --git a/src/sound/timiditypp/sffile.cpp b/src/sound/timiditypp/sffile.cpp index 26df7abca0..35899616b0 100644 --- a/src/sound/timiditypp/sffile.cpp +++ b/src/sound/timiditypp/sffile.cpp @@ -69,6 +69,7 @@ static int READCHUNK(SFChunk *vp, struct timidity_file *tf) if (tf_read(vp, 8, 1, tf) != 1) return -1; vp->size = LE_LONG(vp->size); + Printf("%.4s %d, %d\n", vp->id, vp->size, tf_tell(tf)); return 1; } @@ -177,8 +178,10 @@ int Instruments::load_soundfont(SFInfo *sf, struct timidity_file *fd) break; } else { - ctl_cmsg(CMSG_WARNING, VERB_NORMAL, "%s: *** illegal id in level 0: %4.4s %4d", fd->filename.c_str(), chunk.id, chunk.size); + ctl_cmsg(CMSG_WARNING, VERB_NORMAL, "%s: *** illegal id in level 0: %4.4s %4d", fd->filename.c_str(), chunk.id, chunk.size); FSKIP(chunk.size, fd); + // Not aborting here will inevitably crash. + return -1; } } @@ -332,6 +335,7 @@ int Instruments::process_info(int size, SFInfo *sf, struct timidity_file *fd) break; default: + FSKIP(chunk.size, fd); break; } size -= chunk.size; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 6e02c1d5e7..663c20ec9a 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1694,7 +1694,6 @@ OptionMenu AdvSoundOptions protected SubMenu "$ADVSNDMNU_SELCONFIG", "TimidityConfigMenu" Option "$ADVSNDMNU_REVERB", "timidity_reverb", "OnOff" Option "$ADVSNDMNU_CHORUS", "timidity_chorus", "OnOff" - Slider "$ADVSNDMNU_TIMIDITYVOLUME", "timidity_mastervolume", 0, 4, 0.2, 1 StaticText " " StaticText "$ADVSNDMNU_WILDMIDI", 1 TextField "$ADVSNDMNU_WILDMIDICONFIG", "wildmidi_config"