Skip to content

Commit

Permalink
Merge pull request #535 from microsoft/pete-dev
Browse files Browse the repository at this point in the history
Sync to main
  • Loading branch information
Psychlist1972 authored Feb 12, 2025
2 parents 6183d93 + 5e79508 commit 1a059ec
Show file tree
Hide file tree
Showing 52 changed files with 2,203 additions and 117 deletions.
2 changes: 1 addition & 1 deletion build/staging/version/BundleInfo.wxi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Include>
<?define SetupVersionName="Customer Preview 2 Arm64" ?>
<?define SetupVersionNumber="1.0.3-preview-11.250209-429" ?>
<?define SetupVersionNumber="1.0.3-preview-11.250211-2313" ?>
</Include>
6 changes: 3 additions & 3 deletions build/staging/version/WindowsMidiServicesVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ public static class MidiBuildInformation
{
public const string Source = "GitHub Preview";
public const string Name = "Customer Preview 2";
public const string BuildFullVersion = "1.0.3-preview-11.250209-429";
public const string BuildFullVersion = "1.0.3-preview-11.250211-2313";
public const string VersionMajor = "1";
public const string VersionMinor = "0";
public const string VersionRevision = "3";
public const string VersionDateNumber = "250209";
public const string VersionTimeNumber = "429";
public const string VersionDateNumber = "250211";
public const string VersionTimeNumber = "2313";
}
}

6 changes: 3 additions & 3 deletions build/staging/version/WindowsMidiServicesVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#define WINDOWS_MIDI_SERVICES_BUILD_SOURCE L"GitHub Preview"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_NAME L"Customer Preview 2"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_FULL L"1.0.3-preview-11.250209-429"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_FULL L"1.0.3-preview-11.250211-2313"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_MAJOR L"1"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_MINOR L"0"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_REVISION L"3"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_DATE_NUMBER L"250209"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_TIME_NUMBER L"429"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_DATE_NUMBER L"250211"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_TIME_NUMBER L"2313"

#endif

3 changes: 2 additions & 1 deletion docs/sdk-winrt-core/common/MidiGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ The `MidiGroup` class is used to provide formatting and data validation for MIDI

## Constructors

| `MidiGroup(UInt8)` | Create a MidiGroup with the specified group Index (0-15) |
| `MidiGroup()` | Create a MidiGroup initialized with group Index 0 |
| `MidiGroup(UInt8)` | Create a MidiGroup with the specified group Index (0-15). C++ note: C++/WinRT creates a constructor which takes nullptr, as a result `MidiGroup(0)` will fail to compile if you have the compiler option set to equate 0 and nullptr. To avoid this, use `MidiGroup(static_cast<uint8_t>(0))` or simply `MidiGroup()` |

