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

@ -157,6 +157,12 @@ struct VorbisSource : ALDataSource
void seekToOffset(float seconds)
{
if (seconds <= 0)
{
ov_raw_seek(&vf, 0);
currentFrame = 0;
}
currentFrame = seconds * info.rate;
if (loop.valid && currentFrame > loop.end)
@ -205,7 +211,7 @@ struct VorbisSource : ALDataSource
if (loop.requested)
{
retStatus = ALDataSource::WrapAround;
reset();
seekToOffset(0);
}
else
{
@ -261,12 +267,6 @@ struct VorbisSource : ALDataSource
return retStatus;
}
void reset()
{
ov_raw_seek(&vf, 0);
currentFrame = 0;
}
uint32_t loopStartFrames()
{
if (loop.valid)
@ -274,6 +274,11 @@ struct VorbisSource : ALDataSource
else
return 0;
}
bool setPitch(float)
{
return false;
}
};
ALDataSource *createVorbisSource(SDL_RWops &ops,