From 9b4a9a435ebc4ec9e98de6f16b045de729fbccf8 Mon Sep 17 00:00:00 2001 From: Nytra <14206961+Nytra@users.noreply.github.com> Date: Fri, 26 Sep 2025 13:45:54 +0100 Subject: [PATCH 1/3] Don't remove port number from end of port name --- RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs b/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs index 8c91ca4..262be3c 100644 --- a/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs +++ b/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs @@ -7,11 +7,7 @@ internal class RtMidiDeviceInfo internal RtMidiDeviceInfo(uint port, string name) { Port = port; - - // RtMidi may add port number to end of name to ensure uniqueness - Name = name.EndsWith(port.ToString()) - ? name.Substring(0, name.LastIndexOf(port.ToString(), StringComparison.Ordinal)) - : name; + Name = name; } public uint Port { get; } From 8e11bb14640909e378bcb1dbe9d9e8af553a7cb8 Mon Sep 17 00:00:00 2001 From: Nytra <14206961+Nytra@users.noreply.github.com> Date: Fri, 26 Sep 2025 14:35:30 +0100 Subject: [PATCH 2/3] Only remove the port number on Windows and remove the extra space at the end too --- .../Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs b/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs index 262be3c..39be622 100644 --- a/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs +++ b/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; namespace RtMidi.Core.Unmanaged.Devices.Infos { @@ -7,7 +8,14 @@ internal class RtMidiDeviceInfo internal RtMidiDeviceInfo(uint port, string name) { Port = port; - Name = name; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + Name = name.EndsWith(port.ToString()) + ? name.Substring(0, name.LastIndexOf(port.ToString(), StringComparison.Ordinal) - 1) + : name; + } + else { Name = name; } } public uint Port { get; } From d0121357242a3f6196d59ebee93041f1d863d23f Mon Sep 17 00:00:00 2001 From: Nytra <14206961+Nytra@users.noreply.github.com> Date: Fri, 26 Sep 2025 14:37:54 +0100 Subject: [PATCH 3/3] Add comment back --- RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs b/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs index 39be622..aacaa25 100644 --- a/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs +++ b/RtMidi.Core/Unmanaged/Devices/Infos/RtMidiDeviceInfo.cs @@ -9,6 +9,7 @@ internal RtMidiDeviceInfo(uint port, string name) { Port = port; + // RtMidi may add port number to end of name on Windows to ensure uniqueness if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Name = name.EndsWith(port.ToString())