mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-08 14:00:43 +00:00
01f59fa85f
heavily customized version of DUMB (Dynamic Universal Music Bibliotheque). It has been slightly modified by me: * Added support for Ogg Vorbis-compressed samples in XM files ala FMOD. * Removed excessive mallocs from the replay core. * Rerolled the loops in resample.c. Unrolling them made the object file ~250k large while providing little benefit. Even at ~100k, I think it's still larger than it ought to be, but I'll live with it for now. Other than that, it's essentially the same thing you'd hear in foobar2000, minus some subsong detection features. Release builds of the library look like they might even be slightly faster than FMOD, which is a plus. - Fixed: Timidity::font_add() did not release the file reader it created. - Fixed: The SF2 loader did not free the sample headers in its destructor. SVN r995 (trunk)
133 lines
2.4 KiB
C++
133 lines
2.4 KiB
C++
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
#include "doomdef.h"
|
|
#include "m_swap.h"
|
|
#include "templates.h"
|
|
#include "timidity.h"
|
|
#include "sf2.h"
|
|
#include "files.h"
|
|
|
|
namespace Timidity
|
|
{
|
|
|
|
FontFile *Fonts;
|
|
|
|
FontFile *ReadDLS(const char *filename, FileReader *f)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
void font_freeall()
|
|
{
|
|
FontFile *font, *next;
|
|
|
|
for (font = Fonts; font != NULL; font = next)
|
|
{
|
|
next = font->Next;
|
|
delete font;
|
|
}
|
|
Fonts = NULL;
|
|
}
|
|
|
|
FontFile *font_find(const char *filename)
|
|
{
|
|
for (FontFile *font = Fonts; font != NULL; font = font->Next)
|
|
{
|
|
if (stricmp(filename, font->Filename) == 0)
|
|
{
|
|
return font;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void font_add(const char *filename, int load_order)
|
|
{
|
|
FontFile *font;
|
|
|
|
font = font_find(filename);
|
|
if (font != NULL)
|
|
{
|
|
font->SetAllOrders(load_order);
|
|
}
|
|
else
|
|
{
|
|
FileReader *fp = open_filereader(filename, openmode, NULL);
|
|
|
|
if (fp != NULL)
|
|
{
|
|
if ((font = ReadSF2(filename, fp)) || (font = ReadDLS(filename, fp)))
|
|
{
|
|
font->SetAllOrders(load_order);
|
|
}
|
|
delete fp;
|
|
}
|
|
}
|
|
}
|
|
|
|
void font_remove(const char *filename)
|
|
{
|
|
FontFile *font;
|
|
|
|
font = font_find(filename);
|
|
if (font != NULL)
|
|
{
|
|
// Don't actually remove the font from the list, because instruments
|
|
// from it might be loaded using the %font extension.
|
|
font->SetAllOrders(255);
|
|
}
|
|
}
|
|
|
|
void font_order(int order, int bank, int preset, int keynote)
|
|
{
|
|
for (FontFile *font = Fonts; font != NULL; font = font->Next)
|
|
{
|
|
font->SetOrder(order, bank, preset, keynote);
|
|
}
|
|
}
|
|
|
|
Instrument *load_instrument_font(struct Renderer *song, const char *font, int drum, int bank, int instr)
|
|
{
|
|
FontFile *fontfile = font_find(font);
|
|
if (fontfile != NULL)
|
|
{
|
|
return fontfile->LoadInstrument(song, drum, bank, instr);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
Instrument *load_instrument_font_order(struct Renderer *song, int order, int drum, int bank, int instr)
|
|
{
|
|
for (FontFile *font = Fonts; font != NULL; font = font->Next)
|
|
{
|
|
Instrument *ip = font->LoadInstrument(song, drum, bank, instr);
|
|
if (ip != NULL)
|
|
{
|
|
return ip;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
FontFile::FontFile(FString filename)
|
|
: Filename(filename)
|
|
{
|
|
Next = Fonts;
|
|
Fonts = this;
|
|
}
|
|
|
|
FontFile::~FontFile()
|
|
{
|
|
for (FontFile **probe = &Fonts; *probe != NULL; probe = &(*probe)->Next)
|
|
{
|
|
if (*probe == this)
|
|
{
|
|
*probe = Next;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|