diff options
author | Chris Robinson <[email protected]> | 2014-07-19 12:42:52 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-07-19 12:42:52 -0700 |
commit | 994c3f00e51b7263d4e24bde81de048584372d49 (patch) | |
tree | 0df81da2301c3e0d58483e910e70607cf8c130a0 /Alc | |
parent | 85e135beea1ff79aa5127ce92d5647bce8da2952 (diff) |
Keep existing presets when loading in a new soundfont
Note that alLoadSoundfontSOFT doesn't currently allow using a soundfont with
existing presets. This is for being able to load and stack multiple soundfonts
for the default soundfont.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/midi/sf2load.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Alc/midi/sf2load.c b/Alc/midi/sf2load.c index dd1a4518..4b8fd6a6 100644 --- a/Alc/midi/sf2load.c +++ b/Alc/midi/sf2load.c @@ -1245,9 +1245,11 @@ ALboolean loadSf2(Reader *stream, ALsoundfont *soundfont, ALCcontext *context) if(!ensureFontSanity(&sfont)) goto error; - presets = calloc(1, (sfont.phdr_size-1)*sizeof(presets[0])); + presets = calloc(1, (soundfont->NumPresets+sfont.phdr_size-1)*sizeof(presets[0])); if(!presets) ERROR_GOTO(error, "Error allocating presets\n"); + memcpy(presets, soundfont->Presets, soundfont->NumPresets*sizeof(presets[0])); + presets_size = soundfont->NumPresets; for(i = 0;i < sfont.phdr_size-1;i++) { @@ -1341,7 +1343,7 @@ ALboolean loadSf2(Reader *stream, ALsoundfont *soundfont, ALCcontext *context) GenModList_Destruct(&gzone); } - for(i = 0;i < presets_size;i++) + for(i = soundfont->NumPresets;i < presets_size;i++) IncrementRef(&presets[i]->ref); presets = ExchangePtr((XchgPtr*)&soundfont->Presets, presets); ExchangeInt(&soundfont->NumPresets, presets_size); @@ -1359,7 +1361,7 @@ error: if(presets) { ALCdevice *device = context->Device; - for(i = 0;i < presets_size;i++) + for(i = soundfont->NumPresets;i < presets_size;i++) DeletePreset(device, presets[i]); free(presets); } |