- fixed Timidity++ playback.

This commit is contained in:
Christoph Oelckers 2018-02-23 18:33:54 +01:00
parent 4a179954b1
commit 88f9f0982c
7 changed files with 26 additions and 45 deletions

View file

@ -268,10 +268,6 @@ void MusInfo::MusicVolumeChanged()
{
}
void MusInfo::TimidityVolumeChanged()
{
}
void MusInfo::GMEDepthChanged(float val)
{
}

View file

@ -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;

View file

@ -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,12 +117,12 @@ TimidityPPMIDIDevice::TimidityPPMIDIDevice(const char *args)
if (instruments == nullptr)
{
instruments = new TimidityPlus::Instruments;
}
if (!instruments->load(args))
{
delete instruments;
instruments = nullptr;
}
}
if (instruments != nullptr)
{
Renderer = new TimidityPlus::Player(timidity_frequency, instruments);
@ -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;
}

View file

@ -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

View file

@ -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;

View file

@ -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;
}
@ -179,6 +180,8 @@ int Instruments::load_soundfont(SFInfo *sf, struct timidity_file *fd)
else {
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;

View file

@ -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"