From 3c40d71c20805d96d36089559b1112c9ca682a9e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Dec 2015 20:32:19 +0100 Subject: [PATCH] - hopefully fixed the MUS precaching for good. According to blzut3, it looks like it is a byte followed by a variable length field. It can be any value 0-15 and will be followed by that many bytes one for each bank used. If the bank count is 0 then it is shorthand for using one bank (bank 0). --- src/sound/music_mus_midiout.cpp | 16 ++++++++-------- src/wildmidi/wildmidi_lib.cpp | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/sound/music_mus_midiout.cpp b/src/sound/music_mus_midiout.cpp index 5f5d39d18a..e81adc07f0 100644 --- a/src/sound/music_mus_midiout.cpp +++ b/src/sound/music_mus_midiout.cpp @@ -228,18 +228,18 @@ void MUSSong2::Precache() val = instr - 100 + (1 << 14); } - BYTE moreparam = used[k++]; - if (moreparam == 1) + int numbanks = used[k++]; + if (numbanks > 0) { - BYTE bank = used[k++]; - val |= (bank << 7); + for (int b = 0; b < numbanks; b++) + { + work[j++] = val | used[k++]; + } } - else if (moreparam > 0) + else { - // No information if this is even valid. Print a message so it can be investigated later - Printf("Unknown instrument data found in music\n"); + work[j++] = val; } - work[j++] = val; } MIDI->PrecacheInstruments(&work[0], j); } diff --git a/src/wildmidi/wildmidi_lib.cpp b/src/wildmidi/wildmidi_lib.cpp index 94a446e176..0a527ec2a8 100644 --- a/src/wildmidi/wildmidi_lib.cpp +++ b/src/wildmidi/wildmidi_lib.cpp @@ -2719,14 +2719,14 @@ midi *WildMidi_NewMidi() { } } - if ((((_mdi*)ret)->reverb = _WM_init_reverb(_WM_SampleRate, reverb_room_width, - reverb_room_length, reverb_listen_posx, reverb_listen_posy)) - == NULL) { - _WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, "to init reverb", 0); + if ((((_mdi*)ret)->reverb = _WM_init_reverb(_WM_SampleRate, reverb_room_width, + reverb_room_length, reverb_listen_posx, reverb_listen_posy)) + == NULL) { + _WM_ERROR(__FUNCTION__, __LINE__, WM_ERR_MEM, "to init reverb", 0); WildMidi_Close(ret); ret = NULL; - } - + } + return ret; }