From: Anton Baskanov baskanov@gmail.com
--- dlls/dmime/performance.c | 23 ++++++++++++++++++----- dlls/dmime/tests/dmime.c | 18 +++++++++--------- 2 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index 01e0bad51b3..10f4f795432 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -2062,12 +2062,25 @@ static HRESULT WINAPI performance_tool_ProcessPMsg(IDirectMusicTool *iface, DMUS_NOTE_PMSG *note = (DMUS_NOTE_PMSG *)msg;
msg->mtTime += note->nOffset; - if (FAILED(hr = performance_send_midi_pmsg(This, msg, DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_TOOL_IMMEDIATE, - MIDI_NOTE_ON, note->bMidiValue, note->bVelocity))) - WARN("Failed to translate message to MIDI, hr %#lx\n", hr);
- msg->mtTime += note->mtDuration; - if (FAILED(hr = performance_send_midi_pmsg(This, msg, DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_TOOL_QUEUE, + if (note->bFlags & DMUS_NOTEF_NOTEON) + { + if (FAILED(hr = performance_send_midi_pmsg(This, msg, DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_TOOL_IMMEDIATE, + MIDI_NOTE_ON, note->bMidiValue, note->bVelocity))) + WARN("Failed to translate message to MIDI, hr %#lx\n", hr); + + if (note->mtDuration) + { + msg->mtTime -= note->nOffset; + msg->mtTime += note->mtDuration; + if (FAILED(hr = IDirectMusicPerformance8_MusicToReferenceTime(performance, msg->mtTime, &msg->rtTime))) + return hr; + note->bFlags &= ~DMUS_NOTEF_NOTEON; + return DMUS_S_REQUEUE; + } + } + + if (FAILED(hr = performance_send_midi_pmsg(This, msg, DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_TOOL_IMMEDIATE, MIDI_NOTE_OFF, note->bMidiValue, 0))) WARN("Failed to translate message to MIDI, hr %#lx\n", hr);
diff --git a/dlls/dmime/tests/dmime.c b/dlls/dmime/tests/dmime.c index 94f781d2796..4edab18c283 100644 --- a/dlls/dmime/tests/dmime.c +++ b/dlls/dmime/tests/dmime.c @@ -2633,11 +2633,11 @@ static void test_performance_tool(void)
*note = note60; hr = IDirectMusicTool_ProcessPMsg(tool, performance, (DMUS_PMSG *)note); - todo_wine ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); + ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); todo_wine ok(fabs(note->rtTime - note60.rtTime - scale_music_time(999, 120.0)) < 10.0, "got %I64d\n", note->rtTime - note60.rtTime); todo_wine ok(note->mtTime - note60.mtTime == 999, "got %ld\n", note->mtTime - note60.mtTime); - check_dmus_note_pmsg(note, note60.mtTime + 999, 0, 1000, 60, 127, 0, FALSE, TRUE); + check_dmus_note_pmsg(note, note60.mtTime + 999, 0, 1000, 60, 127, 0, FALSE, FALSE);
hr = IDirectMusicPerformance_GetTime(performance, NULL, ¬e60.mtTime); ok(hr == S_OK, "got %#lx\n", hr); @@ -2647,11 +2647,11 @@ static void test_performance_tool(void) *note = note60; note->nOffset = 1000; hr = IDirectMusicTool_ProcessPMsg(tool, performance, (DMUS_PMSG *)note); - todo_wine ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); + ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); todo_wine ok(fabs(note->rtTime - note60.rtTime - scale_music_time(999, 120.0)) < 10.0, "got %I64d\n", note->rtTime - note60.rtTime); todo_wine ok(note->mtTime - note60.mtTime == 999, "got %ld\n", note->mtTime - note60.mtTime); - check_dmus_note_pmsg(note, note60.mtTime + 999, 0, 1000, 60, 127, 0, TRUE, TRUE); + check_dmus_note_pmsg(note, note60.mtTime + 999, 0, 1000, 60, 127, 0, FALSE, FALSE);
hr = IDirectMusicPerformance_GetTime(performance, NULL, ¬e60.mtTime); ok(hr == S_OK, "got %#lx\n", hr); @@ -2661,11 +2661,11 @@ static void test_performance_tool(void) *note = note60; note->mtDuration = 2; hr = IDirectMusicTool_ProcessPMsg(tool, performance, (DMUS_PMSG *)note); - todo_wine ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); + ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); todo_wine ok(fabs(note->rtTime - note60.rtTime - scale_music_time(1, 120.0)) < 10.0, "got %I64d\n", note->rtTime - note60.rtTime); todo_wine ok(note->mtTime - note60.mtTime == 1, "got %ld\n", note->mtTime - note60.mtTime); - check_dmus_note_pmsg(note, note60.mtTime + 1, 0, 2, 60, 127, 0, FALSE, TRUE); + check_dmus_note_pmsg(note, note60.mtTime + 1, 0, 2, 60, 127, 0, FALSE, FALSE);
hr = IDirectMusicPerformance_GetTime(performance, NULL, ¬e60.mtTime); ok(hr == S_OK, "got %#lx\n", hr); @@ -2675,11 +2675,11 @@ static void test_performance_tool(void) *note = note60; note->mtDuration = 1; hr = IDirectMusicTool_ProcessPMsg(tool, performance, (DMUS_PMSG *)note); - todo_wine ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); - todo_wine ok(fabs(note->rtTime - note60.rtTime - scale_music_time(1, 120.0)) < 10.0, + ok(hr == DMUS_S_REQUEUE, "got %#lx\n", hr); + ok(fabs(note->rtTime - note60.rtTime - scale_music_time(1, 120.0)) < 10.0, "got %I64d\n", note->rtTime - note60.rtTime); ok(note->mtTime - note60.mtTime == 1, "got %ld\n", note->mtTime - note60.mtTime); - check_dmus_note_pmsg(note, note60.mtTime + 1, 0, 1, 60, 127, 0, FALSE, TRUE); + check_dmus_note_pmsg(note, note60.mtTime + 1, 0, 1, 60, 127, 0, FALSE, FALSE);
hr = IDirectMusicPerformance_FreePMsg(performance, (DMUS_PMSG *)note); ok(hr == S_OK, "got %#lx\n", hr);