Audio: Add MIDI format playback support

This adds a new dependency with libfuildsynth. MIDI support
is built by default, but can be disabled if not desired.

All RTP songs should work well, but there are known problems
with other files (see README). Also, the pitch shift implementation
is somewhat poor and doesn't match RMXP (at least subjectively).

A soundfont is not included and must be provided by
the user themself.
This commit is contained in:
Jonas Kulla 2014-07-31 03:32:07 +02:00
parent 818ca18ebb
commit 751fdc599e
17 changed files with 1170 additions and 35 deletions

View file

@ -37,6 +37,10 @@
#include "binding.h"
#include "exception.h"
#ifdef MIDI
#include "sharedmidistate.h"
#endif
#include <unistd.h>
#include <stdio.h>
#include <string>
@ -58,6 +62,10 @@ struct SharedStatePrivate
RGSSThreadData &rtData;
Config &config;
#ifdef MIDI
SharedMidiState midiState;
#endif
Graphics graphics;
Input input;
Audio audio;
@ -89,6 +97,9 @@ struct SharedStatePrivate
eThread(*threadData->ethread),
rtData(*threadData),
config(threadData->config),
#ifdef MIDI
midiState(threadData->config),
#endif
graphics(threadData),
fontState(threadData->config),
stampCounter(0)
@ -137,6 +148,12 @@ struct SharedStatePrivate
/* Reuse starting values */
TEXFBO::allocEmpty(gpTexFBO, globalTexW, globalTexH);
TEXFBO::linkFBO(gpTexFBO);
/* RGSS3 games will call setup_midi, so there's
* no need to do it on startup */
#if MIDI && !RGSS3
midiState.initDefaultSynths();
#endif
}
~SharedStatePrivate()
@ -212,6 +229,10 @@ GSATT(TexPool&, texPool)
GSATT(Quad&, gpQuad)
GSATT(SharedFontState&, fontState)
#ifdef MIDI
GSATT(SharedMidiState&, midiState)
#endif
void SharedState::setBindingData(void *data)
{
p->bindingData = data;