Required by many SF2 instruments.
From: Anton Baskanov baskanov@gmail.com
--- dlls/dmsynth/synth.c | 63 +++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 27 deletions(-)
diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index e0fe70f264f..92d28b05166 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -1910,41 +1910,19 @@ static void set_default_voice_connections(fluid_voice_t *fluid_voice) add_voice_connections(fluid_voice, &list, connections); }
-static int synth_preset_noteon(fluid_preset_t *fluid_preset, fluid_synth_t *fluid_synth, int chan, int key, int vel) +static int play_region(struct synth *synth, struct instrument *instrument, struct region *region, + int chan, int key, int vel) { - struct preset *preset = fluid_preset_get_data(fluid_preset); - struct synth *synth = preset->synth; struct articulation *articulation; - struct instrument *instrument; fluid_voice_t *fluid_voice; - struct region *region; struct voice *voice; struct wave *wave; - UINT patch; - - TRACE("(%p, %p, %u, %u, %u)\n", fluid_preset, fluid_synth, chan, key, vel); - - EnterCriticalSection(&synth->cs); - - patch = preset->patch; - patch |= (preset->bank << 8) & 0x007f00; - patch |= (preset->bank << 9) & 0x7f0000; - if (chan == 9) - patch |= F_INSTRUMENT_DRUMS; - - find_region(synth, patch, key, vel, &instrument, ®ion); - if (!region) - { - LeaveCriticalSection(&synth->cs); - return FLUID_FAILED; - }
wave = region->wave;
if (!(fluid_voice = fluid_synth_alloc_voice(synth->fluid_synth, wave->fluid_sample, chan, key, vel))) { WARN("Failed to allocate FluidSynth voice\n"); - LeaveCriticalSection(&synth->cs); return FLUID_FAILED; }
@@ -1964,10 +1942,7 @@ static int synth_preset_noteon(fluid_preset_t *fluid_preset, fluid_synth_t *flui if (&voice->entry == &synth->voices) { if (!(voice = calloc(1, sizeof(struct voice)))) - { - LeaveCriticalSection(&synth->cs); return FLUID_FAILED; - } voice->fluid_voice = fluid_voice; list_add_tail(&synth->voices, &voice->entry); } @@ -2005,6 +1980,40 @@ static int synth_preset_noteon(fluid_preset_t *fluid_preset, fluid_synth_t *flui fluid_voice_gen_set(voice->fluid_voice, GEN_EXCLUSIVECLASS, region->group); fluid_synth_start_voice(synth->fluid_synth, fluid_voice);
+ return FLUID_OK; +} + +static int synth_preset_noteon(fluid_preset_t *fluid_preset, fluid_synth_t *fluid_synth, int chan, int key, int vel) +{ + struct preset *preset = fluid_preset_get_data(fluid_preset); + struct synth *synth = preset->synth; + struct instrument *instrument; + struct region *region; + UINT patch; + + TRACE("(%p, %p, %u, %u, %u)\n", fluid_preset, fluid_synth, chan, key, vel); + + EnterCriticalSection(&synth->cs); + + patch = preset->patch; + patch |= (preset->bank << 8) & 0x007f00; + patch |= (preset->bank << 9) & 0x7f0000; + if (chan == 9) + patch |= F_INSTRUMENT_DRUMS; + + find_region(synth, patch, key, vel, &instrument, ®ion); + if (!region) + { + LeaveCriticalSection(&synth->cs); + return FLUID_FAILED; + } + + if (FLUID_OK != play_region(synth, instrument, region, chan, key, vel)) + { + LeaveCriticalSection(&synth->cs); + return FLUID_FAILED; + } + LeaveCriticalSection(&synth->cs);
return FLUID_OK;
From: Anton Baskanov baskanov@gmail.com
--- dlls/dmsynth/synth.c | 84 ++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 42 deletions(-)
diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 92d28b05166..13ac602f36a 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -1519,48 +1519,6 @@ static int synth_preset_get_num(fluid_preset_t *fluid_preset) return preset->patch; }
-static void find_region_no_fallback(struct synth *synth, int patch, int key, int vel, - struct instrument **out_instrument, struct region **out_region) -{ - struct instrument *instrument; - struct region *region; - - *out_instrument = NULL; - *out_region = NULL; - - LIST_FOR_EACH_ENTRY(instrument, &synth->instruments, struct instrument, entry) - { - if (instrument->patch == patch) - break; - } - - if (&instrument->entry == &synth->instruments) - return; - - *out_instrument = instrument; - - LIST_FOR_EACH_ENTRY(region, &instrument->regions, struct region, entry) - { - if (key < region->key_range.usLow || key > region->key_range.usHigh) continue; - if (vel < region->vel_range.usLow || vel > region->vel_range.usHigh) continue; - *out_region = region; - break; - } -} - -static void find_region(struct synth *synth, int patch, int key, int vel, - struct instrument **out_instrument, struct region **out_region) -{ - find_region_no_fallback(synth, patch, key, vel, out_instrument, out_region); - if (!*out_region && (patch & F_INSTRUMENT_DRUMS)) - find_region_no_fallback(synth, F_INSTRUMENT_DRUMS, key, vel, out_instrument, out_region); - - if (!*out_instrument) - WARN("Could not find instrument with patch %#x\n", patch); - else if (!*out_region) - WARN("Failed to find instrument matching note / velocity\n"); -} - static BOOL gen_from_connection(const CONNECTION *conn, UINT *gen) { switch (conn->usDestination) @@ -1983,6 +1941,48 @@ static int play_region(struct synth *synth, struct instrument *instrument, struc return FLUID_OK; }
+static void find_region_no_fallback(struct synth *synth, int patch, int key, int vel, + struct instrument **out_instrument, struct region **out_region) +{ + struct instrument *instrument; + struct region *region; + + *out_instrument = NULL; + *out_region = NULL; + + LIST_FOR_EACH_ENTRY(instrument, &synth->instruments, struct instrument, entry) + { + if (instrument->patch == patch) + break; + } + + if (&instrument->entry == &synth->instruments) + return; + + *out_instrument = instrument; + + LIST_FOR_EACH_ENTRY(region, &instrument->regions, struct region, entry) + { + if (key < region->key_range.usLow || key > region->key_range.usHigh) continue; + if (vel < region->vel_range.usLow || vel > region->vel_range.usHigh) continue; + *out_region = region; + break; + } +} + +static void find_region(struct synth *synth, int patch, int key, int vel, + struct instrument **out_instrument, struct region **out_region) +{ + find_region_no_fallback(synth, patch, key, vel, out_instrument, out_region); + if (!*out_region && (patch & F_INSTRUMENT_DRUMS)) + find_region_no_fallback(synth, F_INSTRUMENT_DRUMS, key, vel, out_instrument, out_region); + + if (!*out_instrument) + WARN("Could not find instrument with patch %#x\n", patch); + else if (!*out_region) + WARN("Failed to find instrument matching note / velocity\n"); +} + static int synth_preset_noteon(fluid_preset_t *fluid_preset, fluid_synth_t *fluid_synth, int chan, int key, int vel) { struct preset *preset = fluid_preset_get_data(fluid_preset);
From: Anton Baskanov baskanov@gmail.com
Required by many SF2 instruments. --- dlls/dmsynth/synth.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 13ac602f36a..ff862b62984 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -1941,7 +1941,7 @@ static int play_region(struct synth *synth, struct instrument *instrument, struc return FLUID_OK; }
-static void find_region_no_fallback(struct synth *synth, int patch, int key, int vel, +static int play_instrument_no_fallback(struct synth *synth, int chan, int patch, int key, int vel, struct instrument **out_instrument, struct region **out_region) { struct instrument *instrument; @@ -1957,7 +1957,7 @@ static void find_region_no_fallback(struct synth *synth, int patch, int key, int }
if (&instrument->entry == &synth->instruments) - return; + return FLUID_FAILED;
*out_instrument = instrument;
@@ -1966,29 +1966,38 @@ static void find_region_no_fallback(struct synth *synth, int patch, int key, int if (key < region->key_range.usLow || key > region->key_range.usHigh) continue; if (vel < region->vel_range.usLow || vel > region->vel_range.usHigh) continue; *out_region = region; - break; + if (FLUID_OK != play_region(synth, instrument, region, chan, key, vel)) + return FLUID_FAILED; } + + if (®ion->entry == &instrument->regions) + return FLUID_FAILED; + + return FLUID_OK; }
-static void find_region(struct synth *synth, int patch, int key, int vel, - struct instrument **out_instrument, struct region **out_region) +static int play_instrument(struct synth *synth, int chan, int patch, int key, int vel) { - find_region_no_fallback(synth, patch, key, vel, out_instrument, out_region); - if (!*out_region && (patch & F_INSTRUMENT_DRUMS)) - find_region_no_fallback(synth, F_INSTRUMENT_DRUMS, key, vel, out_instrument, out_region); + struct instrument *instrument; + struct region *region; + int result;
- if (!*out_instrument) + result = play_instrument_no_fallback(synth, chan, patch, key, vel, &instrument, ®ion); + if (!region && (patch & F_INSTRUMENT_DRUMS)) + result = play_instrument_no_fallback(synth, chan, F_INSTRUMENT_DRUMS, key, vel, &instrument, ®ion); + + if (!instrument) WARN("Could not find instrument with patch %#x\n", patch); - else if (!*out_region) + else if (!region) WARN("Failed to find instrument matching note / velocity\n"); + + return result; }
static int synth_preset_noteon(fluid_preset_t *fluid_preset, fluid_synth_t *fluid_synth, int chan, int key, int vel) { struct preset *preset = fluid_preset_get_data(fluid_preset); struct synth *synth = preset->synth; - struct instrument *instrument; - struct region *region; UINT patch;
TRACE("(%p, %p, %u, %u, %u)\n", fluid_preset, fluid_synth, chan, key, vel); @@ -2001,14 +2010,7 @@ static int synth_preset_noteon(fluid_preset_t *fluid_preset, fluid_synth_t *flui if (chan == 9) patch |= F_INSTRUMENT_DRUMS;
- find_region(synth, patch, key, vel, &instrument, ®ion); - if (!region) - { - LeaveCriticalSection(&synth->cs); - return FLUID_FAILED; - } - - if (FLUID_OK != play_region(synth, instrument, region, chan, key, vel)) + if (FLUID_OK != play_instrument(synth, chan, patch, key, vel)) { LeaveCriticalSection(&synth->cs); return FLUID_FAILED;
This merge request was approved by Rémi Bernon.
This merge request was approved by Michael Stefaniuc.
Test failures are unrelated (user32/win)