aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-07-19 13:44:02 -0700
committerChris Robinson <[email protected]>2014-07-19 13:44:02 -0700
commit36381f316496aac24919fb27b855b43bb2d97432 (patch)
tree6651254374ea190bfcc3bc6ec573378b0bdce2f6 /OpenAL32
parent994c3f00e51b7263d4e24bde81de048584372d49 (diff)
Load the default soundfont as a comma-separate list of filename
This allows multiple soundfont files to be "patched" together to create a single soundfont. For instance a GM soundfont with a separate soundfont for GS-only additions.
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/alSoundfont.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/OpenAL32/alSoundfont.c b/OpenAL32/alSoundfont.c
index 40a93021..ac181125 100644
--- a/OpenAL32/alSoundfont.c
+++ b/OpenAL32/alSoundfont.c
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "alMain.h"
#include "alMidi.h"
@@ -306,7 +307,8 @@ void ALsoundfont_Destruct(ALsoundfont *self)
ALsoundfont *ALsoundfont_getDefSoundfont(ALCcontext *context)
{
ALCdevice *device = context->Device;
- const char *fname;
+ al_string fname = AL_STRING_INIT_STATIC();
+ const char *namelist;
if(device->DefaultSfont)
return device->DefaultSfont;
@@ -314,25 +316,44 @@ ALsoundfont *ALsoundfont_getDefSoundfont(ALCcontext *context)
device->DefaultSfont = calloc(1, sizeof(device->DefaultSfont[0]));
ALsoundfont_Construct(device->DefaultSfont);
- fname = getenv("ALSOFT_SOUNDFONT");
- if((fname && fname[0]) || ConfigValueStr("midi", "soundfont", &fname))
+ namelist = getenv("ALSOFT_SOUNDFONT");
+ if(!namelist || !namelist[0])
+ ConfigValueStr("midi", "soundfont", &namelist);
+ while(namelist && namelist[0])
{
+ const char *next, *end;
FILE *f;
- f = OpenDataFile(fname, "openal/soundfonts");
+ while(*namelist && (isspace(*namelist) || *namelist == ','))
+ namelist++;
+ if(!*namelist)
+ break;
+ next = strchr(namelist, ',');
+ end = next ? next++ : (namelist+strlen(namelist));
+ while(--end != namelist && isspace(*end)) {
+ }
+ if(end == namelist)
+ continue;
+ al_string_append_range(&fname, namelist, end+1);
+ namelist = next;
+
+ f = OpenDataFile(al_string_get_cstr(fname), "openal/soundfonts");
if(f == NULL)
- ERR("Failed to open %s\n", fname);
+ ERR("Failed to open %s\n", al_string_get_cstr(fname));
else
{
Reader reader;
reader.cb = ALsoundfont_read;
reader.ptr = f;
reader.error = 0;
- TRACE("Loading %s\n", fname);
+ TRACE("Loading %s\n", al_string_get_cstr(fname));
loadSf2(&reader, device->DefaultSfont, context);
fclose(f);
}
+
+ al_string_clear(&fname);
}
+ AL_STRING_DEINIT(fname);
return device->DefaultSfont;
}