## Properties

Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/basics/client-basics-cpp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250209-429</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250211-2313</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>false</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/basics/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250209-429" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250211-2313" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250209-429</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250211-2313</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/loopback-endpoints/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250209-429" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250211-2313" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion samples/cpp-winrt/send-speed/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250209-429" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250211-2313" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion samples/cpp-winrt/send-speed/send-speed-cpp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250209-429</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250211-2313</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/simple-app-to-app-midi/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250209-429" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250211-2313" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250209-429</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250211-2313</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/static-enum-endpoints/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250209-429" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250211-2313" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250209-429</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250211-2313</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp-winrt/watch-endpoints/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250209-429" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250211-2313" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250209-429</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250211-2313</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
21 changes: 19 additions & 2 deletions src/api/Inc/MidiDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,22 @@ static_assert( MAXIMUM_LOOPED_BUFFER_SIZE < ULONG_MAX/2, "The maximum looped
#define MIDI_USE_MMCSS_REG_VALUE L"UseMMCSS"
#define MIDI_USE_MMCSS_REG_DEFAULT_VALUE 0x00000000

// this is used as the default approach for how we name MIDI 1 ports
// individual ports can override this via a property in the list below.
#define MIDI_USE_OLD_MIDI1PORT_NAMING_DEFAULT_REG_VALUE L"DefaultToOldMidi1PortNaming"
#define MIDI_USE_OLD_MIDI1PORT_NAMING_DEFAULT_VALUE 0x00000001

#define MIDI_CONFIG_FILE_REG_VALUE L"CurrentConfig"

// if value > 0, then endpoint discovery and protocol negotiation are enabled
// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows MIDI Services\Midi2DiscoveryEnabled (DWORD)
#define MIDI_DISCOVERY_ENABLED_REG_VALUE L"Midi2DiscoveryEnabled"
#define MIDI_DISCOVERY_ENABLED_REG_DEFAULT_VALUE 0x00000001

// this is the amount of time we allocate to discovery across all native UMP format MIDI 2 devices
#define MIDI_DISCOVERY_TIMEOUT_REG_VALUE L"Midi2DiscoveryTimeoutMS"
#define MIDI_DISCOVERY_TIMEOUT_DEFAULT_VALUE 10000
#define MIDI_DISCOVERY_TIMEOUT_MINIMUM_VALUE 1000
#define MIDI_DISCOVERY_TIMEOUT_MINIMUM_VALUE 500
#define MIDI_DISCOVERY_TIMEOUT_MAXIMUM_VALUE 50000


Expand Down Expand Up @@ -639,7 +645,18 @@ DEFINE_MIDIDEVPROPKEY(PKEY_MIDI_VirtualMidiEndpointAssociator, 900); // DEVP



// Structures for properties ================================================================
// MIDI 1.0 Port Naming Properties ==========================================================
// Starts at 1000

// this property is used on the parent UMP interface to control all generated MIDI 1 ports
#define STRING_PKEY_MIDI_UseOldMidi1PortNamingScheme MIDI_STRING_PKEY_GUID MIDI_STRING_PKEY_PID_SEPARATOR L"1000"
DEFINE_MIDIDEVPROPKEY(PKEY_MIDI_UseOldMidi1PortNamingScheme, 1000); // DEVPROP_TYPE_BOOL





// Structures for properties =================================================================



Expand Down
153 changes: 153 additions & 0 deletions src/api/Inc/midi_naming.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License
// ============================================================================
// This is part of the Windows MIDI Services App API and should be used
// in your Windows application via an official binary distribution.
// Further information: https://aka.ms/midi
// ============================================================================

#pragma once

#ifndef MIDI_NAMING_H
#define MIDI_NAMING_H

#include <string>
#include <vector>

namespace WindowsMidiServicesInternal::Midi1PortNaming
{
inline std::wstring CleanupKSPinName(
_In_ std::wstring const& pinName,
_In_ std::wstring parentDeviceName,
_In_ std::wstring filterName
)
{
std::wstring cleanedPinName{};

// Used by ESI, MOTU, and others. We don't want to mess up other names, so check only
// for whole word. We do other removal in the next step
if (pinName == L"MIDI" ||
pinName == L"Out" || pinName == L"OUT" || pinName == L"out" ||
pinName == L"In" || pinName == L"IN" || pinName == L"in"
)
{
cleanedPinName = L"";
}
else
{
cleanedPinName = pinName;
}

// the double and triple space entries need to be last
// there are other ways to do this with pattern matching,
// but just banging this through for this version
const std::wstring wordsToRemove[] =
{
// many of these are added by our USB and KS stack, not by the device, which is why they are here
parentDeviceName, filterName,
L"[0]", L"[1]", L"[2]", L"[3]", L"[4]", L"[5]", L"[6]", L"[7]", L"[8]", L"[9]", L"[10]", L"[11]", L"[12]", L"[13]", L"[14]", L"[15]", L"[16]",
L" ", L" ", L" "
};

for (auto const& word : wordsToRemove)
{
if (cleanedPinName.length() >= word.length())
{
auto idx = cleanedPinName.find(word);

if (idx != std::wstring::npos)
{
cleanedPinName = cleanedPinName.erase(idx, word.length());
}
}
}

internal::InPlaceTrim(cleanedPinName);

return cleanedPinName;
}


// This is used for generating the GTB names on KSA endpoints, for MIDI 1.0 devices. Those
// GTB names are used directly when creating WinMM endpoints
inline std::wstring GenerateMidi1PortName(
_In_ bool const useOldStyleNaming, // this comes from the property on the device, and if not specified, from the registry. Controls using old WinMM-style naming
_In_ std::wstring const& userSuppliedPortName, // if the user has supplied a name for the generated port, and we're not using old-style naming, this wins
_In_ std::wstring const& deviceContainerName, // oddly some old WinMM code picks up the deviceContainerName somehow
_In_ std::wstring const& parentDeviceName, // the name of the actual connected device from which the UMP interface is generated
_In_ std::wstring const& parentDeviceManufacturerName, // the name of the parent device
_In_ std::wstring const& filterName, // the name of the filter. This is sometimes the same as the parent device
_In_ std::wstring const& pinName, // the name of the KS Filter pin. This can be the same as the USB iJack
_In_ uint8_t const groupIndex,
_In_ MidiFlow const flowFromUserPerspective,
_In_ bool const isUmpDevice,
_In_ bool const isUsingVendorDriver,
_In_ bool const truncateToWinMMLimit,
_In_ std::vector<std::wstring> const& otherExistingMidi1PortNamesForThisDeviceAndFlow
)
{
UNREFERENCED_PARAMETER(deviceContainerName);
UNREFERENCED_PARAMETER(parentDeviceName);
UNREFERENCED_PARAMETER(parentDeviceManufacturerName);
UNREFERENCED_PARAMETER(groupIndex);
UNREFERENCED_PARAMETER(flowFromUserPerspective);
UNREFERENCED_PARAMETER(isUmpDevice);
UNREFERENCED_PARAMETER(isUsingVendorDriver);
UNREFERENCED_PARAMETER(otherExistingMidi1PortNamesForThisDeviceAndFlow);

// user supplied a port name, so it is what we use
// if we're using old-style naming, we do not use
// any user-supplied information for the name
if (!userSuppliedPortName.empty() && !useOldStyleNaming)
{
return userSuppliedPortName;
}


if (useOldStyleNaming)
{
std::wstring name{};

// TODO: Find the old naming code in the source tree, and reimplement



return name;
}
else
{
std::wstring name{};

auto cleanedPinName = CleanupKSPinName(pinName, parentDeviceName, filterName);

name = internal::TrimmedWStringCopy(filterName + L" " + internal::TrimmedWStringCopy(cleanedPinName));

if (truncateToWinMMLimit)
{
if (name.length() + 1 > MAXPNAMELEN)
{
if (!cleanedPinName.empty())
{
// we're over length, so just use the pin name
name = cleanedPinName.substr(0, MAXPNAMELEN - 1);
}
else
{
// we're over length, and there's no pin name
// so we use the filter name
name = filterName.substr(0, MAXPNAMELEN - 1);
}
}
}

// TODO: do we need to do any port differentiators here? Look at the collection and see
// if there are already ports starting with the same name, and if so, increment a counter and append

return name;
}

}

}

#endif
1 change: 1 addition & 0 deletions src/api/Midi2.sln
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{A4512D
Inc\loopback_ids.h = Inc\loopback_ids.h
Inc\MidiDefs.h = Inc\MidiDefs.h
Inc\midi_group_terminal_blocks.h = Inc\midi_group_terminal_blocks.h
Inc\midi_naming.h = Inc\midi_naming.h
Inc\midi_timestamp.h = Inc\midi_timestamp.h
Inc\midi_ump.h = Inc\midi_ump.h
Inc\midi_ump_message_defs.h = Inc\midi_ump_message_defs.h
Expand Down
Loading

0 comments on commit 1a059ec

Please sign in to comment.