Skip to content

Commit

Permalink
Merge pull request #539 from microsoft/pete-dev
Browse files Browse the repository at this point in the history
More work on naming
  • Loading branch information
Psychlist1972 authored Feb 13, 2025
2 parents d4a3566 + a6f617a commit 3c84fc2
Show file tree
Hide file tree
Showing 31 changed files with 363 additions and 134 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.250211-2313" ?>
<?define SetupVersionNumber="1.0.3-preview-11.250213-52" ?>
</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.250211-2313";
public const string BuildFullVersion = "1.0.3-preview-11.250213-52";
public const string VersionMajor = "1";
public const string VersionMinor = "0";
public const string VersionRevision = "3";
public const string VersionDateNumber = "250211";
public const string VersionTimeNumber = "2313";
public const string VersionDateNumber = "250213";
public const string VersionTimeNumber = "52";
}
}

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.250211-2313"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_FULL L"1.0.3-preview-11.250213-52"
#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"250211"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_TIME_NUMBER L"2313"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_DATE_NUMBER L"250213"
#define WINDOWS_MIDI_SERVICES_BUILD_VERSION_TIME_NUMBER L"52"

#endif

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.250211-2313</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250213-52</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.250211-2313" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250213-52" 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.250211-2313</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250213-52</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.250211-2313" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250213-52" 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.250211-2313" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250213-52" 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.250211-2313</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250213-52</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.250211-2313" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250213-52" 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.250211-2313</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250213-52</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.250211-2313" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250213-52" 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.250211-2313</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250213-52</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.250211-2313" targetFramework="native" />
<package id="Microsoft.Windows.Devices.Midi2" version="1.0.3-preview-11.250213-52" 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.250211-2313</WindowsMidiServicesSdkPackage>
<WindowsMidiServicesSdkPackage>Microsoft.Windows.Devices.Midi2.1.0.3-preview-11.250213-52</WindowsMidiServicesSdkPackage>
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
Expand Down
147 changes: 134 additions & 13 deletions src/api/Inc/midi_naming.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,51 +68,170 @@ namespace WindowsMidiServicesInternal::Midi1PortNaming
}


inline std::wstring GenerateMidi1PortNameFromCreatedUmpEndpoint(
_In_ bool const useOldStyleNamingForNonUmpDevice, // 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& customPortName, // 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& blockName, // group terminal block or function block
_In_ std::wstring const& parentDeviceName, // the name of the actual connected device from which the UMP interface is generated
_In_ std::wstring const& deviceManufacturerName, // manufacturer name, if we have it
_In_ std::wstring const& transportSuppliedEndpointName, // the name of the parent endpoint as provided by the transport
_In_ std::wstring const& customParentEndpointName, // if the user has supplied a name for the generated port, and we're not using old-style naming, this wins
_In_ bool const forceUseExactBlockName, // true for transports that already put the appropriate name in the GTB, like the KSA transport
_In_ uint8_t const groupIndex,
_In_ MidiFlow const flowFromUserPerspective,
_In_ bool const isNativeUmpDevice,
_In_ bool const truncateToWinMMLimit
/*_In_ std::vector<std::wstring> const& otherExistingMidi1PortNamesForThisDeviceAndFlow*/
)
{
UNREFERENCED_PARAMETER(flowFromUserPerspective);
//UNREFERENCED_PARAMETER(otherExistingMidi1PortNamesForThisDeviceAndFlow);

// KSA transport pre-calculates the MIDI 1 port names based upon
// information from the USB device, which is not necessarily available
// at the time this function is called. So when using that transport's
// devices, we flag to just use the gtb name as it is.
if (forceUseExactBlockName && !blockName.empty())
{
return truncateToWinMMLimit ? blockName.substr(0, MAXPNAMELEN - 1) : blockName;
}

// user supplied a port name, so it is what we prefer
// if we're using old-style naming, we do not use
// any user-supplied information for the name
if (!customPortName.empty() && !useOldStyleNamingForNonUmpDevice)
{
return truncateToWinMMLimit ? customPortName.substr(0, MAXPNAMELEN - 1) : customPortName;
}


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

std::wstring suffix{};

if (!blockName.empty())
{
suffix = blockName;
}
else
{
// a winmm port can only represent a single group
suffix = L":" + std::to_wstring(groupIndex + 1);
}


if (!customParentEndpointName.empty())
{
name = customParentEndpointName;
}
else if (!transportSuppliedEndpointName.empty())
{
name = transportSuppliedEndpointName;
}
else if (!parentDeviceName.empty())
{
name = parentDeviceName;
}
else if (!deviceManufacturerName.empty())
{
name = deviceManufacturerName;
}

if (truncateToWinMMLimit)
{
if (name.length() + suffix.length() >= MAXPNAMELEN)
{
// -1 for null, -1 again for the space between words
name = name.substr(0, MAXPNAMELEN - 1 - suffix.length() - 1);
}
}

return name + L" " + suffix;
}


if (useOldStyleNamingForNonUmpDevice)
{
// TODO: Find the old naming code in the source tree, and reimplement it here

std::wstring name;

// TEMPORARY code
name = transportSuppliedEndpointName;


return truncateToWinMMLimit ? name.substr(0, MAXPNAMELEN - 1) : name;
}
else
{

std::wstring name;

// TEMPORARY code

name = parentDeviceName;


return truncateToWinMMLimit ? name.substr(0, MAXPNAMELEN - 1) : name;
}


return L"No name available";
}


// 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(
inline std::wstring GenerateGtbNameFromMidi1Device(
_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& customPortName, // 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& ksDriverSuppliedDeviceName, // the name the driver stored in the registry for the device
_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& deviceManufacturerName, // manufacturer name, if we have it
_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(deviceManufacturerName);
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
// user supplied a port name, so it is what we prefer
// if we're using old-style naming, we do not use
// any user-supplied information for the name
if (!userSuppliedPortName.empty() && !useOldStyleNaming)
if (!customPortName.empty() && !useOldStyleNaming)
{
return userSuppliedPortName;
return truncateToWinMMLimit ? customPortName.substr(0, MAXPNAMELEN - 1) : customPortName;
}


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

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

if (!ksDriverSuppliedDeviceName.empty())
{
name = truncateToWinMMLimit ? ksDriverSuppliedDeviceName.substr(0, MAXPNAMELEN - 1) : ksDriverSuppliedDeviceName;
}
else if (!filterName.empty())
{
name = truncateToWinMMLimit ? filterName.substr(0, MAXPNAMELEN - 1) : filterName;
}

//auto cleanPinName = CleanupKSPinName(pinName, parentDeviceName, filterName);

return name;
return truncateToWinMMLimit ? name.substr(0, MAXPNAMELEN - 1) : name;
}
else
{
Expand Down Expand Up @@ -146,6 +265,8 @@ namespace WindowsMidiServicesInternal::Midi1PortNaming
return name;
}


return L"No name available";
}

}
Expand Down
Loading

0 comments on commit 3c84fc2

Please sign in to comment.