[PATCH v2 0/6] MR4224: dmsynth: Various fixes
-- v2: dmsynth: Return void from add_mod_from_connection(). https://gitlab.winehq.org/wine/wine/-/merge_requests/4224
From: Anton Baskanov <baskanov(a)gmail.com> Fixes out-of-tune Harmonica from gm.dls. --- dlls/dmsynth/synth.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 4fabdcdda87..31adf3df1c1 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -1772,8 +1772,11 @@ static int synth_preset_noteon(fluid_preset_t *fluid_preset, fluid_synth_t *flui else FIXME("Unsupported loop type %lu\n", loop->ulType); - fluid_voice_gen_set(fluid_voice, GEN_STARTLOOPADDROFS, loop->ulStart); - fluid_voice_gen_set(fluid_voice, GEN_ENDLOOPADDROFS, loop->ulStart + loop->ulLength); + /* When copy_data is TRUE, fluid_sample_set_sound_data() adds + * 8-frame padding around the sample data. Offset the loop points + * to compensate for this. */ + fluid_voice_gen_set(fluid_voice, GEN_STARTLOOPADDROFS, 8 + loop->ulStart); + fluid_voice_gen_set(fluid_voice, GEN_ENDLOOPADDROFS, 8 + loop->ulStart + loop->ulLength); } LIST_FOR_EACH_ENTRY(articulation, &instrument->articulations, struct articulation, entry) add_voice_connections(fluid_voice, &articulation->list, articulation->connections); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4224
From: Anton Baskanov <baskanov(a)gmail.com> --- dlls/dmsynth/synth.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 31adf3df1c1..2b0c5b45ea5 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -1080,6 +1080,9 @@ static HRESULT WINAPI synth_Render(IDirectMusicSynth8 *iface, short *buffer, case MIDI_PROGRAM_CHANGE: fluid_synth_program_change(This->fluid_synth, chan, event->midi[1]); break; + case MIDI_PITCH_BEND_CHANGE: + fluid_synth_pitch_bend(This->fluid_synth, chan, event->midi[1] | (event->midi[2] << 7)); + break; default: FIXME("MIDI event not implemented: %#x %#x %#x\n", event->midi[0], event->midi[1], event->midi[2]); break; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4224
From: Anton Baskanov <baskanov(a)gmail.com> Fixes pitch bend scale. --- dlls/dmsynth/synth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 2b0c5b45ea5..72696cca856 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -1563,7 +1563,7 @@ static void add_voice_connections(fluid_voice_t *fluid_voice, const CONNECTIONLI if (!mod_from_connection(conn->usSource, (conn->usTransform >> 10) & 0x3f, &src1, &flags1)) continue; - if (!mod_from_connection(conn->usControl, (conn->usControl >> 4) & 0x3f, + if (!mod_from_connection(conn->usControl, (conn->usTransform >> 4) & 0x3f, &src2, &flags2)) continue; add_mod_from_connection(fluid_voice, conn, src1, flags1, src2, flags2); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4224
From: Anton Baskanov <baskanov(a)gmail.com> Fixes modulation wheel effects. --- dlls/dmsynth/synth.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 72696cca856..ee1ec1aad06 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -1497,9 +1497,9 @@ static BOOL mod_from_connection(USHORT source, USHORT transform, UINT *fluid_sou return TRUE; } -static BOOL add_mod_from_connection(fluid_voice_t *fluid_voice, const CONNECTION *conn, - UINT src1, UINT flags1, UINT src2, UINT flags2) +static BOOL add_mod_from_connection(fluid_voice_t *fluid_voice, const CONNECTION *conn) { + UINT src1 = FLUID_MOD_NONE, flags1 = 0, src2 = FLUID_MOD_NONE, flags2 = 0; fluid_mod_t *mod; UINT gen = -1; double value; @@ -1520,10 +1520,15 @@ static BOOL add_mod_from_connection(fluid_voice_t *fluid_voice, const CONNECTION if (conn->usControl != CONN_SRC_NONE && gen != -1) { - src1 = src2; - flags1 = flags2; - src2 = 0; - flags2 = 0; + if (!mod_from_connection(conn->usControl, (conn->usTransform >> 4) & 0x3f, &src1, &flags1)) + return FALSE; + } + else + { + if (!mod_from_connection(conn->usSource, (conn->usTransform >> 10) & 0x3f, &src1, &flags1)) + return FALSE; + if (!mod_from_connection(conn->usControl, (conn->usTransform >> 4) & 0x3f, &src2, &flags2)) + return FALSE; } if (gen == -1 && !gen_from_connection(conn, &gen)) return FALSE; @@ -1555,18 +1560,11 @@ static void add_voice_connections(fluid_voice_t *fluid_voice, const CONNECTIONLI for (i = 0; i < list->cConnections; i++) { - UINT src1 = FLUID_MOD_NONE, flags1 = 0, src2 = FLUID_MOD_NONE, flags2 = 0; const CONNECTION *conn = connections + i; if (set_gen_from_connection(fluid_voice, conn)) continue; - if (!mod_from_connection(conn->usSource, (conn->usTransform >> 10) & 0x3f, - &src1, &flags1)) - continue; - if (!mod_from_connection(conn->usControl, (conn->usTransform >> 4) & 0x3f, - &src2, &flags2)) - continue; - add_mod_from_connection(fluid_voice, conn, src1, flags1, src2, flags2); + add_mod_from_connection(fluid_voice, conn); } } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4224
From: Anton Baskanov <baskanov(a)gmail.com> --- dlls/dmsynth/synth.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index ee1ec1aad06..f6565c7a36d 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -565,6 +565,10 @@ static HRESULT WINAPI synth_Open(IDirectMusicSynth8 *iface, DMUS_PORTPARAMS *par } fluid_settings_setnum(This->fluid_settings, "synth.sample-rate", actual.dwSampleRate); + fluid_settings_setint(This->fluid_settings, "synth.reverb.active", + !!(actual.dwEffectFlags & DMUS_EFFECT_REVERB)); + fluid_settings_setint(This->fluid_settings, "synth.chorus.active", + !!(actual.dwEffectFlags & DMUS_EFFECT_CHORUS)); if (!(This->fluid_synth = new_fluid_synth(This->fluid_settings))) return E_OUTOFMEMORY; if ((id = fluid_synth_add_sfont(This->fluid_synth, This->fluid_sfont)) == FLUID_FAILED) WARN("Failed to add fluid_sfont to fluid_synth\n"); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4224
From: Anton Baskanov <baskanov(a)gmail.com> --- dlls/dmsynth/synth.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index f6565c7a36d..fcf709ec21c 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -1501,7 +1501,7 @@ static BOOL mod_from_connection(USHORT source, USHORT transform, UINT *fluid_sou return TRUE; } -static BOOL add_mod_from_connection(fluid_voice_t *fluid_voice, const CONNECTION *conn) +static void add_mod_from_connection(fluid_voice_t *fluid_voice, const CONNECTION *conn) { UINT src1 = FLUID_MOD_NONE, flags1 = 0, src2 = FLUID_MOD_NONE, flags2 = 0; fluid_mod_t *mod; @@ -1525,19 +1525,19 @@ static BOOL add_mod_from_connection(fluid_voice_t *fluid_voice, const CONNECTION if (conn->usControl != CONN_SRC_NONE && gen != -1) { if (!mod_from_connection(conn->usControl, (conn->usTransform >> 4) & 0x3f, &src1, &flags1)) - return FALSE; + return; } else { if (!mod_from_connection(conn->usSource, (conn->usTransform >> 10) & 0x3f, &src1, &flags1)) - return FALSE; + return; if (!mod_from_connection(conn->usControl, (conn->usTransform >> 4) & 0x3f, &src2, &flags2)) - return FALSE; + return; } - if (gen == -1 && !gen_from_connection(conn, &gen)) return FALSE; + if (gen == -1 && !gen_from_connection(conn, &gen)) return; - if (!(mod = new_fluid_mod())) return FALSE; + if (!(mod = new_fluid_mod())) return; fluid_mod_set_source1(mod, src1, flags1); fluid_mod_set_source2(mod, src2, flags2); fluid_mod_set_dest(mod, gen); @@ -1553,8 +1553,6 @@ static BOOL add_mod_from_connection(fluid_voice_t *fluid_voice, const CONNECTION fluid_mod_set_amount(mod, value); fluid_voice_add_mod(fluid_voice, mod, FLUID_VOICE_OVERWRITE); - - return TRUE; } static void add_voice_connections(fluid_voice_t *fluid_voice, const CONNECTIONLIST *list, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4224
Correct me if I'm wrong, but it looks like there's no way to set `sample->notify` through FluidSynth API.
Indeed... I think the only way that doesn't involve changing FluidSynth is to keep track of voice/sample mapping, and release the previously associated sample/wave whenever a voice is seen again (as `fluid_synth_alloc_voice` recycles voices), or when the synth is destroyed. We could then either create the samples with the waves, or separately, depending on whether we want to avoid a copy. But maybe we can just keep the copy after all. Anyway, as you say we'll still have to offset the loop, so the change here seems fine and the sample leak fix could be done separately. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4224#note_50290
This merge request was approved by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4224
Unrelated test failures in device8 and win tests -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4224#note_50379
This merge request was approved by Michael Stefaniuc. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4224
participants (4)
-
Anton Baskanov -
Anton Baskanov (@baskanov) -
Michael Stefaniuc (@mstefani) -
Rémi Bernon