From 5f4454481e223d5af1ffeeae97e8381b4659d3c3 Mon Sep 17 00:00:00 2001 From: Pete Brown Date: Sat, 1 Jul 2023 15:13:13 -0400 Subject: [PATCH 1/6] Backed out strongly-typed collections --- .../Microsoft.Devices.Midi2.Core.vcxproj | 66 +------------------ src/app-dev-sdk/sdk-core/MidiChannelList.idl | 23 ------- .../sdk-core/MidiDeviceInformation.cpp | 2 +- .../sdk-core/MidiDeviceInformation.h | 2 +- .../sdk-core/MidiDeviceInformation.idl | 4 +- .../sdk-core/MidiDeviceInformationList.cpp | 8 --- .../sdk-core/MidiDeviceInformationList.h | 19 ------ .../sdk-core/MidiDeviceInformationList.idl | 23 ------- .../sdk-core/MidiEndpointConnection.cpp | 2 +- .../sdk-core/MidiEndpointConnection.h | 2 +- .../sdk-core/MidiEndpointConnection.idl | 3 +- .../sdk-core/MidiEndpointConnectionList.cpp | 8 --- .../sdk-core/MidiEndpointConnectionList.h | 19 ------ .../sdk-core/MidiEndpointConnectionList.idl | 23 ------- .../sdk-core/MidiEndpointDisplayFormatter.cpp | 4 +- .../sdk-core/MidiEndpointDisplayFormatter.h | 4 +- .../sdk-core/MidiEndpointDisplayFormatter.idl | 5 +- .../sdk-core/MidiFunctionBlock.cpp | 4 +- src/app-dev-sdk/sdk-core/MidiFunctionBlock.h | 4 +- .../sdk-core/MidiFunctionBlock.idl | 6 +- .../sdk-core/MidiFunctionBlockList.cpp | 8 --- .../sdk-core/MidiFunctionBlockList.h | 19 ------ .../sdk-core/MidiFunctionBlockList.idl | 24 ------- src/app-dev-sdk/sdk-core/MidiGroupList.cpp | 8 --- src/app-dev-sdk/sdk-core/MidiGroupList.h | 19 ------ .../sdk-core/MidiGroupTerminalBlock.cpp | 2 +- .../sdk-core/MidiGroupTerminalBlock.h | 2 +- .../sdk-core/MidiGroupTerminalBlock.idl | 3 +- .../sdk-core/MidiGroupTerminalBlockList.cpp | 8 --- .../sdk-core/MidiGroupTerminalBlockList.h | 19 ------ .../sdk-core/MidiGroupTerminalBlockList.idl | 24 ------- ...iChannelList.cpp => MidiInteropHelper.cpp} | 9 ++- ...{MidiChannelList.h => MidiInteropHelper.h} | 11 ++-- ...idiGroupList.idl => MidiInteropHelper.idl} | 16 ++--- src/app-dev-sdk/sdk-core/MidiListBase.cpp | 8 --- src/app-dev-sdk/sdk-core/MidiListBase.h | 12 ---- src/app-dev-sdk/sdk-core/MidiListBase.idl | 27 -------- .../sdk-core/MidiMessageReader.cpp | 2 +- src/app-dev-sdk/sdk-core/MidiMessageReader.h | 2 +- .../sdk-core/MidiMessageReader.idl | 3 +- .../sdk-core/MidiMessageWriter.cpp | 2 +- src/app-dev-sdk/sdk-core/MidiMessageWriter.h | 2 +- .../sdk-core/MidiMessageWriter.idl | 4 +- src/app-dev-sdk/sdk-core/MidiServices.cpp | 2 +- src/app-dev-sdk/sdk-core/MidiServices.h | 2 +- src/app-dev-sdk/sdk-core/MidiServices.idl | 3 +- src/app-dev-sdk/sdk-core/MidiSession.cpp | 4 +- src/app-dev-sdk/sdk-core/MidiSession.h | 2 +- src/app-dev-sdk/sdk-core/MidiSession.idl | 3 +- .../sdk-core/MidiTransportInformationList.cpp | 8 --- .../sdk-core/MidiTransportInformationList.h | 19 ------ .../sdk-core/MidiTransportInformationList.idl | 24 ------- .../sdk-core/MidiUmpWithTimestampList.cpp | 8 --- .../sdk-core/MidiUmpWithTimestampList.h | 19 ------ .../sdk-core/MidiUmpWithTimestampList.idl | 26 -------- 55 files changed, 59 insertions(+), 526 deletions(-) delete mode 100644 src/app-dev-sdk/sdk-core/MidiChannelList.idl delete mode 100644 src/app-dev-sdk/sdk-core/MidiDeviceInformationList.cpp delete mode 100644 src/app-dev-sdk/sdk-core/MidiDeviceInformationList.h delete mode 100644 src/app-dev-sdk/sdk-core/MidiDeviceInformationList.idl delete mode 100644 src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.cpp delete mode 100644 src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.h delete mode 100644 src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.idl delete mode 100644 src/app-dev-sdk/sdk-core/MidiFunctionBlockList.cpp delete mode 100644 src/app-dev-sdk/sdk-core/MidiFunctionBlockList.h delete mode 100644 src/app-dev-sdk/sdk-core/MidiFunctionBlockList.idl delete mode 100644 src/app-dev-sdk/sdk-core/MidiGroupList.cpp delete mode 100644 src/app-dev-sdk/sdk-core/MidiGroupList.h delete mode 100644 src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.cpp delete mode 100644 src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.h delete mode 100644 src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.idl rename src/app-dev-sdk/sdk-core/{MidiChannelList.cpp => MidiInteropHelper.cpp} (64%) rename src/app-dev-sdk/sdk-core/{MidiChannelList.h => MidiInteropHelper.h} (60%) rename src/app-dev-sdk/sdk-core/{MidiGroupList.idl => MidiInteropHelper.idl} (59%) delete mode 100644 src/app-dev-sdk/sdk-core/MidiListBase.cpp delete mode 100644 src/app-dev-sdk/sdk-core/MidiListBase.h delete mode 100644 src/app-dev-sdk/sdk-core/MidiListBase.idl delete mode 100644 src/app-dev-sdk/sdk-core/MidiTransportInformationList.cpp delete mode 100644 src/app-dev-sdk/sdk-core/MidiTransportInformationList.h delete mode 100644 src/app-dev-sdk/sdk-core/MidiTransportInformationList.idl delete mode 100644 src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.cpp delete mode 100644 src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.h delete mode 100644 src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.idl diff --git a/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj b/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj index 0a1577dcd..9ffc9afc3 100644 --- a/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj +++ b/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj @@ -158,39 +158,13 @@ - - MidiChannelList.idl - - - MidiDeviceInformationList.idl - - - MidiEndpointConnectionList.idl - - - MidiFunctionBlockList.idl - - - MidiGroupList.idl - - - MidiGroupTerminalBlockList.idl - MidiEndpointDisplayFormatter.idl MidiHighResolutionValueDisplayFormatter.idl - - MidiListBase.idl - - - MidiTransportInformationList.idl - - - MidiUmpWithTimestampList.idl - + MidiLocalizedStrings.idl @@ -256,39 +230,13 @@ - - MidiChannelList.idl - - - MidiDeviceInformationList.idl - - - MidiEndpointConnectionList.idl - - - MidiGroupList.idl - - - MidiTransportInformationList.idl - - - MidiUmpWithTimestampList.idl - - - MidiFunctionBlockList.idl - - - MidiGroupTerminalBlockList.idl - - - MidiListBase.idl - MidiEndpointDisplayFormatter.idl MidiHighResolutionValueDisplayFormatter.idl + MidiLocalizedStrings.idl @@ -356,17 +304,11 @@ - - - - - - - + @@ -385,13 +327,11 @@ - - diff --git a/src/app-dev-sdk/sdk-core/MidiChannelList.idl b/src/app-dev-sdk/sdk-core/MidiChannelList.idl deleted file mode 100644 index 6fc79ddfe..000000000 --- a/src/app-dev-sdk/sdk-core/MidiChannelList.idl +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License -// ============================================================================ -// This is part of the Windows MIDI Services App SDK and should be used -// in your Windows application via an official binary distribution. -// Further information: https://github.com/microsoft/MIDI/ -// ============================================================================ - -// The various list implementations are here because some languages (like Delphi/Pascal) -// have no automatic projection support, and can't reasonably handle any class with -// templates / generics. -// The IDL is a placeholder for now - -import "MidiListBase.idl"; - -namespace Microsoft.Devices.Midi2 -{ - [default_interface] - runtimeclass MidiChannelList : MidiListBase - { - MidiChannelList(); - } -} \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core/MidiDeviceInformation.cpp b/src/app-dev-sdk/sdk-core/MidiDeviceInformation.cpp index 49736b09a..d26e04908 100644 --- a/src/app-dev-sdk/sdk-core/MidiDeviceInformation.cpp +++ b/src/app-dev-sdk/sdk-core/MidiDeviceInformation.cpp @@ -57,7 +57,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { throw hresult_not_implemented(); } - winrt::Microsoft::Devices::Midi2::MidiGroupTerminalBlockList MidiDeviceInformation::GroupTerminalBlocks() + winrt::Windows::Foundation::Collections::IVectorView MidiDeviceInformation::GroupTerminalBlocks() { throw hresult_not_implemented(); } diff --git a/src/app-dev-sdk/sdk-core/MidiDeviceInformation.h b/src/app-dev-sdk/sdk-core/MidiDeviceInformation.h index 7c028829a..4b61467ee 100644 --- a/src/app-dev-sdk/sdk-core/MidiDeviceInformation.h +++ b/src/app-dev-sdk/sdk-core/MidiDeviceInformation.h @@ -27,7 +27,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation hstring UniqueIdentifier(); winrt::Microsoft::Devices::Midi2::MidiEndpointDataFormat EndpointDataFormat(); bool HasGroupTerminalBlocks(); - winrt::Microsoft::Devices::Midi2::MidiGroupTerminalBlockList GroupTerminalBlocks(); + winrt::Windows::Foundation::Collections::IVectorView GroupTerminalBlocks(); winrt::Windows::Devices::Enumeration::DeviceThumbnail DeviceThumbnail(); }; } diff --git a/src/app-dev-sdk/sdk-core/MidiDeviceInformation.idl b/src/app-dev-sdk/sdk-core/MidiDeviceInformation.idl index 2c1e47fd1..c0e675798 100644 --- a/src/app-dev-sdk/sdk-core/MidiDeviceInformation.idl +++ b/src/app-dev-sdk/sdk-core/MidiDeviceInformation.idl @@ -15,7 +15,6 @@ import "MidiGroupTerminalBlock.idl"; import "MidiEndpointDataFormatEnum.idl"; -import "MidiGroupTerminalBlockList.idl"; namespace Microsoft.Devices.Midi2 { @@ -47,8 +46,7 @@ namespace Microsoft.Devices.Midi2 MidiEndpointDataFormat EndpointDataFormat{ get; }; Boolean HasGroupTerminalBlocks{ get; }; - //IVectorGroupTerminalBlocks{ get; }; // these are USB-specific, created at enumeration time, and do not change - MidiGroupTerminalBlockList GroupTerminalBlocks{ get; }; // these are USB-specific, created at enumeration time, and do not change + IVectorView GroupTerminalBlocks{ get; }; // these are USB-specific, created at enumeration time, and do not change Windows.Devices.Enumeration.DeviceThumbnail DeviceThumbnail{ get; }; diff --git a/src/app-dev-sdk/sdk-core/MidiDeviceInformationList.cpp b/src/app-dev-sdk/sdk-core/MidiDeviceInformationList.cpp deleted file mode 100644 index e056287e2..000000000 --- a/src/app-dev-sdk/sdk-core/MidiDeviceInformationList.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "pch.h" -#include "MidiDeviceInformationList.h" -#include "MidiDeviceInformationList.g.cpp" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ -} diff --git a/src/app-dev-sdk/sdk-core/MidiDeviceInformationList.h b/src/app-dev-sdk/sdk-core/MidiDeviceInformationList.h deleted file mode 100644 index 011e1bb59..000000000 --- a/src/app-dev-sdk/sdk-core/MidiDeviceInformationList.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "MidiDeviceInformationList.g.h" -#include "MidiListBase.h" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ - struct MidiDeviceInformationList : MidiDeviceInformationListT - { - MidiDeviceInformationList() = default; - - }; -} -namespace winrt::Microsoft::Devices::Midi2::factory_implementation -{ - struct MidiDeviceInformationList : MidiDeviceInformationListT - { - }; -} diff --git a/src/app-dev-sdk/sdk-core/MidiDeviceInformationList.idl b/src/app-dev-sdk/sdk-core/MidiDeviceInformationList.idl deleted file mode 100644 index 2000f8d89..000000000 --- a/src/app-dev-sdk/sdk-core/MidiDeviceInformationList.idl +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License -// ============================================================================ -// This is part of the Windows MIDI Services App SDK and should be used -// in your Windows application via an official binary distribution. -// Further information: https://github.com/microsoft/MIDI/ -// ============================================================================ - -// The various list implementations are here because some languages (like Delphi/Pascal) -// have no automatic projection support, and can't reasonably handle any class with -// templates / generics. -// The IDL is a placeholder for now - -import "MidiListBase.idl"; - -namespace Microsoft.Devices.Midi2 -{ - [default_interface] - runtimeclass MidiDeviceInformationList : MidiListBase - { - MidiDeviceInformationList(); - } -} \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core/MidiEndpointConnection.cpp b/src/app-dev-sdk/sdk-core/MidiEndpointConnection.cpp index a8d9405f1..7d8e6a3e0 100644 --- a/src/app-dev-sdk/sdk-core/MidiEndpointConnection.cpp +++ b/src/app-dev-sdk/sdk-core/MidiEndpointConnection.cpp @@ -32,7 +32,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { throw hresult_not_implemented(); } - winrt::Microsoft::Devices::Midi2::MidiFunctionBlockList MidiEndpointConnection::FunctionBlocks() + winrt::Windows::Foundation::Collections::IVectorView MidiEndpointConnection::FunctionBlocks() { throw hresult_not_implemented(); } diff --git a/src/app-dev-sdk/sdk-core/MidiEndpointConnection.h b/src/app-dev-sdk/sdk-core/MidiEndpointConnection.h index 5eb227b37..21c9f7e8d 100644 --- a/src/app-dev-sdk/sdk-core/MidiEndpointConnection.h +++ b/src/app-dev-sdk/sdk-core/MidiEndpointConnection.h @@ -20,7 +20,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation hstring DeviceId(); bool EndpointInformationValid(); winrt::Microsoft::Devices::Midi2::MidiEndpointInformation EndpointInformation(); - winrt::Microsoft::Devices::Midi2::MidiFunctionBlockList FunctionBlocks(); + winrt::Windows::Foundation::Collections::IVectorView FunctionBlocks(); void RequestEndpointInformationAndFunctions(bool forceRefresh); winrt::Windows::Foundation::IAsyncAction RequestEndpointInformationAndFunctionsAsync(bool forceRefresh); winrt::Microsoft::Devices::Midi2::MidiMessageReader GetMessageReader(); diff --git a/src/app-dev-sdk/sdk-core/MidiEndpointConnection.idl b/src/app-dev-sdk/sdk-core/MidiEndpointConnection.idl index 8ec653175..435644fbe 100644 --- a/src/app-dev-sdk/sdk-core/MidiEndpointConnection.idl +++ b/src/app-dev-sdk/sdk-core/MidiEndpointConnection.idl @@ -17,7 +17,6 @@ import "MidiUmpWithTimestamp.idl"; import "MidiMessagesReceivedEventArgs.idl"; import "MidiMessageReader.idl"; import "MidiMessageWriter.idl"; -import "MidiFunctionBlockList.idl"; namespace Microsoft.Devices.Midi2 { @@ -46,7 +45,7 @@ namespace Microsoft.Devices.Midi2 MidiEndpointInformation EndpointInformation{ get; }; // information from Endpoint Info request. Not valid until EndpointInformation requested and received. // Blocks which tell us how to treat the groups - MidiFunctionBlockList FunctionBlocks { get; }; // these are discovered in-protocol. They can change within the rules in the spec + IVectorView FunctionBlocks { get; }; // these are discovered in-protocol. They can change within the rules in the spec // call this if you have your own worker thread. It's a long-running operation diff --git a/src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.cpp b/src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.cpp deleted file mode 100644 index cde03911b..000000000 --- a/src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "pch.h" -#include "MidiEndpointConnectionList.h" -#include "MidiEndpointConnectionList.g.cpp" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ -} diff --git a/src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.h b/src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.h deleted file mode 100644 index f8424e5e4..000000000 --- a/src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "MidiEndpointConnectionList.g.h" -#include "MidiListBase.h" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ - struct MidiEndpointConnectionList : MidiEndpointConnectionListT - { - MidiEndpointConnectionList() = default; - - }; -} -namespace winrt::Microsoft::Devices::Midi2::factory_implementation -{ - struct MidiEndpointConnectionList : MidiEndpointConnectionListT - { - }; -} diff --git a/src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.idl b/src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.idl deleted file mode 100644 index ac3787af4..000000000 --- a/src/app-dev-sdk/sdk-core/MidiEndpointConnectionList.idl +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License -// ============================================================================ -// This is part of the Windows MIDI Services App SDK and should be used -// in your Windows application via an official binary distribution. -// Further information: https://github.com/microsoft/MIDI/ -// ============================================================================ - -// The various list implementations are here because some languages (like Delphi/Pascal) -// have no automatic projection support, and can't reasonably handle any class with -// templates / generics. -// The IDL is a placeholder for now - -import "MidiListBase.idl"; - -namespace Microsoft.Devices.Midi2 -{ - [default_interface] - runtimeclass MidiEndpointConnectionList : MidiListBase - { - MidiEndpointConnectionList(); - } -} \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.cpp b/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.cpp index 10fb45528..6a48fb29f 100644 --- a/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.cpp +++ b/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.cpp @@ -12,11 +12,11 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { - hstring MidiEndpointDisplayFormatter::FormatGroupWithFunctionBlocks(winrt::Microsoft::Devices::Midi2::MidiGroup const& group, winrt::Microsoft::Devices::Midi2::MidiFunctionBlockList const& blocks, bool abbreviatedVersion) + hstring MidiEndpointDisplayFormatter::FormatGroupWithFunctionBlocks(winrt::Microsoft::Devices::Midi2::MidiGroup const& group, winrt::Windows::Foundation::Collections::IVector const&, bool abbreviatedVersion) { throw hresult_not_implemented(); } - hstring MidiEndpointDisplayFormatter::FormatAllGroupOptionWithFunctionBlocks(winrt::Microsoft::Devices::Midi2::MidiFunctionBlockList const& blocks, bool abbreviatedVersion) + hstring MidiEndpointDisplayFormatter::FormatAllGroupOptionWithFunctionBlocks(winrt::Windows::Foundation::Collections::IVector const&, bool abbreviatedVersion) { throw hresult_not_implemented(); } diff --git a/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.h b/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.h index b93c7447b..625dae6f1 100644 --- a/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.h +++ b/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.h @@ -16,8 +16,8 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { MidiEndpointDisplayFormatter() = default; - static hstring FormatGroupWithFunctionBlocks(winrt::Microsoft::Devices::Midi2::MidiGroup const& group, winrt::Microsoft::Devices::Midi2::MidiFunctionBlockList const& blocks, bool abbreviatedVersion); - static hstring FormatAllGroupOptionWithFunctionBlocks(winrt::Microsoft::Devices::Midi2::MidiFunctionBlockList const& blocks, bool abbreviatedVersion); + static hstring FormatGroupWithFunctionBlocks(winrt::Microsoft::Devices::Midi2::MidiGroup const& group, winrt::Windows::Foundation::Collections::IVector const&, bool abbreviatedVersion); + static hstring FormatAllGroupOptionWithFunctionBlocks(winrt::Windows::Foundation::Collections::IVector const& blocks, bool abbreviatedVersion); static hstring FormatChannel(winrt::Microsoft::Devices::Midi2::MidiChannel const& channel, bool abbreviatedVersion); }; } diff --git a/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.idl b/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.idl index 22e73acb4..b4058ef23 100644 --- a/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.idl +++ b/src/app-dev-sdk/sdk-core/MidiEndpointDisplayFormatter.idl @@ -10,7 +10,6 @@ import "MidiFunctionBlock.idl"; import "MidiChannel.idl"; import "MidiGroup.idl"; -import "MidiFunctionBlockList.idl"; namespace Microsoft.Devices.Midi2 { @@ -24,12 +23,12 @@ namespace Microsoft.Devices.Midi2 // and then makes the right decisions? static String FormatGroupWithFunctionBlocks( MidiGroup group, - MidiFunctionBlockList blocks, + IVector blocks, Boolean abbreviatedVersion); // returns the "All Groups (FB name, FB name, FB name)" string static String FormatAllGroupOptionWithFunctionBlocks( - MidiFunctionBlockList blocks, + IVector blocks, Boolean abbreviatedVersion); diff --git a/src/app-dev-sdk/sdk-core/MidiFunctionBlock.cpp b/src/app-dev-sdk/sdk-core/MidiFunctionBlock.cpp index 368630757..f9d472542 100644 --- a/src/app-dev-sdk/sdk-core/MidiFunctionBlock.cpp +++ b/src/app-dev-sdk/sdk-core/MidiFunctionBlock.cpp @@ -37,11 +37,11 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { throw hresult_not_implemented(); } - winrt::Microsoft::Devices::Midi2::MidiGroupList MidiFunctionBlock::IncludedGroups() + winrt::Windows::Foundation::Collections::IVectorView MidiFunctionBlock::IncludedGroups() { throw hresult_not_implemented(); } - winrt::Microsoft::Devices::Midi2::MidiUmpWithTimestampList MidiFunctionBlock::OriginalResponses() + winrt::Windows::Foundation::Collections::IVectorView MidiFunctionBlock::OriginalResponses() { throw hresult_not_implemented(); } diff --git a/src/app-dev-sdk/sdk-core/MidiFunctionBlock.h b/src/app-dev-sdk/sdk-core/MidiFunctionBlock.h index 7b3c1a136..baed6fd8e 100644 --- a/src/app-dev-sdk/sdk-core/MidiFunctionBlock.h +++ b/src/app-dev-sdk/sdk-core/MidiFunctionBlock.h @@ -21,8 +21,8 @@ namespace winrt::Microsoft::Devices::Midi2::implementation winrt::Microsoft::Devices::Midi2::MidiFunctionBlockUIHint UIHint(); bool IsMidi10Connection(); bool IsBandwidthRestricted(); - winrt::Microsoft::Devices::Midi2::MidiGroupList IncludedGroups(); - winrt::Microsoft::Devices::Midi2::MidiUmpWithTimestampList OriginalResponses(); + winrt::Windows::Foundation::Collections::IVectorView IncludedGroups(); + winrt::Windows::Foundation::Collections::IVectorView OriginalResponses(); uint8_t MidiCIMessageVersionFormat(); uint8_t MaxSysEx8Streams(); }; diff --git a/src/app-dev-sdk/sdk-core/MidiFunctionBlock.idl b/src/app-dev-sdk/sdk-core/MidiFunctionBlock.idl index 4dea7893f..9bed62185 100644 --- a/src/app-dev-sdk/sdk-core/MidiFunctionBlock.idl +++ b/src/app-dev-sdk/sdk-core/MidiFunctionBlock.idl @@ -11,8 +11,6 @@ import "MidiFunctionBlockDirectionEnum.idl"; import "MidiFunctionBlockUIHintEnum.idl"; import "MidiUmpWithTimestamp.idl"; import "MidiGroup.idl"; -import "MidiGroupList.idl"; -import "MidiUmpWithTimestampList.idl"; namespace Microsoft.Devices.Midi2 { @@ -32,8 +30,8 @@ namespace Microsoft.Devices.Midi2 //IVector IncludedGroups{ get; }; //IVector OriginalResponses{ get; }; - MidiGroupList IncludedGroups{ get; }; - MidiUmpWithTimestampList OriginalResponses{ get; }; + IVectorView IncludedGroups{ get; }; + IVectorView OriginalResponses{ get; }; UInt8 MidiCIMessageVersionFormat{ get; }; diff --git a/src/app-dev-sdk/sdk-core/MidiFunctionBlockList.cpp b/src/app-dev-sdk/sdk-core/MidiFunctionBlockList.cpp deleted file mode 100644 index fc0619b09..000000000 --- a/src/app-dev-sdk/sdk-core/MidiFunctionBlockList.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "pch.h" -#include "MidiFunctionBlockList.h" -#include "MidiFunctionBlockList.g.cpp" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ -} diff --git a/src/app-dev-sdk/sdk-core/MidiFunctionBlockList.h b/src/app-dev-sdk/sdk-core/MidiFunctionBlockList.h deleted file mode 100644 index dcf8e0dc9..000000000 --- a/src/app-dev-sdk/sdk-core/MidiFunctionBlockList.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "MidiFunctionBlockList.g.h" -#include "MidiListBase.h" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ - struct MidiFunctionBlockList : MidiFunctionBlockListT - { - MidiFunctionBlockList() = default; - - }; -} -namespace winrt::Microsoft::Devices::Midi2::factory_implementation -{ - struct MidiFunctionBlockList : MidiFunctionBlockListT - { - }; -} diff --git a/src/app-dev-sdk/sdk-core/MidiFunctionBlockList.idl b/src/app-dev-sdk/sdk-core/MidiFunctionBlockList.idl deleted file mode 100644 index 3e6da0b62..000000000 --- a/src/app-dev-sdk/sdk-core/MidiFunctionBlockList.idl +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License -// ============================================================================ -// This is part of the Windows MIDI Services App SDK and should be used -// in your Windows application via an official binary distribution. -// Further information: https://github.com/microsoft/MIDI/ -// ============================================================================ - -// The various list implementations are here because some languages (like Delphi/Pascal) -// have no automatic projection support, and can't reasonably handle any class with -// templates / generics. -// The IDL is a placeholder for now - - -import "MidiListBase.idl"; - -namespace Microsoft.Devices.Midi2 -{ - [default_interface] - runtimeclass MidiFunctionBlockList : MidiListBase - { - MidiFunctionBlockList(); - } -} \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core/MidiGroupList.cpp b/src/app-dev-sdk/sdk-core/MidiGroupList.cpp deleted file mode 100644 index 8ac853229..000000000 --- a/src/app-dev-sdk/sdk-core/MidiGroupList.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "pch.h" -#include "MidiGroupList.h" -#include "MidiGroupList.g.cpp" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ -} diff --git a/src/app-dev-sdk/sdk-core/MidiGroupList.h b/src/app-dev-sdk/sdk-core/MidiGroupList.h deleted file mode 100644 index 5d42aebcf..000000000 --- a/src/app-dev-sdk/sdk-core/MidiGroupList.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "MidiGroupList.g.h" -#include "MidiListBase.h" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ - struct MidiGroupList : MidiGroupListT - { - MidiGroupList() = default; - - }; -} -namespace winrt::Microsoft::Devices::Midi2::factory_implementation -{ - struct MidiGroupList : MidiGroupListT - { - }; -} diff --git a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.cpp b/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.cpp index b3d5a1b29..dd7c465f1 100644 --- a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.cpp +++ b/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.cpp @@ -29,7 +29,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { throw hresult_not_implemented(); } - winrt::Microsoft::Devices::Midi2::MidiGroupList MidiGroupTerminalBlock::IncludedGroups() + winrt::Windows::Foundation::Collections::IVectorView MidiGroupTerminalBlock::IncludedGroups() { throw hresult_not_implemented(); } diff --git a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.h b/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.h index ab2c0463e..bb4b1bad8 100644 --- a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.h +++ b/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.h @@ -20,7 +20,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation hstring Name(); winrt::Microsoft::Devices::Midi2::MidiGroupTerminalBlockDirection Direction(); winrt::Microsoft::Devices::Midi2::MidiGroupTerminalBlockProtocol Protocol(); - winrt::Microsoft::Devices::Midi2::MidiGroupList IncludedGroups(); + winrt::Windows::Foundation::Collections::IVectorView IncludedGroups(); uint16_t MaxDeviceInputBandwidthIn4KBSecondUnits(); uint16_t MaxDeviceOutputBandwidthIn4KBSecondUnits(); }; diff --git a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.idl b/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.idl index 0c788ca88..efcdeb3ec 100644 --- a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.idl +++ b/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlock.idl @@ -12,7 +12,6 @@ // Blocks and Function Blocks import "MidiGroup.idl"; -import "MidiGroupList.idl"; namespace Microsoft.Devices.Midi2 { @@ -50,7 +49,7 @@ namespace Microsoft.Devices.Midi2 // rather than number of groups and a start group, we just have a vector of groups // here to make it flexible and to be consistent with what we do for function blocks - MidiGroupList IncludedGroups{ get; }; + IVectorView IncludedGroups{ get; }; // Note: 0x0000 is unknown or not fixed // 0x0001 is 31.24kb/s diff --git a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.cpp b/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.cpp deleted file mode 100644 index b24fad577..000000000 --- a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "pch.h" -#include "MidiGroupTerminalBlockList.h" -#include "MidiGroupTerminalBlockList.g.cpp" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ -} diff --git a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.h b/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.h deleted file mode 100644 index 7e55aac4c..000000000 --- a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "MidiGroupTerminalBlockList.g.h" -#include "MidiListBase.h" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ - struct MidiGroupTerminalBlockList : MidiGroupTerminalBlockListT - { - MidiGroupTerminalBlockList() = default; - - }; -} -namespace winrt::Microsoft::Devices::Midi2::factory_implementation -{ - struct MidiGroupTerminalBlockList : MidiGroupTerminalBlockListT - { - }; -} diff --git a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.idl b/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.idl deleted file mode 100644 index b50edbccd..000000000 --- a/src/app-dev-sdk/sdk-core/MidiGroupTerminalBlockList.idl +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License -// ============================================================================ -// This is part of the Windows MIDI Services App SDK and should be used -// in your Windows application via an official binary distribution. -// Further information: https://github.com/microsoft/MIDI/ -// ============================================================================ - -// The various list implementations are here because some languages (like Delphi/Pascal) -// have no automatic projection support, and can't reasonably handle any class with -// templates / generics. -// The IDL is a placeholder for now - - -import "MidiListBase.idl"; - -namespace Microsoft.Devices.Midi2 -{ - [default_interface] - runtimeclass MidiGroupTerminalBlockList : MidiListBase - { - MidiGroupTerminalBlockList(); - } -} \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core/MidiChannelList.cpp b/src/app-dev-sdk/sdk-core/MidiInteropHelper.cpp similarity index 64% rename from src/app-dev-sdk/sdk-core/MidiChannelList.cpp rename to src/app-dev-sdk/sdk-core/MidiInteropHelper.cpp index cdde26208..d7d87f377 100644 --- a/src/app-dev-sdk/sdk-core/MidiChannelList.cpp +++ b/src/app-dev-sdk/sdk-core/MidiInteropHelper.cpp @@ -7,9 +7,14 @@ // ============================================================================ #include "pch.h" -#include "MidiChannelList.h" -#include "MidiChannelList.g.cpp" +#include "MidiInteropHelper.h" +#include "MidiInteropHelper.g.cpp" + namespace winrt::Microsoft::Devices::Midi2::implementation { + winrt::Windows::Foundation::Collections::IVector MidiInteropHelper::CreateEmptyUmpWithTimestampList() + { + throw hresult_not_implemented(); + } } diff --git a/src/app-dev-sdk/sdk-core/MidiChannelList.h b/src/app-dev-sdk/sdk-core/MidiInteropHelper.h similarity index 60% rename from src/app-dev-sdk/sdk-core/MidiChannelList.h rename to src/app-dev-sdk/sdk-core/MidiInteropHelper.h index f73b44b04..3702af2f1 100644 --- a/src/app-dev-sdk/sdk-core/MidiChannelList.h +++ b/src/app-dev-sdk/sdk-core/MidiInteropHelper.h @@ -7,20 +7,21 @@ // ============================================================================ #pragma once -#include "MidiChannelList.g.h" -#include "MidiListBase.h" +#include "MidiInteropHelper.g.h" + namespace winrt::Microsoft::Devices::Midi2::implementation { - struct MidiChannelList : MidiChannelListT + struct MidiInteropHelper : MidiInteropHelperT { - MidiChannelList() = default; + MidiInteropHelper() = default; + static winrt::Windows::Foundation::Collections::IVector CreateEmptyUmpWithTimestampList(); }; } namespace winrt::Microsoft::Devices::Midi2::factory_implementation { - struct MidiChannelList : MidiChannelListT + struct MidiInteropHelper : MidiInteropHelperT { }; } diff --git a/src/app-dev-sdk/sdk-core/MidiGroupList.idl b/src/app-dev-sdk/sdk-core/MidiInteropHelper.idl similarity index 59% rename from src/app-dev-sdk/sdk-core/MidiGroupList.idl rename to src/app-dev-sdk/sdk-core/MidiInteropHelper.idl index 337bcdc68..bd361c85a 100644 --- a/src/app-dev-sdk/sdk-core/MidiGroupList.idl +++ b/src/app-dev-sdk/sdk-core/MidiInteropHelper.idl @@ -6,19 +6,17 @@ // Further information: https://github.com/microsoft/MIDI/ // ============================================================================ -// The various list implementations are here because some languages (like Delphi/Pascal) -// have no automatic projection support, and can't reasonably handle any class with -// templates / generics. -// The IDL is a placeholder for now +// some helper methods for folks having to build their own projections for languages +// like Delphi. - -import "MidiListBase.idl"; +import "MidiUmpWithTimestamp.idl"; namespace Microsoft.Devices.Midi2 { [default_interface] - runtimeclass MidiGroupList : MidiListBase + runtimeclass MidiInteropHelper { - MidiGroupList(); - } + static IVector CreateEmptyUmpWithTimestampList(); + + } } \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core/MidiListBase.cpp b/src/app-dev-sdk/sdk-core/MidiListBase.cpp deleted file mode 100644 index e5081e0c8..000000000 --- a/src/app-dev-sdk/sdk-core/MidiListBase.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "pch.h" -#include "MidiListBase.h" -#include "MidiListBase.g.cpp" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ -} diff --git a/src/app-dev-sdk/sdk-core/MidiListBase.h b/src/app-dev-sdk/sdk-core/MidiListBase.h deleted file mode 100644 index 2e98097b8..000000000 --- a/src/app-dev-sdk/sdk-core/MidiListBase.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "MidiListBase.g.h" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ - struct MidiListBase : MidiListBaseT - { - MidiListBase() = default; - - }; -} diff --git a/src/app-dev-sdk/sdk-core/MidiListBase.idl b/src/app-dev-sdk/sdk-core/MidiListBase.idl deleted file mode 100644 index 78e5f14e7..000000000 --- a/src/app-dev-sdk/sdk-core/MidiListBase.idl +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License -// ============================================================================ -// This is part of the Windows MIDI Services App SDK and should be used -// in your Windows application via an official binary distribution. -// Further information: https://github.com/microsoft/MIDI/ -// ============================================================================ - -// The various list implementations are here because some languages (like Delphi/Pascal) -// have no automatic projection support, and can't reasonably handle any class with -// templates / generics. -// The IDL is a placeholder for now -// Ref: https://learn.microsoft.com/windows/uwp/cpp-and-winrt-apis/collections - -// TODO: This needs to have in here, or a separate COM interface, some reasonable way -// to convert to/from std::vector. Normally the IVector projection would do that for you -// for C++ - - -namespace Microsoft.Devices.Midi2 -{ - [default_interface] - unsealed runtimeclass MidiListBase - { - - } -} \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core/MidiMessageReader.cpp b/src/app-dev-sdk/sdk-core/MidiMessageReader.cpp index 653a0c79c..6ea459056 100644 --- a/src/app-dev-sdk/sdk-core/MidiMessageReader.cpp +++ b/src/app-dev-sdk/sdk-core/MidiMessageReader.cpp @@ -41,7 +41,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { throw hresult_not_implemented(); } - winrt::Microsoft::Devices::Midi2::MidiUmpWithTimestampList MidiMessageReader::ReadToEnd() + winrt::Windows::Foundation::Collections::IVector MidiMessageReader::ReadToEnd() { throw hresult_not_implemented(); } diff --git a/src/app-dev-sdk/sdk-core/MidiMessageReader.h b/src/app-dev-sdk/sdk-core/MidiMessageReader.h index 51900e126..db71fc90d 100644 --- a/src/app-dev-sdk/sdk-core/MidiMessageReader.h +++ b/src/app-dev-sdk/sdk-core/MidiMessageReader.h @@ -23,7 +23,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation winrt::Microsoft::Devices::Midi2::MidiUmpMessageType PeekNextUmpMessageType(); winrt::Microsoft::Devices::Midi2::MidiUmpSize PeekNextUmpSize(); winrt::Microsoft::Devices::Midi2::MidiUmpWithTimestamp PeekNextMessage(); - winrt::Microsoft::Devices::Midi2::MidiUmpWithTimestampList ReadToEnd(); + winrt::Windows::Foundation::Collections::IVector ReadToEnd(); winrt::Microsoft::Devices::Midi2::MidiUmpWithTimestamp ReadNextMessage(); winrt::Microsoft::Devices::Midi2::MidiUmp32 ReadUmp32(); winrt::Microsoft::Devices::Midi2::MidiUmp64 ReadUmp64(); diff --git a/src/app-dev-sdk/sdk-core/MidiMessageReader.idl b/src/app-dev-sdk/sdk-core/MidiMessageReader.idl index 936c1f22e..7c3d5237e 100644 --- a/src/app-dev-sdk/sdk-core/MidiMessageReader.idl +++ b/src/app-dev-sdk/sdk-core/MidiMessageReader.idl @@ -8,7 +8,6 @@ import "MidiUmpMessageTypeEnum.idl"; import "MidiUmpWithTimestamp.idl"; -import "MidiUmpWithTimestampList.idl"; import "MidiUmpSizeEnum.idl"; @@ -47,7 +46,7 @@ namespace Microsoft.Devices.Midi2 MidiUmpWithTimestamp PeekNextMessage(); // copies all pending messages into a List - MidiUmpWithTimestampList ReadToEnd(); + IVector ReadToEnd(); // reads a single message in a polymorphic way MidiUmpWithTimestamp ReadNextMessage(); diff --git a/src/app-dev-sdk/sdk-core/MidiMessageWriter.cpp b/src/app-dev-sdk/sdk-core/MidiMessageWriter.cpp index 78d69fce3..c02272d88 100644 --- a/src/app-dev-sdk/sdk-core/MidiMessageWriter.cpp +++ b/src/app-dev-sdk/sdk-core/MidiMessageWriter.cpp @@ -41,7 +41,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { throw hresult_not_implemented(); } - void MidiMessageWriter::WriteMultipleUmpsWithTimestamps(winrt::Microsoft::Devices::Midi2::MidiUmpWithTimestampList const& umpList) + void MidiMessageWriter::WriteMultipleUmpsWithTimestamps(winrt::Windows::Foundation::Collections::IVector const& umpList) { throw hresult_not_implemented(); } diff --git a/src/app-dev-sdk/sdk-core/MidiMessageWriter.h b/src/app-dev-sdk/sdk-core/MidiMessageWriter.h index 022c8ed23..ce43f677f 100644 --- a/src/app-dev-sdk/sdk-core/MidiMessageWriter.h +++ b/src/app-dev-sdk/sdk-core/MidiMessageWriter.h @@ -23,7 +23,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation void WriteUmpWords128(uint64_t midiTimestamp, uint32_t umpWord1, uint32_t umpWord2, uint32_t umpWord3, uint32_t umpWord4); void WriteUmpWords(uint64_t midiTimeStamp, array_view words, uint8_t wordCount); void WriteUmpWithTimestamp(winrt::Microsoft::Devices::Midi2::MidiUmpWithTimestamp const& ump); - void WriteMultipleUmpsWithTimestamps(winrt::Microsoft::Devices::Midi2::MidiUmpWithTimestampList const& umpList); + void WriteMultipleUmpsWithTimestamps(winrt::Windows::Foundation::Collections::IVector const& umpList); uint32_t WriteTimestampedUmpStructsFromBuffer(winrt::Windows::Foundation::IMemoryBufferReference const& buffer, uint32_t byteOffsetInBuffer, uint32_t maxBytesToWrite); void WriteTimestampedUmp32Struct(winrt::Microsoft::Devices::Midi2::MidiUmp32 const& ump); void WriteTimestampedUmp64Struct(winrt::Microsoft::Devices::Midi2::MidiUmp64 const& ump); diff --git a/src/app-dev-sdk/sdk-core/MidiMessageWriter.idl b/src/app-dev-sdk/sdk-core/MidiMessageWriter.idl index 49a3d59b1..91c73e5cf 100644 --- a/src/app-dev-sdk/sdk-core/MidiMessageWriter.idl +++ b/src/app-dev-sdk/sdk-core/MidiMessageWriter.idl @@ -22,7 +22,7 @@ // written to the queue/stream. import "MidiUmpWithTimestamp.idl"; -import "MidiUmpWithTimestampList.idl"; + namespace Microsoft.Devices.Midi2 @@ -55,7 +55,7 @@ namespace Microsoft.Devices.Midi2 // use these for all strongly-typed UMPs void WriteUmpWithTimestamp(MidiUmpWithTimestamp ump); - void WriteMultipleUmpsWithTimestamps(MidiUmpWithTimestampList umpList); + void WriteMultipleUmpsWithTimestamps(IVector umpList); // write a single UMP struct to the stream void WriteTimestampedUmp32Struct(ref const MidiUmp32 ump); diff --git a/src/app-dev-sdk/sdk-core/MidiServices.cpp b/src/app-dev-sdk/sdk-core/MidiServices.cpp index c595bc760..bf453c825 100644 --- a/src/app-dev-sdk/sdk-core/MidiServices.cpp +++ b/src/app-dev-sdk/sdk-core/MidiServices.cpp @@ -35,7 +35,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { throw hresult_not_implemented(); } - winrt::Microsoft::Devices::Midi2::MidiTransportInformationList MidiServices::GetInstalledTransports() + winrt::Windows::Foundation::Collections::IVector MidiServices::GetInstalledTransports() { throw hresult_not_implemented(); } diff --git a/src/app-dev-sdk/sdk-core/MidiServices.h b/src/app-dev-sdk/sdk-core/MidiServices.h index 57118d4d2..26f44518b 100644 --- a/src/app-dev-sdk/sdk-core/MidiServices.h +++ b/src/app-dev-sdk/sdk-core/MidiServices.h @@ -20,7 +20,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation static hstring SdkVersion(); static hstring MinimumCompatibleMidiServicesVersion(); static winrt::Windows::Foundation::Uri LatestMidiServicesInstallUri(); - static winrt::Microsoft::Devices::Midi2::MidiTransportInformationList GetInstalledTransports(); + static winrt::Windows::Foundation::Collections::IVector GetInstalledTransports(); }; } namespace winrt::Microsoft::Devices::Midi2::factory_implementation diff --git a/src/app-dev-sdk/sdk-core/MidiServices.idl b/src/app-dev-sdk/sdk-core/MidiServices.idl index b4e9b450d..352faf982 100644 --- a/src/app-dev-sdk/sdk-core/MidiServices.idl +++ b/src/app-dev-sdk/sdk-core/MidiServices.idl @@ -7,7 +7,6 @@ // ============================================================================ import "MidiTransportInformation.idl"; -import "MidiTransportInformationList.idl"; namespace Microsoft.Devices.Midi2 { @@ -36,7 +35,7 @@ namespace Microsoft.Devices.Midi2 static Windows.Foundation.Uri LatestMidiServicesInstallUri{ get; }; // list all the installed transports like Virtual, USB, BLE1, etc - static MidiTransportInformationList GetInstalledTransports(); + static IVector GetInstalledTransports(); } diff --git a/src/app-dev-sdk/sdk-core/MidiSession.cpp b/src/app-dev-sdk/sdk-core/MidiSession.cpp index 344f00481..01dd87c97 100644 --- a/src/app-dev-sdk/sdk-core/MidiSession.cpp +++ b/src/app-dev-sdk/sdk-core/MidiSession.cpp @@ -18,12 +18,14 @@ namespace winrt::Microsoft::Devices::Midi2::implementation // TODO: Call the service to create the session return winrt::make(); + + } bool MidiSession::IsOpen() { throw hresult_not_implemented(); } - winrt::Microsoft::Devices::Midi2::MidiEndpointConnectionList MidiSession::Connections() + winrt::Windows::Foundation::Collections::IVectorView MidiSession::Connections() { throw hresult_not_implemented(); } diff --git a/src/app-dev-sdk/sdk-core/MidiSession.h b/src/app-dev-sdk/sdk-core/MidiSession.h index 9bc5b8f26..f1dae8a19 100644 --- a/src/app-dev-sdk/sdk-core/MidiSession.h +++ b/src/app-dev-sdk/sdk-core/MidiSession.h @@ -18,7 +18,7 @@ namespace winrt::Microsoft::Devices::Midi2::implementation static winrt::Microsoft::Devices::Midi2::MidiSession CreateNewSession(hstring const& sessionName, winrt::Microsoft::Devices::Midi2::MidiSessionSettings const& settings); bool IsOpen(); - winrt::Microsoft::Devices::Midi2::MidiEndpointConnectionList Connections(); + winrt::Windows::Foundation::Collections::IVectorView Connections(); winrt::Microsoft::Devices::Midi2::MidiEndpointConnection ConnectToEndpoint(hstring const& midiEndpointId, bool routeIncomingMessagesToSession, winrt::Microsoft::Devices::Midi2::MidiEndpointConnectOptions const& options); void DisconnectFromEndpoint(hstring const& midiEndpointId); uint64_t GetMidiTimestamp(); diff --git a/src/app-dev-sdk/sdk-core/MidiSession.idl b/src/app-dev-sdk/sdk-core/MidiSession.idl index 0173ccc78..fbfe3b971 100644 --- a/src/app-dev-sdk/sdk-core/MidiSession.idl +++ b/src/app-dev-sdk/sdk-core/MidiSession.idl @@ -11,7 +11,6 @@ import "MidiEndpointConnection.idl"; import "MidiEndpointConnectOptions.idl"; import "MidiSessionSettings.idl"; import "MidiMessagesReceivedEventArgs.idl"; -import "MidiEndpointConnectionList.idl"; namespace Microsoft.Devices.Midi2 { @@ -31,7 +30,7 @@ namespace Microsoft.Devices.Midi2 // this really should be read-only to users of this class //Windows.Foundation.Collections.IObservableVector Connections { get; }; - MidiEndpointConnectionList Connections{ get; }; + IVectorView Connections{ get; }; // uses the enumeration information to connect to an endpoint // adds it to the list of connected endpoints. The boolean diff --git a/src/app-dev-sdk/sdk-core/MidiTransportInformationList.cpp b/src/app-dev-sdk/sdk-core/MidiTransportInformationList.cpp deleted file mode 100644 index 4c9165bb5..000000000 --- a/src/app-dev-sdk/sdk-core/MidiTransportInformationList.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "pch.h" -#include "MidiTransportInformationList.h" -#include "MidiTransportInformationList.g.cpp" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ -} diff --git a/src/app-dev-sdk/sdk-core/MidiTransportInformationList.h b/src/app-dev-sdk/sdk-core/MidiTransportInformationList.h deleted file mode 100644 index 4a192f0cd..000000000 --- a/src/app-dev-sdk/sdk-core/MidiTransportInformationList.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "MidiTransportInformationList.g.h" -#include "MidiListBase.h" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ - struct MidiTransportInformationList : MidiTransportInformationListT - { - MidiTransportInformationList() = default; - - }; -} -namespace winrt::Microsoft::Devices::Midi2::factory_implementation -{ - struct MidiTransportInformationList : MidiTransportInformationListT - { - }; -} diff --git a/src/app-dev-sdk/sdk-core/MidiTransportInformationList.idl b/src/app-dev-sdk/sdk-core/MidiTransportInformationList.idl deleted file mode 100644 index d46ee3227..000000000 --- a/src/app-dev-sdk/sdk-core/MidiTransportInformationList.idl +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License -// ============================================================================ -// This is part of the Windows MIDI Services App SDK and should be used -// in your Windows application via an official binary distribution. -// Further information: https://github.com/microsoft/MIDI/ -// ============================================================================ - -// The various list implementations are here because some languages (like Delphi/Pascal) -// have no automatic projection support, and can't reasonably handle any class with -// templates / generics. -// The IDL is a placeholder for now - - -import "MidiListBase.idl"; - -namespace Microsoft.Devices.Midi2 -{ - [default_interface] - runtimeclass MidiTransportInformationList : MidiListBase - { - MidiTransportInformationList(); - } -} \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.cpp b/src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.cpp deleted file mode 100644 index 29e670e50..000000000 --- a/src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "pch.h" -#include "MidiUmpWithTimestampList.h" -#include "MidiUmpWithTimestampList.g.cpp" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ -} diff --git a/src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.h b/src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.h deleted file mode 100644 index 1e2111a16..000000000 --- a/src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "MidiUmpWithTimestampList.g.h" -#include "MidiListBase.h" - - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ - struct MidiUmpWithTimestampList : MidiUmpWithTimestampListT - { - MidiUmpWithTimestampList() = default; - - }; -} -namespace winrt::Microsoft::Devices::Midi2::factory_implementation -{ - struct MidiUmpWithTimestampList : MidiUmpWithTimestampListT - { - }; -} diff --git a/src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.idl b/src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.idl deleted file mode 100644 index d46602d6d..000000000 --- a/src/app-dev-sdk/sdk-core/MidiUmpWithTimestampList.idl +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License -// ============================================================================ -// This is part of the Windows MIDI Services App SDK and should be used -// in your Windows application via an official binary distribution. -// Further information: https://github.com/microsoft/MIDI/ -// ============================================================================ - -// The various list implementations are here because some languages (like Delphi/Pascal) -// have no automatic projection support, and can't reasonably handle any class with -// templates / generics. -// The IDL is a placeholder for now - -import "MidiListBase.idl"; - -namespace Microsoft.Devices.Midi2 -{ - [default_interface] - runtimeclass MidiUmpWithTimestampList : MidiListBase - { - MidiUmpWithTimestampList(); - - - - } -} \ No newline at end of file From 53416f43cae84d7d7d1fc6ee65360730ab15ea03 Mon Sep 17 00:00:00 2001 From: Pete Brown Date: Sat, 1 Jul 2023 17:58:24 -0400 Subject: [PATCH 2/6] Hard-coding a bunch of session and service properties and functions No API yet, so hard-coded results so folks can start doing meaningful work targeting the SDK. Still a lot to do here. --- .../sdk-core-cpp-winrt-tests/DummyTests.cpp | 34 ------- .../sdk-core-cpp-winrt-tests/ServiceTests.cpp | 37 ++++--- .../sdk-core-cpp-winrt-tests/SessionTests.cpp | 2 +- .../sdk-core-cpp-winrt-tests.vcxproj | 1 - .../sdk-core-cpp-winrt-tests.vcxproj.filters | 6 -- src/app-dev-sdk/sdk-core/DummyTestClass.cpp | 98 ------------------- src/app-dev-sdk/sdk-core/DummyTestClass.h | 32 ------ src/app-dev-sdk/sdk-core/DummyTestClass.idl | 32 ------ .../Microsoft.Devices.Midi2.Core.vcxproj | 11 ++- .../sdk-core/MidiInteropHelper.cpp | 11 ++- src/app-dev-sdk/sdk-core/MidiInteropHelper.h | 3 +- .../sdk-core/MidiInteropHelper.idl | 3 +- src/app-dev-sdk/sdk-core/MidiServices.cpp | 53 ++++++++-- src/app-dev-sdk/sdk-core/MidiServices.h | 7 +- src/app-dev-sdk/sdk-core/MidiServices.idl | 8 +- src/app-dev-sdk/sdk-core/MidiSession.cpp | 21 ++-- src/app-dev-sdk/sdk-core/MidiSession.h | 6 ++ .../sdk-core/MidiSessionSettings.cpp | 4 +- .../sdk-core/MidiTransportInformation.cpp | 35 +++++-- .../sdk-core/MidiTransportInformation.h | 22 +++++ src/app-dev-sdk/sdk-core/MidiUmpUtilities.cpp | 2 +- .../sdk-core/MidiUmpWithTimestamp.cpp | 2 +- .../sdk-core/midi_app_sdk_version.h | 3 + src/app-dev-sdk/sdk-core/pch.h | 3 + 24 files changed, 180 insertions(+), 256 deletions(-) delete mode 100644 src/app-dev-sdk/sdk-core-cpp-winrt-tests/DummyTests.cpp delete mode 100644 src/app-dev-sdk/sdk-core/DummyTestClass.cpp delete mode 100644 src/app-dev-sdk/sdk-core/DummyTestClass.h delete mode 100644 src/app-dev-sdk/sdk-core/DummyTestClass.idl diff --git a/src/app-dev-sdk/sdk-core-cpp-winrt-tests/DummyTests.cpp b/src/app-dev-sdk/sdk-core-cpp-winrt-tests/DummyTests.cpp deleted file mode 100644 index 2ef0272bc..000000000 --- a/src/app-dev-sdk/sdk-core-cpp-winrt-tests/DummyTests.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "pch.h" - -#include "catch_amalgamated.hpp" - -using namespace winrt; -using namespace Microsoft::Devices::Midi2; - -namespace DummyTests -{ - - TEST_CASE("Create test class and set a property") - { - DummyTestClass obj; - - const uint32_t val = 200; - - obj.SomeProperty(val); - - REQUIRE((bool)(obj.SomeProperty() == val)); - } - - TEST_CASE("Load up UMPs") - { - const uint32_t countUmp = 10; - - DummyTestClass obj{}; - - obj.LoadDummyUmps(countUmp); - - REQUIRE((bool)(obj.Umps().Size() == countUmp)); - } - - -} diff --git a/src/app-dev-sdk/sdk-core-cpp-winrt-tests/ServiceTests.cpp b/src/app-dev-sdk/sdk-core-cpp-winrt-tests/ServiceTests.cpp index c1027f8df..466561d4d 100644 --- a/src/app-dev-sdk/sdk-core-cpp-winrt-tests/ServiceTests.cpp +++ b/src/app-dev-sdk/sdk-core-cpp-winrt-tests/ServiceTests.cpp @@ -2,46 +2,51 @@ #include "catch_amalgamated.hpp" +#include + using namespace winrt; using namespace Microsoft::Devices::Midi2; TEST_CASE("Check for Windows MIDI Services", "[MidiServices.CheckForWindowsMidiServices]") { - // fails until implemented - REQUIRE(false); - - //REQUIRE((bool)(obj.SomeProperty() == val)); + REQUIRE_NOTHROW(MidiServices::CheckForWindowsMidiServices()); } TEST_CASE("Get installed Windows MIDI Services Version", "[MidiServices.GetInstalledWindowsMidiServicesVersion]") { - // fails until implemented - REQUIRE(false); + REQUIRE_NOTHROW(MidiServices::GetInstalledWindowsMidiServicesVersion()); + + + hstring version = MidiServices::GetInstalledWindowsMidiServicesVersion(); - //REQUIRE((bool)(obj.SomeProperty() == val)); + REQUIRE(version != L""); } TEST_CASE("Get SDK Version", "[MidiServices.GetSdkVersion]") { - // fails until implemented - REQUIRE(false); + REQUIRE_NOTHROW(MidiServices::SdkVersion()); - //REQUIRE((bool)(obj.SomeProperty() == val)); + hstring version = MidiServices::SdkVersion(); + + REQUIRE(version != L""); } TEST_CASE("Get Latest MIDI Services Installer URI", "[MidiServices.LatestMidiServicesInstallUri]") { - // fails until implemented - REQUIRE(false); + REQUIRE_NOTHROW(MidiServices::LatestMidiServicesInstallUri()); + + auto uri = MidiServices::LatestMidiServicesInstallUri(); - //REQUIRE((bool)(obj.SomeProperty() == val)); + std::cout << uri.ToString().c_str(); } TEST_CASE("Get Installed Transports", "[MidiServices.GetInstalledTransports]") { - // fails until implemented - REQUIRE(false); + REQUIRE_NOTHROW(MidiServices::GetInstalledTransports()); + + auto transports = MidiServices::GetInstalledTransports(); - //REQUIRE((bool)(obj.SomeProperty() == val)); + // zero installed transports is, in theory, a passing case, but we're going to ignore that + REQUIRE(transports.Size() > 0); } diff --git a/src/app-dev-sdk/sdk-core-cpp-winrt-tests/SessionTests.cpp b/src/app-dev-sdk/sdk-core-cpp-winrt-tests/SessionTests.cpp index 6a39c36d9..08938872e 100644 --- a/src/app-dev-sdk/sdk-core-cpp-winrt-tests/SessionTests.cpp +++ b/src/app-dev-sdk/sdk-core-cpp-winrt-tests/SessionTests.cpp @@ -13,6 +13,6 @@ TEST_CASE("Create session") auto session = MidiSession::CreateNewSession(L"Test Session Name", settings); - //REQUIRE((bool)(obj.SomeProperty() == val)); + REQUIRE((bool)(session.IsOpen())); } diff --git a/src/app-dev-sdk/sdk-core-cpp-winrt-tests/sdk-core-cpp-winrt-tests.vcxproj b/src/app-dev-sdk/sdk-core-cpp-winrt-tests/sdk-core-cpp-winrt-tests.vcxproj index 73c8eb51c..9f67418bc 100644 --- a/src/app-dev-sdk/sdk-core-cpp-winrt-tests/sdk-core-cpp-winrt-tests.vcxproj +++ b/src/app-dev-sdk/sdk-core-cpp-winrt-tests/sdk-core-cpp-winrt-tests.vcxproj @@ -125,7 +125,6 @@ - Create diff --git a/src/app-dev-sdk/sdk-core-cpp-winrt-tests/sdk-core-cpp-winrt-tests.vcxproj.filters b/src/app-dev-sdk/sdk-core-cpp-winrt-tests/sdk-core-cpp-winrt-tests.vcxproj.filters index 0f82d3d47..422476006 100644 --- a/src/app-dev-sdk/sdk-core-cpp-winrt-tests/sdk-core-cpp-winrt-tests.vcxproj.filters +++ b/src/app-dev-sdk/sdk-core-cpp-winrt-tests/sdk-core-cpp-winrt-tests.vcxproj.filters @@ -9,9 +9,6 @@ Tests - - TempTests - Tests @@ -27,9 +24,6 @@ - - {fbfc8fff-af3f-4456-b52b-3b6c75bd3672} - {e34a5f67-984a-4f18-8ccd-0bcce7fd5ba9} diff --git a/src/app-dev-sdk/sdk-core/DummyTestClass.cpp b/src/app-dev-sdk/sdk-core/DummyTestClass.cpp deleted file mode 100644 index 196933d10..000000000 --- a/src/app-dev-sdk/sdk-core/DummyTestClass.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "pch.h" -#include "DummyTestClass.h" -#include "DummyTestClass.g.cpp" - -#include -#include "midi_timestamp.h" -#include "ump_helpers.h" - -using namespace Microsoft::Devices::Midi2::Internal::Shared; -using namespace Microsoft::Devices::Midi2::Internal; - -namespace winrt::Microsoft::Devices::Midi2::implementation -{ - winrt::Microsoft::Devices::Midi2::MidiUmpMessageType DummyTestClass::GetSomeStaticValue() - { - return MidiUmpMessageType::Midi2ChannelVoice64; - } - uint32_t DummyTestClass::SomeProperty() - { - return _someProperty; - } - void DummyTestClass::SomeProperty(uint32_t value) - { - _someProperty = value; - } - uint32_t DummyTestClass::SomeReadOnlyProperty() - { - return (uint32_t)_umps.Size(); - } - winrt::Windows::Foundation::Collections::IVector DummyTestClass::Umps() - { - return _umps; - } - - // the messages this creates are valid only in that the size matches the message type. Otherwise, it's garbage data - void DummyTestClass::LoadDummyUmps(uint32_t count) - { - // gen a decent spread of random numbers so we can pick the right message types - - std::random_device rand; - std::mt19937 engine(rand()); - std::uniform_int_distribution<> distribution(0x0, 0xF); - - - for (int i = 0; i < count; i++) - { - uint8_t messageType = distribution(engine); - - switch (GetUmpLengthInMidiWordsFromMessageType(messageType)) - { - case 1: - { - MidiUmp32 umpStruct; - umpStruct.Timestamp = GetCurrentMidiTimestamp(); - umpStruct.Word1 = 0x0ABCDEF9 | (messageType << 28); - - _umps.Append(MidiUmpWithTimestamp::FromUmp32(umpStruct)); - } - break; - case 2: - { - MidiUmp64 umpStruct; - umpStruct.Timestamp = GetCurrentMidiTimestamp(); - umpStruct.Word1 = 0x09876541 | (messageType << 28); - umpStruct.Word2 = 0xAAAABBB1; - - _umps.Append(MidiUmpWithTimestamp::FromUmp64(umpStruct)); - } - break; - case 3: - { - MidiUmp96 umpStruct; - umpStruct.Timestamp = GetCurrentMidiTimestamp(); - umpStruct.Word1 = 0x0ABCDEF3 | (messageType << 28); - umpStruct.Word2 = 0xCCCCDDD3; - umpStruct.Word3 = 0x99997773; - - _umps.Append(MidiUmpWithTimestamp::FromUmp96(umpStruct)); - } - break; - case 4: - { - MidiUmp128 umpStruct; - umpStruct.Timestamp = GetCurrentMidiTimestamp(); - umpStruct.Word1 = 0x0FAFBFC1 | (messageType << 28); - umpStruct.Word2 = 0xEEEEFFF1; - umpStruct.Word3 = 0x66665551; - umpStruct.Word4 = 0x88889901; - - _umps.Append(MidiUmpWithTimestamp::FromUmp128(umpStruct)); - } - break; - } - - } - } - -} diff --git a/src/app-dev-sdk/sdk-core/DummyTestClass.h b/src/app-dev-sdk/sdk-core/DummyTestClass.h deleted file mode 100644 index 3b937a66e..000000000 --- a/src/app-dev-sdk/sdk-core/DummyTestClass.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "DummyTestClass.g.h" - -// WARNING: This file is automatically generated by a tool. Do not directly -// add this file to your project, as any changes you make will be lost. -namespace winrt::Microsoft::Devices::Midi2::implementation -{ - struct DummyTestClass : DummyTestClassT - { - DummyTestClass() = default; - - static winrt::Microsoft::Devices::Midi2::MidiUmpMessageType GetSomeStaticValue(); - uint32_t SomeProperty(); - void SomeProperty(uint32_t value); - uint32_t SomeReadOnlyProperty(); - winrt::Windows::Foundation::Collections::IVector Umps(); - - void LoadDummyUmps(uint32_t count); - - private: - winrt::Windows::Foundation::Collections::IVector - _umps{ winrt::single_threaded_vector() }; - - uint32_t _someProperty = 0; - }; -} -namespace winrt::Microsoft::Devices::Midi2::factory_implementation -{ - struct DummyTestClass : DummyTestClassT - { - }; -} diff --git a/src/app-dev-sdk/sdk-core/DummyTestClass.idl b/src/app-dev-sdk/sdk-core/DummyTestClass.idl deleted file mode 100644 index 1a8d968c9..000000000 --- a/src/app-dev-sdk/sdk-core/DummyTestClass.idl +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License -// ============================================================================ -// This is part of the Windows MIDI Services App SDK and should be used -// in your Windows application via an official binary distribution. -// Further information: https://github.com/microsoft/MIDI/ -// ============================================================================ - - -import "MidiUmpMessageTypeEnum.idl"; -import "MidiUmpWithTimestamp.idl"; - -namespace Microsoft.Devices.Midi2 -{ - [default_interface] - runtimeclass DummyTestClass - { - DummyTestClass(); - - static MidiUmpMessageType GetSomeStaticValue(); - - UInt32 SomeProperty{ get; set; }; - - UInt32 SomeReadOnlyProperty{ get; }; - - - void LoadDummyUmps(UInt32 count); - - IVector Umps{ get; }; - - } -} \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj b/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj index 9ffc9afc3..7f9bf958c 100644 --- a/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj +++ b/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj @@ -157,14 +157,15 @@ - MidiEndpointDisplayFormatter.idl MidiHighResolutionValueDisplayFormatter.idl - + + MidiInteropHelper.idl + MidiLocalizedStrings.idl @@ -229,14 +230,15 @@ - MidiEndpointDisplayFormatter.idl MidiHighResolutionValueDisplayFormatter.idl - + + MidiInteropHelper.idl + MidiLocalizedStrings.idl @@ -299,7 +301,6 @@ - diff --git a/src/app-dev-sdk/sdk-core/MidiInteropHelper.cpp b/src/app-dev-sdk/sdk-core/MidiInteropHelper.cpp index d7d87f377..7b82d70e2 100644 --- a/src/app-dev-sdk/sdk-core/MidiInteropHelper.cpp +++ b/src/app-dev-sdk/sdk-core/MidiInteropHelper.cpp @@ -13,8 +13,15 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { - winrt::Windows::Foundation::Collections::IVector MidiInteropHelper::CreateEmptyUmpWithTimestampList() + winrt::Windows::Foundation::Collections::IVector MidiInteropHelper::CreateEmptySingleThreadedUmpWithTimestampList() { - throw hresult_not_implemented(); + return winrt::single_threaded_vector< winrt::Microsoft::Devices::Midi2::MidiUmpWithTimestamp>(); } + + winrt::Windows::Foundation::Collections::IVector MidiInteropHelper::CreateEmptyMultiThreadedUmpWithTimestampList() + { + return winrt::multi_threaded_vector< winrt::Microsoft::Devices::Midi2::MidiUmpWithTimestamp>(); + } + + } diff --git a/src/app-dev-sdk/sdk-core/MidiInteropHelper.h b/src/app-dev-sdk/sdk-core/MidiInteropHelper.h index 3702af2f1..47920559b 100644 --- a/src/app-dev-sdk/sdk-core/MidiInteropHelper.h +++ b/src/app-dev-sdk/sdk-core/MidiInteropHelper.h @@ -16,7 +16,8 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { MidiInteropHelper() = default; - static winrt::Windows::Foundation::Collections::IVector CreateEmptyUmpWithTimestampList(); + static winrt::Windows::Foundation::Collections::IVector CreateEmptySingleThreadedUmpWithTimestampList(); + static winrt::Windows::Foundation::Collections::IVector CreateEmptyMultiThreadedUmpWithTimestampList(); }; } namespace winrt::Microsoft::Devices::Midi2::factory_implementation diff --git a/src/app-dev-sdk/sdk-core/MidiInteropHelper.idl b/src/app-dev-sdk/sdk-core/MidiInteropHelper.idl index bd361c85a..8ef950c93 100644 --- a/src/app-dev-sdk/sdk-core/MidiInteropHelper.idl +++ b/src/app-dev-sdk/sdk-core/MidiInteropHelper.idl @@ -16,7 +16,8 @@ namespace Microsoft.Devices.Midi2 [default_interface] runtimeclass MidiInteropHelper { - static IVector CreateEmptyUmpWithTimestampList(); + static IVector CreateEmptySingleThreadedUmpWithTimestampList(); + static IVector CreateEmptyMultiThreadedUmpWithTimestampList(); } } \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core/MidiServices.cpp b/src/app-dev-sdk/sdk-core/MidiServices.cpp index bf453c825..bcac89df6 100644 --- a/src/app-dev-sdk/sdk-core/MidiServices.cpp +++ b/src/app-dev-sdk/sdk-core/MidiServices.cpp @@ -11,17 +11,24 @@ #include "MidiServices.h" #include "MidiServices.g.cpp" + #include "midi_app_sdk_version.h" +using namespace Microsoft::Devices::Midi2; + namespace winrt::Microsoft::Devices::Midi2::implementation { - bool MidiServices::CheckForWindowsMidiServices(winrt::Microsoft::Devices::Midi2::WindowsMidiServicesCheckError& errorResult) + winrt::Microsoft::Devices::Midi2::WindowsMidiServicesCheckResult MidiServices::CheckForWindowsMidiServices() { - throw hresult_not_implemented(); + // TODO: This will be a call to check the actual service + + return WindowsMidiServicesCheckResult::NotPresent; } hstring MidiServices::GetInstalledWindowsMidiServicesVersion() { - throw hresult_not_implemented(); + // TODO: Temp + + return L"0.0.0-not-present"; } hstring MidiServices::SdkVersion() { @@ -29,14 +36,48 @@ namespace winrt::Microsoft::Devices::Midi2::implementation } hstring MidiServices::MinimumCompatibleMidiServicesVersion() { - throw hresult_not_implemented(); + return MIDI_MINIMUM_REQUIRED_SERVICES_VERSION_STRING; } winrt::Windows::Foundation::Uri MidiServices::LatestMidiServicesInstallUri() { - throw hresult_not_implemented(); + return Windows::Foundation::Uri(MIDI_SERVICES_INSTALL_URI_STRING); } winrt::Windows::Foundation::Collections::IVector MidiServices::GetInstalledTransports() { - throw hresult_not_implemented(); + // TODO: need to get an actual list of installed transports + + auto transports = winrt::single_threaded_vector(); + + // we need the impl type to call this constructor + com_ptr transport1 = + winrt::make_self( + L"SWD//USB/DUMMY-TRANSPORT", // Id + L"Dummy USB Transport", // Name + L"USB", // short name + L"", // icon path + L"Microsoft", // author + L"foo_usbmidi2.dll", // service plugin file name + false // is runtime creatable + ); + + // append projected instance + transports.Append(*transport1); + + + auto transport2 = winrt::make_self( + L"SWD//VIRT/DUMMY-TRANSPORT", // Id + L"Dummy Virtual Transport", // Name + L"VIRT", // short name + L"", // icon path + L"Microsoft", // author + L"foo_virt.dll", // service plugin file name + true // is runtime creatable + ); + + transports.Append(*transport2); + + + + return transports; } } diff --git a/src/app-dev-sdk/sdk-core/MidiServices.h b/src/app-dev-sdk/sdk-core/MidiServices.h index 26f44518b..152abbaac 100644 --- a/src/app-dev-sdk/sdk-core/MidiServices.h +++ b/src/app-dev-sdk/sdk-core/MidiServices.h @@ -9,18 +9,23 @@ #pragma once #include "MidiServices.g.h" +#include "MidiTransportInformation.h" + namespace winrt::Microsoft::Devices::Midi2::implementation { struct MidiServices : MidiServicesT { MidiServices() = default; - static bool CheckForWindowsMidiServices(winrt::Microsoft::Devices::Midi2::WindowsMidiServicesCheckError& errorResult); + static winrt::Microsoft::Devices::Midi2::WindowsMidiServicesCheckResult CheckForWindowsMidiServices(); static hstring GetInstalledWindowsMidiServicesVersion(); static hstring SdkVersion(); static hstring MinimumCompatibleMidiServicesVersion(); static winrt::Windows::Foundation::Uri LatestMidiServicesInstallUri(); static winrt::Windows::Foundation::Collections::IVector GetInstalledTransports(); + + private: + }; } namespace winrt::Microsoft::Devices::Midi2::factory_implementation diff --git a/src/app-dev-sdk/sdk-core/MidiServices.idl b/src/app-dev-sdk/sdk-core/MidiServices.idl index 352faf982..26dd272d3 100644 --- a/src/app-dev-sdk/sdk-core/MidiServices.idl +++ b/src/app-dev-sdk/sdk-core/MidiServices.idl @@ -10,11 +10,11 @@ import "MidiTransportInformation.idl"; namespace Microsoft.Devices.Midi2 { - // I strongly dislike the name of this enum - enum WindowsMidiServicesCheckError + enum WindowsMidiServicesCheckResult { + PresentAndUsable =0, IncompatibleVersion = 100, - NotPresent = 400 + NotPresent = 400, }; @@ -24,7 +24,7 @@ namespace Microsoft.Devices.Midi2 // Checks to see if Windows MIDI Services is running and is compatible with this SDK version // Because of how we're aligning versions, in most cases, the SDK version will be compatible, // but it's good to check and be ready in case it is not - static Boolean CheckForWindowsMidiServices(out WindowsMidiServicesCheckError errorResult); + static WindowsMidiServicesCheckResult CheckForWindowsMidiServices(); // The version of Windows MIDI Services installed on this PC static String GetInstalledWindowsMidiServicesVersion(); diff --git a/src/app-dev-sdk/sdk-core/MidiSession.cpp b/src/app-dev-sdk/sdk-core/MidiSession.cpp index 01dd87c97..d49b9ca42 100644 --- a/src/app-dev-sdk/sdk-core/MidiSession.cpp +++ b/src/app-dev-sdk/sdk-core/MidiSession.cpp @@ -10,20 +10,26 @@ #include "MidiSession.h" #include "MidiSession.g.cpp" +#include ; namespace winrt::Microsoft::Devices::Midi2::implementation { winrt::Microsoft::Devices::Midi2::MidiSession MidiSession::CreateNewSession(hstring const& sessionName, winrt::Microsoft::Devices::Midi2::MidiSessionSettings const& settings) { // TODO: Call the service to create the session + auto session = winrt::make_self(); - return winrt::make(); - + session->Open(); + return *session; + } + void MidiSession::Open() + { + _isOpen = true; } bool MidiSession::IsOpen() { - throw hresult_not_implemented(); + return _isOpen; } winrt::Windows::Foundation::Collections::IVectorView MidiSession::Connections() { @@ -39,14 +45,17 @@ namespace winrt::Microsoft::Devices::Midi2::implementation } uint64_t MidiSession::GetMidiTimestamp() { - throw hresult_not_implemented(); + return ::Microsoft::Devices::Midi2::Internal::Shared::GetCurrentMidiTimestamp(); } uint64_t MidiSession::GetMidiTimestampFrequency() { - throw hresult_not_implemented(); + return ::Microsoft::Devices::Midi2::Internal::Shared::GetMidiTimestampFrequency(); } void MidiSession::Close() { - throw hresult_not_implemented(); + // todo: need to clean up all connnections, disconnect from service, etc. + + + _isOpen = false; } } diff --git a/src/app-dev-sdk/sdk-core/MidiSession.h b/src/app-dev-sdk/sdk-core/MidiSession.h index f1dae8a19..0cb06c667 100644 --- a/src/app-dev-sdk/sdk-core/MidiSession.h +++ b/src/app-dev-sdk/sdk-core/MidiSession.h @@ -24,6 +24,12 @@ namespace winrt::Microsoft::Devices::Midi2::implementation uint64_t GetMidiTimestamp(); uint64_t GetMidiTimestampFrequency(); void Close(); + + // private to the SDK + void Open(); + + private: + bool _isOpen; }; } namespace winrt::Microsoft::Devices::Midi2::factory_implementation diff --git a/src/app-dev-sdk/sdk-core/MidiSessionSettings.cpp b/src/app-dev-sdk/sdk-core/MidiSessionSettings.cpp index 9940f662f..27c186f88 100644 --- a/src/app-dev-sdk/sdk-core/MidiSessionSettings.cpp +++ b/src/app-dev-sdk/sdk-core/MidiSessionSettings.cpp @@ -15,6 +15,8 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { winrt::Microsoft::Devices::Midi2::MidiSessionSettings MidiSessionSettings::Default() { - throw hresult_not_implemented(); + // right now, the default is just empty + + return *(winrt::make_self()); } } diff --git a/src/app-dev-sdk/sdk-core/MidiTransportInformation.cpp b/src/app-dev-sdk/sdk-core/MidiTransportInformation.cpp index 8934c593a..20a54e369 100644 --- a/src/app-dev-sdk/sdk-core/MidiTransportInformation.cpp +++ b/src/app-dev-sdk/sdk-core/MidiTransportInformation.cpp @@ -13,32 +13,53 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { + // constructor for use inside the SDK + MidiTransportInformation::MidiTransportInformation( + hstring id, + hstring name, + hstring shortName, + hstring iconPath, + hstring author, + hstring servicePluginFileName, + bool isRuntimeCreatable + ) + { + _id = id; + _name = name; + _shortName = shortName; + _iconPath = iconPath; + _author = author; + _servicePluginFileName = servicePluginFileName; + _isRuntimeCreatable = isRuntimeCreatable; + } + + hstring MidiTransportInformation::Id() { - throw hresult_not_implemented(); + return _id; } hstring MidiTransportInformation::Name() { - throw hresult_not_implemented(); + return _name; } hstring MidiTransportInformation::ShortName() { - throw hresult_not_implemented(); + return _shortName; } hstring MidiTransportInformation::IconPath() { - throw hresult_not_implemented(); + return _iconPath; } hstring MidiTransportInformation::Author() { - throw hresult_not_implemented(); + return _author; } hstring MidiTransportInformation::ServicePluginFileName() { - throw hresult_not_implemented(); + return _servicePluginFileName; } bool MidiTransportInformation::IsRuntimeCreatable() { - throw hresult_not_implemented(); + return _isRuntimeCreatable; } } diff --git a/src/app-dev-sdk/sdk-core/MidiTransportInformation.h b/src/app-dev-sdk/sdk-core/MidiTransportInformation.h index 8c7f07e0a..1deac52b6 100644 --- a/src/app-dev-sdk/sdk-core/MidiTransportInformation.h +++ b/src/app-dev-sdk/sdk-core/MidiTransportInformation.h @@ -23,5 +23,27 @@ namespace winrt::Microsoft::Devices::Midi2::implementation hstring Author(); hstring ServicePluginFileName(); bool IsRuntimeCreatable(); + + + // constructor only on the implementation type. Not part of WinRT. Used inside the SDK only. + MidiTransportInformation( + hstring id, + hstring name, + hstring shortName, + hstring iconPath, + hstring author, + hstring servicePluginFileName, + bool isRuntimeCreatable + ); + + + private: + hstring _id; + hstring _name; + hstring _shortName; + hstring _iconPath; + hstring _author; + hstring _servicePluginFileName; + bool _isRuntimeCreatable; }; } diff --git a/src/app-dev-sdk/sdk-core/MidiUmpUtilities.cpp b/src/app-dev-sdk/sdk-core/MidiUmpUtilities.cpp index b4698d2d1..cd5f9cb9f 100644 --- a/src/app-dev-sdk/sdk-core/MidiUmpUtilities.cpp +++ b/src/app-dev-sdk/sdk-core/MidiUmpUtilities.cpp @@ -12,7 +12,7 @@ #include "ump_helpers.h" -using namespace Microsoft::Devices::Midi2::Internal; +using namespace ::Microsoft::Devices::Midi2::Internal; namespace winrt::Microsoft::Devices::Midi2::implementation diff --git a/src/app-dev-sdk/sdk-core/MidiUmpWithTimestamp.cpp b/src/app-dev-sdk/sdk-core/MidiUmpWithTimestamp.cpp index f8fc24588..c6aa5b8cb 100644 --- a/src/app-dev-sdk/sdk-core/MidiUmpWithTimestamp.cpp +++ b/src/app-dev-sdk/sdk-core/MidiUmpWithTimestamp.cpp @@ -12,7 +12,7 @@ #include "ump_helpers.h" -using namespace Microsoft::Devices::Midi2::Internal; +using namespace ::Microsoft::Devices::Midi2::Internal; namespace winrt::Microsoft::Devices::Midi2::implementation { diff --git a/src/app-dev-sdk/sdk-core/midi_app_sdk_version.h b/src/app-dev-sdk/sdk-core/midi_app_sdk_version.h index 7a39ef2f8..73212c771 100644 --- a/src/app-dev-sdk/sdk-core/midi_app_sdk_version.h +++ b/src/app-dev-sdk/sdk-core/midi_app_sdk_version.h @@ -12,4 +12,7 @@ #define MIDI_APP_SDK_VERSION_STRING L"1.0.0-preview" // TODO: Need to include minimum compat API version info here? +#define MIDI_MINIMUM_REQUIRED_SERVICES_VERSION_STRING L"1.0.0" +// TODO: Change this to the actual install location +#define MIDI_SERVICES_INSTALL_URI_STRING L"https://github.com/microsoft/MIDI/releases" \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core/pch.h b/src/app-dev-sdk/sdk-core/pch.h index ae0b09751..29ec776ff 100644 --- a/src/app-dev-sdk/sdk-core/pch.h +++ b/src/app-dev-sdk/sdk-core/pch.h @@ -17,3 +17,6 @@ #include #include + + +using namespace winrt; From 4e40b3e8b6b50172b2b263adc05f55d3a9e6619f Mon Sep 17 00:00:00 2001 From: Pete Brown Date: Sun, 2 Jul 2023 01:50:14 -0400 Subject: [PATCH 3/6] Snapshot of local loopback endpoint work Not complete, but want to get it in the branch. Now has a dependency on boost (needs %BOOST_ROOT% set to your Boost 1.82 folder root.) --- .../Microsoft.Devices.Midi2.Core.vcxproj | 13 ++- .../sdk-core/MidiEndpointConnection.h | 9 ++ src/app-dev-sdk/sdk-core/MidiSession.cpp | 63 +++++++++- src/app-dev-sdk/sdk-core/MidiSession.h | 11 +- src/app-dev-sdk/sdk-core/MidiSession.idl | 3 +- .../midi_sdk_inproc_loopback_simulator.h | 110 ++++++++++++++++++ 6 files changed, 196 insertions(+), 13 deletions(-) create mode 100644 src/app-dev-sdk/sdk-core/midi_sdk_inproc_loopback_simulator.h diff --git a/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj b/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj index 7f9bf958c..1dab282e2 100644 --- a/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj +++ b/src/app-dev-sdk/sdk-core/Microsoft.Devices.Midi2.Core.vcxproj @@ -92,27 +92,27 @@ - ..\..\shared\inc;$(IncludePath) + ..\..\shared\inc;$(BOOST_ROOT);$(IncludePath) Microsoft.Devices.Midi2 - ..\..\shared\inc;$(IncludePath) + ..\..\shared\inc;$(BOOST_ROOT);$(IncludePath) Microsoft.Devices.Midi2 - ..\..\shared\inc;$(IncludePath) + ..\..\shared\inc;$(BOOST_ROOT);$(IncludePath) Microsoft.Devices.Midi2 - ..\..\shared\inc;$(IncludePath) + ..\..\shared\inc;$(BOOST_ROOT);$(IncludePath) Microsoft.Devices.Midi2 - ..\..\shared\inc;$(IncludePath) + ..\..\shared\inc;$(BOOST_ROOT);$(IncludePath) Microsoft.Devices.Midi2 - ..\..\shared\inc;$(IncludePath) + ..\..\shared\inc;$(BOOST_ROOT);$(IncludePath) Microsoft.Devices.Midi2 @@ -210,6 +210,7 @@ MidiTransportInformation.idl + MidiUmpUtilities.idl diff --git a/src/app-dev-sdk/sdk-core/MidiEndpointConnection.h b/src/app-dev-sdk/sdk-core/MidiEndpointConnection.h index 21c9f7e8d..542c13a0e 100644 --- a/src/app-dev-sdk/sdk-core/MidiEndpointConnection.h +++ b/src/app-dev-sdk/sdk-core/MidiEndpointConnection.h @@ -27,6 +27,15 @@ namespace winrt::Microsoft::Devices::Midi2::implementation winrt::Microsoft::Devices::Midi2::MidiMessageWriter GetMessageWriter(); winrt::event_token MessagesReceived(winrt::Windows::Foundation::EventHandler const& handler); void MessagesReceived(winrt::event_token const& token) noexcept; + + + // TODO: Internal constructor to spin this up with the local inproc loopback rather than an actual device + + + + private: + hstring _id; + }; } namespace winrt::Microsoft::Devices::Midi2::factory_implementation diff --git a/src/app-dev-sdk/sdk-core/MidiSession.cpp b/src/app-dev-sdk/sdk-core/MidiSession.cpp index d49b9ca42..384c2a195 100644 --- a/src/app-dev-sdk/sdk-core/MidiSession.cpp +++ b/src/app-dev-sdk/sdk-core/MidiSession.cpp @@ -10,7 +10,11 @@ #include "MidiSession.h" #include "MidiSession.g.cpp" -#include ; +#include "MidiEndpointConnection.h" +#include +#include "midi_sdk_inproc_loopback_simulator.h" + +#include namespace winrt::Microsoft::Devices::Midi2::implementation { @@ -31,13 +35,64 @@ namespace winrt::Microsoft::Devices::Midi2::implementation { return _isOpen; } - winrt::Windows::Foundation::Collections::IVectorView MidiSession::Connections() + + //winrt::Windows::Foundation::Collections::IVectorView MidiSession::Connections() + winrt::Windows::Foundation::Collections::IMapView MidiSession::Connections() { - throw hresult_not_implemented(); + return _connections.GetView(); } + + + winrt::Microsoft::Devices::Midi2::MidiEndpointConnection MidiSession::ConnectToEndpoint(hstring const& midiEndpointId, bool routeIncomingMessagesToSession, winrt::Microsoft::Devices::Midi2::MidiEndpointConnectOptions const& options) { - throw hresult_not_implemented(); + // TODO: Obviously this needs to return a real connection brokered by the service. + // Right now, it will accept any old Id just to enable testing + + + // todo: need to convert to upper and remove leading/trailing spaces + std::wstring normalizedEndpointId{ midiEndpointId }; + + boost::algorithm::to_upper(normalizedEndpointId); + boost::algorithm::trim(normalizedEndpointId); + + + + // verify we're not already connected to this. If we are, just return that connection. + if (_connections.HasKey(normalizedEndpointId)) + { + return _connections.Lookup(normalizedEndpointId); + } + + + // are we using the SDK Local loopback Ids for testing? + + if (normalizedEndpointId == MIDI_SDK_LOOPBACK_SIM1_ENDPOINT_ID || normalizedEndpointId == MIDI_SDK_LOOPBACK_SIM2_ENDPOINT_ID) + { + // this is a special case. We're using the SDK local (inproc) loopback for testing purposes + auto endpoint = winrt::make_self(); + + + + // TODO: tell the endpoint connection to spin itself up + + _connections.Insert(normalizedEndpointId, *endpoint); + + return *endpoint; + } + else + { + // normal endpoint. Call the service API, set up the connection, and get the buffers + auto endpoint = winrt::make_self(); + + // TODO: tell the endpoint connection to spin itself up + + + _connections.Insert(normalizedEndpointId, *endpoint); + + return *endpoint; + } + } void MidiSession::DisconnectFromEndpoint(hstring const& midiEndpointId) { diff --git a/src/app-dev-sdk/sdk-core/MidiSession.h b/src/app-dev-sdk/sdk-core/MidiSession.h index 0cb06c667..247cf118b 100644 --- a/src/app-dev-sdk/sdk-core/MidiSession.h +++ b/src/app-dev-sdk/sdk-core/MidiSession.h @@ -18,7 +18,8 @@ namespace winrt::Microsoft::Devices::Midi2::implementation static winrt::Microsoft::Devices::Midi2::MidiSession CreateNewSession(hstring const& sessionName, winrt::Microsoft::Devices::Midi2::MidiSessionSettings const& settings); bool IsOpen(); - winrt::Windows::Foundation::Collections::IVectorView Connections(); + //winrt::Windows::Foundation::Collections::IVectorView Connections(); + winrt::Windows::Foundation::Collections::IMapView Connections(); winrt::Microsoft::Devices::Midi2::MidiEndpointConnection ConnectToEndpoint(hstring const& midiEndpointId, bool routeIncomingMessagesToSession, winrt::Microsoft::Devices::Midi2::MidiEndpointConnectOptions const& options); void DisconnectFromEndpoint(hstring const& midiEndpointId); uint64_t GetMidiTimestamp(); @@ -30,6 +31,14 @@ namespace winrt::Microsoft::Devices::Midi2::implementation private: bool _isOpen; + + //winrt::Windows::Foundation::Collections::IVector + // _connections { winrt::single_threaded_vector() }; + + winrt::Windows::Foundation::Collections::IMap + _connections{ winrt::single_threaded_map() }; + + }; } namespace winrt::Microsoft::Devices::Midi2::factory_implementation diff --git a/src/app-dev-sdk/sdk-core/MidiSession.idl b/src/app-dev-sdk/sdk-core/MidiSession.idl index fbfe3b971..5210df439 100644 --- a/src/app-dev-sdk/sdk-core/MidiSession.idl +++ b/src/app-dev-sdk/sdk-core/MidiSession.idl @@ -29,8 +29,7 @@ namespace Microsoft.Devices.Midi2 // this really should be read-only to users of this class - //Windows.Foundation.Collections.IObservableVector Connections { get; }; - IVectorView Connections{ get; }; + IMapView Connections{ get; }; // uses the enumeration information to connect to an endpoint // adds it to the list of connected endpoints. The boolean diff --git a/src/app-dev-sdk/sdk-core/midi_sdk_inproc_loopback_simulator.h b/src/app-dev-sdk/sdk-core/midi_sdk_inproc_loopback_simulator.h new file mode 100644 index 000000000..b54bbff4e --- /dev/null +++ b/src/app-dev-sdk/sdk-core/midi_sdk_inproc_loopback_simulator.h @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License +// ============================================================================ +// This is part of the Windows MIDI Services App SDK and should be used +// in your Windows application via an official binary distribution. +// Further information: https://github.com/microsoft/MIDI/ +// ============================================================================ + +#pragma once + +#include "pch.h" +#include +#include +#include + +// the simulator is for in-SDK single app testing only. It does not use the service +// or the Windows MIDI APIs. To avoid any confusion, the Ids do not show up during +// enumeration, and must be explicitly specified. +// We use this in unit tests, but also for developers to use when developing with the +// SDK on a PC which doesn't have the rest of the MIDI Services infrastructure in place + +// these are designed to look somewhat like real Ids, just to allow for folks formatting +#define MIDI_SDK_LOOPBACK_SIM1_ENDPOINT_ID L"SWD\\MIDISDK\\MIDI_Loopback1.LOOP20" +#define MIDI_SDK_LOOPBACK_SIM2_ENDPOINT_ID L"SWD\\MIDISDK\\MIDI_Loopback2.LOOP20" + +namespace Microsoft::Devices::Midi2::Internal::Simulator +{ + // Change to use use Gary's circular buffer later so redundant code paths aren't needed + + struct MidiBuffer + { + private: + std::queue _queue = std::queue(); + + public: + MidiBuffer() {}; + + bool IsEmpty() + { + return _queue.empty(); + } + + void WriteWords(uint64_t timestamp, uint32_t* words, uint8_t wordCount) + { + // timestamp + + uint32_t h = (uint32_t)((timestamp & 0xFFFFFFFF00000000) >> 32); + uint32_t l = (uint32_t)(timestamp & 0x00000000FFFFFFFF); + + _queue.push(h); + _queue.push(l); + } + + uint32_t PeekWord() + { + return _queue.front(); + } + + uint64_t ReadTimestamp() + { + // read the next 64 bits + + if (_queue.size() >= 2) + { + uint32_t h = _queue.front(); + _queue.pop(); + + uint32_t l = _queue.front(); + _queue.pop(); + + return (uint64_t)(((uint64_t)h << 32) | l); + } + else + { + return 0; + } + } + + uint32_t ReadWord() + { + auto f = _queue.front(); + _queue.pop(); + + return f; + } + + // TODO: Needs the incoming message callback + + }; + + + class MidiSdkInProcLoopbackSimulator + { + + private: + + MidiBuffer _endpoint1OutEndpoint2In; + MidiBuffer _endpoint1InEndpoint2Out; + + // TODO: Need buffer lock objects + + public: + + + // send/receive on each side + + // signal for events + + }; +} \ No newline at end of file From 2c423a8b6f4ca7d7b02d07597b921a99b81e1dba Mon Sep 17 00:00:00 2001 From: Pete Brown Date: Sun, 2 Jul 2023 02:09:19 -0400 Subject: [PATCH 4/6] Doc updates --- .../app-developers/docs/README.md | 48 ++----------------- .../app-developers/docs/building-midi-sdk.md | 40 ++++++++++++++++ .../app-developers/docs/general-info.md | 47 ++++++++++++++++++ 3 files changed, 92 insertions(+), 43 deletions(-) create mode 100644 get-started/midi-developers/app-developers/docs/building-midi-sdk.md create mode 100644 get-started/midi-developers/app-developers/docs/general-info.md diff --git a/get-started/midi-developers/app-developers/docs/README.md b/get-started/midi-developers/app-developers/docs/README.md index 63c80e613..bebe0edd6 100644 --- a/get-started/midi-developers/app-developers/docs/README.md +++ b/get-started/midi-developers/app-developers/docs/README.md @@ -2,46 +2,8 @@ API and other documentation which will eventually be used in either the Microsoft.com docs portal, or in a github site. Format is markdown. Work on the docs has not really started. We will lean heavily on the samples to help wth explanations. -## Some basics - -The API, SDK, tools, service, drivers, and more are being developed with some guidelines about how apps could/should interact with MIDI on Windows. In no specific order or organization, here's a high-level look at what we plan to do here. In most cases, the MIDI API provides raw, and not easily used information, but the MIDI SDK provides everything an application needs to use the API in a way compatible with the MIDI Association MIDI 2.0 Implementation Guide. - -Both the MIDI API and the SDK are Windows Runtime (WinRT) components. - -* [Using WinRT Components from Desktop Applications](https://blogs.windows.com/windowsdeveloper/2019/04/30/enhancing-non-packaged-desktop-apps-using-windows-runtime-components/) - -### Enumeration - -MIDI 2.0 enumeration involves both physically connected devices discoverable through PnP, as well as in-protocol information. - -#### Enumerate UMP Endpoints - -Windows.Devices.Enumeration provides the classes required to enumerate MIDI devices, and to watch for add/removal of devices, as it. We're building upon that and use the SDK to interpret the enumerated information as well as provide additional information about the devices. - -#### Get Group Block or Function Block information for a UMP Endpoint - -Function blocks could be requested through in-protocol UMP messages. Our intent is that applications not do this themselves, but that they use an SDK call to request this information. That gives us flexibility in how we can provide this information for older devices, and also reduce the number of Function Block information request calls. - -Group Block information is provided by the USB driver, and passed through the API to the SDK. - -### Names and Formatting - -MIDI 2.0 naming of entities is more complex than it was with MIDI 1.0. Names can be sourced from different places through both enumeration and in-protocol messages. We would like to keep names consistent across applications and Windows. To that end, the SDK includes code to provide formatted, and when appropriate, localized names for entities. - -#### Format Function Block, Group Block, UMP Endpoint names - -The SDK will provide properties with this information formatted per the implementation guide. - -#### Format Group and Channel names - -The SDK has calls to enumerate Groups and Channels using data provided by MIDI 2.0 and MIDI CI. The results are formatted as per the MIDI 2.0 implementation guide and with the correct number transition (0-15 indexes changed to 1-16 for display, Channel names listed when available, Function Block names included with the group, etc.) - -### USB MIDI 2.0 UMP Endpoints - -#### Support more than one UMP Endpoint on a MIDI 2.0 USB device - -We recommend you use a separate MIDI interface for each UMP Endpoint exposed by a USB device. This makes it easier to correctly association group blocks and with the resulting UMP Endpoints. Our driver does not support multiple UMP Endpoints on a single interface. - -#### Use both Function Blocks and Group Blocks - -The MIDI Association implementation guide has information on using both function blocks and group blocks together. These need to be logically consistent and not overlap in incompatible ways. This is especially important for how macOS uses these entities, so we don't want to have them represented differently on the operating systems. +| Page | Description | +| ------------- | --------------------- | +| [consuming-midi-sdk.md](consuming-midi-sdk.md) | Information on how to use the SDK in your own apps | +| [building-midi-sdk.md](building-midi-sdk.md) | Basics on what's needed in case you want to build the SDK yourself | +| [general-info.md](general-info.md) | Some early general information about the SDK | diff --git a/get-started/midi-developers/app-developers/docs/building-midi-sdk.md b/get-started/midi-developers/app-developers/docs/building-midi-sdk.md new file mode 100644 index 000000000..15b5c8592 --- /dev/null +++ b/get-started/midi-developers/app-developers/docs/building-midi-sdk.md @@ -0,0 +1,40 @@ +# Building the MIDI SDK for yourself + +The Windows MIDI Services SDK is built using C++/WinRT. WinRT, a requirement for modern APIs on Windows, enables desktop applications, regardless of language, to be able to use APIs, SDKs, etc. that we create. The older tools, C++/CX, are arguably simpler to implement in, but because they include proprietary extensions to C++, we decided to go with standards-based C++/WinRT instead. + +Normally, you'll just one of the SDK packages. However, if you wish to build it for yourself, this document explains how. + +## Prerequisites + +To build the SDK you need to use Visual Studio 2022 and C++/WinRT + +* Visual Studio 2022 if you are using Visual Studio +* Windows SDK 10.0.20348 (Install with Visual Studio) +* Windows 10 22H2, or preferably, the latest version of Windows 11. Our development machines are all running Windows 11. +* C++ 17 (C++ 20 may work, C++ 14 will not) +* Boost 1.82 or higher installed in %BOOST_ROOT% (and that environment variable set, of course) +* C++/WinRT will be installed via NuGet + +## Folder Structure + +Here's the structure on my developer PC. + +github\microsoft\midi is the root of the repo. Inside that, the src, get-started, etc. folders from GitHub. + +github\microsoft\midi\publish is a folder that doesn't appear in the repo, but is referenced by the NuGet build. This is where the NuGet packages end up + +github\microsoft\midi\src\app-dev-sdk\_build is the build target location for SDK projects. This is where the NuGet packaging steps expect to find the binaries for packaging. + +## Building + +The midi-sdk solution is the main solution for building, well, the MIDI SDK. It includes the correct runsettings for tests, and the Directory.Build.props files for the build layout. + +For the native projects, note that 32 Bit Arm and x86 (32 bit) architectures are not supported by this project. You may build for x64, Arm64, (and in the future, Arm64EC). We are intentionally not building for 32 bit architectures here. + +NuGet packages are set to pick up only Release output, not Debug. To get it all going, do a batch build of the supported architectures. + +## Tests + +To run the Catch2 unit tests, you'll need the Catch2 Test Adapter VSIX installed. It's called "Test Adapter for Catch2" and is available in the Visual Studio Marketplace. + +Open the Test Explorer and then build the full solution if tests do not appear in it. You can then execute tests. \ No newline at end of file diff --git a/get-started/midi-developers/app-developers/docs/general-info.md b/get-started/midi-developers/app-developers/docs/general-info.md new file mode 100644 index 000000000..63c80e613 --- /dev/null +++ b/get-started/midi-developers/app-developers/docs/general-info.md @@ -0,0 +1,47 @@ +# Documentation + +API and other documentation which will eventually be used in either the Microsoft.com docs portal, or in a github site. Format is markdown. Work on the docs has not really started. We will lean heavily on the samples to help wth explanations. + +## Some basics + +The API, SDK, tools, service, drivers, and more are being developed with some guidelines about how apps could/should interact with MIDI on Windows. In no specific order or organization, here's a high-level look at what we plan to do here. In most cases, the MIDI API provides raw, and not easily used information, but the MIDI SDK provides everything an application needs to use the API in a way compatible with the MIDI Association MIDI 2.0 Implementation Guide. + +Both the MIDI API and the SDK are Windows Runtime (WinRT) components. + +* [Using WinRT Components from Desktop Applications](https://blogs.windows.com/windowsdeveloper/2019/04/30/enhancing-non-packaged-desktop-apps-using-windows-runtime-components/) + +### Enumeration + +MIDI 2.0 enumeration involves both physically connected devices discoverable through PnP, as well as in-protocol information. + +#### Enumerate UMP Endpoints + +Windows.Devices.Enumeration provides the classes required to enumerate MIDI devices, and to watch for add/removal of devices, as it. We're building upon that and use the SDK to interpret the enumerated information as well as provide additional information about the devices. + +#### Get Group Block or Function Block information for a UMP Endpoint + +Function blocks could be requested through in-protocol UMP messages. Our intent is that applications not do this themselves, but that they use an SDK call to request this information. That gives us flexibility in how we can provide this information for older devices, and also reduce the number of Function Block information request calls. + +Group Block information is provided by the USB driver, and passed through the API to the SDK. + +### Names and Formatting + +MIDI 2.0 naming of entities is more complex than it was with MIDI 1.0. Names can be sourced from different places through both enumeration and in-protocol messages. We would like to keep names consistent across applications and Windows. To that end, the SDK includes code to provide formatted, and when appropriate, localized names for entities. + +#### Format Function Block, Group Block, UMP Endpoint names + +The SDK will provide properties with this information formatted per the implementation guide. + +#### Format Group and Channel names + +The SDK has calls to enumerate Groups and Channels using data provided by MIDI 2.0 and MIDI CI. The results are formatted as per the MIDI 2.0 implementation guide and with the correct number transition (0-15 indexes changed to 1-16 for display, Channel names listed when available, Function Block names included with the group, etc.) + +### USB MIDI 2.0 UMP Endpoints + +#### Support more than one UMP Endpoint on a MIDI 2.0 USB device + +We recommend you use a separate MIDI interface for each UMP Endpoint exposed by a USB device. This makes it easier to correctly association group blocks and with the resulting UMP Endpoints. Our driver does not support multiple UMP Endpoints on a single interface. + +#### Use both Function Blocks and Group Blocks + +The MIDI Association implementation guide has information on using both function blocks and group blocks together. These need to be logically consistent and not overlap in incompatible ways. This is especially important for how macOS uses these entities, so we don't want to have them represented differently on the operating systems. From 84639d15167455ae964e89bb81c2a0c550a5dfce Mon Sep 17 00:00:00 2001 From: Pete Brown Date: Sun, 2 Jul 2023 15:10:23 -0400 Subject: [PATCH 5/6] Updated NuGet package with new targets file. Updated sdk-basics sample --- .../cpp-winrt/sdk-client-basics/main.cpp | 10 ++-- .../sdk-client-basics/packages.config | 2 +- .../sdk-client-basics.vcxproj | 14 ++--- .../nuget/Microsoft.Devices.Midi2.Core.nuspec | 9 ++-- .../nuget/Microsoft.Devices.Midi2.Core.props | 19 +++++-- .../Microsoft.Devices.Midi2.Core.targets | 52 ++++++++++++------- 6 files changed, 64 insertions(+), 42 deletions(-) diff --git a/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/main.cpp b/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/main.cpp index 6f1ccbd4a..eeff4a529 100644 --- a/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/main.cpp +++ b/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/main.cpp @@ -17,15 +17,13 @@ int main() init_apartment(); // check for presence of compatible Windows MIDI Services - - WindowsMidiServicesCheckError err; - bool servicesOk = MidiServices::CheckForWindowsMidiServices(err); + auto checkResult = MidiServices::CheckForWindowsMidiServices(); // proceed only if MIDI services is present and compatible. Your own application may decide // to fall back to WinRT/WinMM MIDI 1.0 APIs, or to prompt the user to install the latest // version of Windows MIDI Services - if (servicesOk) + if (checkResult == WindowsMidiServicesCheckResult::PresentAndUsable) { // create the MIDI session, giving us access to Windows MIDI Services. An app may open // more than one session. If so, the session name should be meaningful to the user, like @@ -88,11 +86,11 @@ int main() } else { - if (err == WindowsMidiServicesCheckError::NotPresent) + if (checkResult == WindowsMidiServicesCheckResult::NotPresent) { // allow the user to install the minimum required version } - else if (err == WindowsMidiServicesCheckError::IncompatibleVersion) + else if (checkResult == WindowsMidiServicesCheckResult::IncompatibleVersion) { // allow the user to install the minimum required version } diff --git a/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/packages.config b/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/packages.config index d1334dc57..560c91122 100644 --- a/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/packages.config +++ b/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/sdk-client-basics.vcxproj b/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/sdk-client-basics.vcxproj index 22f712e91..869464227 100644 --- a/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/sdk-client-basics.vcxproj +++ b/get-started/midi-developers/app-developers/samples/cpp-winrt/sdk-client-basics/sdk-client-basics.vcxproj @@ -1,6 +1,6 @@ - + @@ -147,16 +147,10 @@ - - - packages\Microsoft.Devices.Midi2.Core.1.0.0-preview.1-0064\runtimes\win10-x64\native\Microsoft.Devices.Midi2.winmd - true - - - + @@ -165,7 +159,7 @@ - - + + \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.nuspec b/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.nuspec index 320867efd..dddee6cfd 100644 --- a/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.nuspec +++ b/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.nuspec @@ -2,7 +2,7 @@ Microsoft.Devices.Midi2.Core - 1.0.0-preview.1-0064 + 1.0.0-preview.1-0074 Microsoft Corporation Windows MIDI Services core application SDK. Minimum package necessary to use Windows MIDI Services from an app. MIT @@ -31,8 +31,8 @@ - - + + diff --git a/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.props b/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.props index f7177cc11..14c7c6b97 100644 --- a/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.props +++ b/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.props @@ -1,13 +1,26 @@  - + + + + + + ---> \ No newline at end of file diff --git a/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.targets b/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.targets index 138935aff..3295cd2e9 100644 --- a/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.targets +++ b/src/app-dev-sdk/sdk-core-projection-cs/nuget/Microsoft.Devices.Midi2.Core.targets @@ -1,29 +1,45 @@  - - - x86 - $(Platform) - - - - - + + + + + - - - - Always - %(Filename)%(Extension) - + + + + + PreserveNewest + %(Filename)%(Extension) + + --> + + + + + + + Microsoft.Devices.Midi2.dll + + + + + + - - + + + - + + BeforeTargets="BeforeBuild;BeforeResolveReferences"> Microsoft.Devices.Midi2.dll + + + + + PreserveNewest + %(Filename)%(Extension) + + + + + + +