Module: wine Branch: master Commit: 2c4fc0adcf66e47455e01651e464b71c8d244b0c URL: https://gitlab.winehq.org/wine/wine/-/commit/2c4fc0adcf66e47455e01651e464b71...
Author: Rémi Bernon rbernon@codeweavers.com Date: Mon Oct 16 20:03:19 2023 +0200
dmusic: Use a dmusic_midi.h header for MIDI messages.
---
dlls/dmime/performance.c | 11 ++++++----- dlls/dmsynth/Makefile.in | 1 + dlls/dmsynth/synth.c | 9 +++++---- dlls/dmusic/dmusic_midi.h | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 9 deletions(-)
diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c index 8ea01b168d7..f120cc6f0a9 100644 --- a/dlls/dmime/performance.c +++ b/dlls/dmime/performance.c @@ -19,6 +19,7 @@ */
#include "dmime_private.h" +#include "dmusic_midi.h" #include "wine/rbtree.h"
WINE_DEFAULT_DEBUG_CHANNEL(dmime); @@ -1702,12 +1703,12 @@ static HRESULT WINAPI performance_tool_ProcessPMsg(IDirectMusicTool *iface,
msg->mtTime += note->nOffset; if (FAILED(hr = performance_send_midi_pmsg(This, msg, DMUS_PMSGF_REFTIME | DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_TOOL_IMMEDIATE, - 0x90 /* NOTE_ON */, note->bMidiValue, note->bVelocity))) + 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, - 0x80 /* NOTE_OFF */, note->bMidiValue, 0))) + MIDI_NOTE_OFF, note->bMidiValue, 0))) WARN("Failed to translate message to MIDI, hr %#lx\n", hr);
break; @@ -1718,15 +1719,15 @@ static HRESULT WINAPI performance_tool_ProcessPMsg(IDirectMusicTool *iface, DMUS_PATCH_PMSG *patch = (DMUS_PATCH_PMSG *)msg;
if (FAILED(hr = performance_send_midi_pmsg(This, msg, DMUS_PMSGF_REFTIME | DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_TOOL_IMMEDIATE, - 0xb0 /* Control Change */, 0x00 /* CC: Bank MSB */, patch->byMSB))) + MIDI_CONTROL_CHANGE, MIDI_CC_BANK_MSB, patch->byMSB))) WARN("Failed to translate message to MIDI, hr %#lx\n", hr);
if (FAILED(hr = performance_send_midi_pmsg(This, msg, DMUS_PMSGF_REFTIME | DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_TOOL_IMMEDIATE, - 0xb0 /* Control Change */, 0x20 /* CC: Bank LSB */, patch->byLSB))) + MIDI_CONTROL_CHANGE, MIDI_CC_BANK_LSB, patch->byLSB))) WARN("Failed to translate message to MIDI, hr %#lx\n", hr);
if (FAILED(hr = performance_send_midi_pmsg(This, msg, DMUS_PMSGF_REFTIME | DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_TOOL_IMMEDIATE, - 0xc0 /* Program Change */, patch->byInstrument, 0))) + MIDI_PROGRAM_CHANGE, patch->byInstrument, 0))) WARN("Failed to translate message to MIDI, hr %#lx\n", hr);
break; diff --git a/dlls/dmsynth/Makefile.in b/dlls/dmsynth/Makefile.in index 7c6d2db721b..85cac5912ac 100644 --- a/dlls/dmsynth/Makefile.in +++ b/dlls/dmsynth/Makefile.in @@ -1,6 +1,7 @@ MODULE = dmsynth.dll IMPORTS = $(FLUIDSYNTH_PE_LIBS) dxguid uuid ole32 advapi32 user32 EXTRAINCL = $(FLUIDSYNTH_PE_CFLAGS) +PARENTSRC = ../dmusic
C_SRCS = \ dmsynth_main.c \ diff --git a/dlls/dmsynth/synth.c b/dlls/dmsynth/synth.c index 5c1bb4eeb15..2e9b6b48245 100644 --- a/dlls/dmsynth/synth.c +++ b/dlls/dmsynth/synth.c @@ -25,6 +25,7 @@ #include "dmksctrl.h"
#include "dmsynth_private.h" +#include "dmusic_midi.h" #include "dls2.h"
#include <fluidsynth.h> @@ -1063,16 +1064,16 @@ static HRESULT WINAPI synth_Render(IDirectMusicSynth8 *iface, short *buffer,
switch (status) { - case 0x80: + case MIDI_NOTE_OFF: fluid_synth_noteoff(This->fluid_synth, chan, event->midi[1]); break; - case 0x90: + case MIDI_NOTE_ON: fluid_synth_noteon(This->fluid_synth, chan, event->midi[1], event->midi[2]); break; - case 0xb0: + case MIDI_CONTROL_CHANGE: fluid_synth_cc(This->fluid_synth, chan, event->midi[1], event->midi[2]); break; - case 0xc0: + case MIDI_PROGRAM_CHANGE: fluid_synth_program_change(This->fluid_synth, chan, event->midi[1]); break; default: diff --git a/dlls/dmusic/dmusic_midi.h b/dlls/dmusic/dmusic_midi.h new file mode 100644 index 00000000000..e545bcaf8cb --- /dev/null +++ b/dlls/dmusic/dmusic_midi.h @@ -0,0 +1,40 @@ +/* + * Copyright 2023 Rémi Bernon for CodeWeavers + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "stdarg.h" +#include "stddef.h" + +#include "windef.h" +#include "winbase.h" + +enum midi_message +{ + MIDI_NOTE_OFF = 0x80, + MIDI_NOTE_ON = 0x90, + MIDI_KEY_PRESSURE = 0xa0, + MIDI_CONTROL_CHANGE = 0xb0, + MIDI_PROGRAM_CHANGE = 0xc0, + MIDI_CHANNEL_PRESSURE = 0xd0, + MIDI_PITCH_BEND_CHANGE = 0xe0, +}; + +enum midi_control +{ + MIDI_CC_BANK_MSB = 0x00, + MIDI_CC_BANK_LSB = 0x20, +};