Skip to content

Commit

Permalink
Working on virtual patchbay
Browse files Browse the repository at this point in the history
  • Loading branch information
Psychlist1972 committed Aug 5, 2024
1 parent 6232c52 commit 7672adf
Show file tree
Hide file tree
Showing 52 changed files with 936 additions and 295 deletions.
2 changes: 1 addition & 1 deletion build/staging/version/BundleInfo.wxi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Include>
<?define SetupVersionName="Developer Preview 7 x64" ?>
<?define SetupVersionNumber="1.0.24214.1322" ?>
<?define SetupVersionNumber="1.0.24215.1710" ?>
</Include>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ CMidi2VirtualPatchBayRoutingDestination::Initialize(
m_matchJson = endpointMatchJson;
m_router = router;

for (uint8_t i = 0; i < 16; i++)
{
m_groupTransformMap[i] = i;
}

return S_OK;
}

Expand Down Expand Up @@ -68,7 +73,20 @@ CMidi2VirtualPatchBayRoutingDestination::SetGroupTransforms(
std::map<uint8_t, uint8_t> groupTransformMap
)
{
UNREFERENCED_PARAMETER(groupTransformMap);
// reset all groups before applying any transform
for (uint8_t i = 0; i < 16; i++)
{
m_groupTransformMap[i] = i;
}

// apply only the transforms presented
for (auto transform : groupTransformMap)
{
if (transform.first < 16)
{
m_groupTransformMap[transform.first] = transform.second;
}
}

return S_OK;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ class CMidi2VirtualPatchBayRoutingDestination :
CMidi2VirtualPatchBayRoutingEntry* m_router;

std::wstring m_matchJson{ };
GUID m_endpointAbstractionId{ };
std::wstring m_resolvedEndpointDeviceInterfaceId{ };

wil::com_ptr_nothrow<IMidiBiDi> m_endpointBiDi{ nullptr };

// each entry in this array is the destination group. Index is the source group
// all values in this array must be valid. Multiple source groups can map to the
// same destination group, but not the other way around.
uint8_t m_groupTransformMap[16]{ };
std::array<uint8_t, 16> m_groupTransformMap{ };

};
Original file line number Diff line number Diff line change
Expand Up @@ -38,49 +38,83 @@ CMidi2VirtualPatchBayRoutingSource::Callback(
// Verify message meets criteria.

auto word0 = internal::MidiWord0FromVoidMessageDataPointer(data);
auto mt = internal::GetUmpMessageTypeFromFirstWord(word0);

// if this is a groupless message
if (internal::MessageHasGroupField(word0))
// check to see if we support this message type
if (m_includedMessageTypes[mt])
{
// if group is not in our list, return
auto groupIndex = internal::GetGroupIndexFromFirstWord(word0);

if (!m_includedGroupIndexes[groupIndex])
if (internal::MessageHasGroupField(word0))
{
return S_OK;
// if group is not in our list, return
auto groupIndex = internal::GetGroupIndexFromFirstWord(word0);

if (!m_includedGroupIndexes[groupIndex])
{
return S_OK;
}
}

RETURN_IF_FAILED(m_router->Callback(data, length, position, context));
}
else

return S_OK;
}

_Use_decl_annotations_
HRESULT
CMidi2VirtualPatchBayRoutingSource::SetIncludedGroups(
std::vector<uint8_t> groupIndexes
)
{
if (groupIndexes.size() > 0)
{
// message has no group field
if (!m_includeGrouplessMessages)
m_includedGroupIndexes = { false };

for (auto const messageType : groupIndexes)
{
return S_OK;
if (messageType < 16)
{
m_includedGroupIndexes[messageType] = true;
}
}
}

RETURN_IF_FAILED(m_router->Callback(data, length, position, context));
else
{
// if an empty set is provided, all groups are included
m_includedGroupIndexes = { true };
}

return S_OK;
}

_Use_decl_annotations_
HRESULT
CMidi2VirtualPatchBayRoutingSource::AddIncludedGroups(
std::vector<uint8_t> groupIndexes
CMidi2VirtualPatchBayRoutingSource::SetIncludedMessageTypes(
std::vector<uint8_t> messageTypes
)
{
for (auto const index : groupIndexes)
if (messageTypes.size() > 0)
{
if (index < 16)
m_includedMessageTypes = { false };

for (auto const messageType : messageTypes)
{
m_includedGroupIndexes[index] = true;
if (messageType < 16)
{
m_includedMessageTypes[messageType] = true;
}
}
}
else
{
// if an empty set is provided, all message types are included
m_includedMessageTypes = { true };
}

return S_OK;
}


_Use_decl_annotations_
HRESULT
CMidi2VirtualPatchBayRoutingSource::SetEndpointCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class CMidi2VirtualPatchBayRoutingSource :

STDMETHOD(Callback)(_In_ PVOID data, _In_ UINT length, _In_ LONGLONG position, _In_ LONGLONG context);

STDMETHOD(AddIncludedGroups)(_In_ std::vector<uint8_t> groupIndexes);
STDMETHOD(SetIncludedGroups)(_In_ std::vector<uint8_t> groupIndexes);
STDMETHOD(SetIncludedMessageTypes)(_In_ std::vector<uint8_t> messageTypes);
STDMETHOD(SetEndpointCallback)(_In_ LPCWSTR resolvedEndpointDeviceInterfaceId, _In_ IMidiCallback* sourceEndpointCallback);

STDMETHOD(Cleanup)();
Expand All @@ -29,13 +30,15 @@ class CMidi2VirtualPatchBayRoutingSource :
CMidi2VirtualPatchBayRoutingEntry* m_router;

std::wstring m_matchJson{ };
std::wstring m_resolvedEndpointDeviceInterfaceId{ };

GUID m_endpointAbstractionId{ };
std::wstring m_resolvedEndpointDeviceInterfaceId{ };

bool m_includeGrouplessMessages{ false };
// array of booleans indexed by message type. If true, the type is included
std::array<bool, 16> m_includedMessageTypes{ true };

// array of booleans. If an index is true, it is included
bool m_includedGroupIndexes[16]{ false };
std::array<bool, 16> m_includedGroupIndexes{ true };


wil::com_ptr<IMidiBiDi> m_sourceEndpointBiDi{ nullptr };
Expand Down
31 changes: 31 additions & 0 deletions src/app-sdk/MyMidiApp.exe.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,37 @@
xmlns="urn:schemas-microsoft-com:winrt.v1" />
</file>

<file name="Microsoft.Windows.Devices.Midi2.VirtualPatchBay.dll">
<activatableClass
name="Microsoft.Windows.Devices.Midi2.VirtualPatchBay.MidiVirtualPatchBayRouteCreationConfig"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
<activatableClass
name="Microsoft.Windows.Devices.Midi2.VirtualPatchBay.MidiVirtualPatchBayRouteRemovalConfig"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
<activatableClass
name="Microsoft.Windows.Devices.Midi2.VirtualPatchBay.MidiVirtualPatchBayRouteUpdateConfig"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
<activatableClass
name="Microsoft.Windows.Devices.Midi2.VirtualPatchBay.MidiVirtualPatchBayDestinationDefinition"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
<activatableClass
name="Microsoft.Windows.Devices.Midi2.VirtualPatchBay.MidiVirtualPatchBayRouteDefinition"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
<activatableClass
name="Microsoft.Windows.Devices.Midi2.VirtualPatchBay.MidiVirtualPatchBaySourceDefinition"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
<activatableClass
name="Microsoft.Windows.Devices.Midi2.VirtualPatchBay.MidiVirtualPatchBayManager"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
</file>


</assembly>

Expand Down
3 changes: 3 additions & 0 deletions src/app-sdk/app-sdk.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Windows.Devices.Midi2.Messages", "winrt-messages\Microsoft.Windows.Devices.Midi2.Messages.vcxproj", "{001601DE-B7AB-41D1-81B7-40286B139841}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Windows.Devices.Midi2.Endpoints.Loopback", "winrt-endpoint-loopback\Microsoft.Windows.Devices.Midi2.Endpoints.Loopback.vcxproj", "{D3B84D5D-8BED-4CB7-B430-B0BF1E46F3A1}"
ProjectSection(ProjectDependencies) = postProject
{001601DE-B7AB-41D1-81B7-40286B139841} = {001601DE-B7AB-41D1-81B7-40286B139841}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Windows.Devices.Midi2.Endpoints.Virtual", "winrt-endpoint-virtual\Microsoft.Windows.Devices.Midi2.Endpoints.Virtual.vcxproj", "{9B93146C-4D9D-4915-BECB-5227DF2667E2}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,38 +260,66 @@
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="MidiVirtualPatchBayManager.h">
<DependentUpon>MidiVirtualPatchBayManager.idl</DependentUpon>
<ClInclude Include="MidiVirtualPatchBayDestinationDefinition.h">
<DependentUpon>MidiVirtualPatchBayDestinationDefinition.idl</DependentUpon>
</ClInclude>
<ClInclude Include="MidiVirtualPatchBayRouteCreationConfig.h">
<DependentUpon>MidiVirtualPatchBayRouteCreationConfig.idl</DependentUpon>
<ClInclude Include="MidiVirtualPatchBayManager.h">
<DependentUpon>MidiVirtualPatchBayManager.idl</DependentUpon>
</ClInclude>
<ClInclude Include="MidiVirtualPatchBayRouteCreationConfig.h">
<DependentUpon>MidiVirtualPatchBayRouteCreationConfig.idl</DependentUpon>
</ClInclude>
<ClInclude Include="MidiVirtualPatchBayRouteDefinition.h">
<DependentUpon>MidiVirtualPatchBayRouteDefinition.idl</DependentUpon>
</ClInclude>
<ClInclude Include="MidiVirtualPatchBayRouteRemovalConfig.h">
<DependentUpon>MidiVirtualPatchBayRouteRemovalConfig.idl</DependentUpon>
<ClInclude Include="MidiVirtualPatchBayRouteRemovalConfig.h">
<DependentUpon>MidiVirtualPatchBayRouteRemovalConfig.idl</DependentUpon>
</ClInclude>
<ClInclude Include="MidiVirtualPatchBayRouteUpdateConfig.h">
<DependentUpon>MidiVirtualPatchBayRouteUpdateConfig.idl</DependentUpon>
</ClInclude>
<ClInclude Include="MidiVirtualPatchBaySourceDefinition.h">
<DependentUpon>MidiVirtualPatchBaySourceDefinition.idl</DependentUpon>
</ClInclude>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(GeneratedFilesDir)\module.g.cpp" />
<ClCompile Include="MidiVirtualPatchBayManager.cpp">
<DependentUpon>MidiVirtualPatchBayManager.idl</DependentUpon>
<ClCompile Include="MidiVirtualPatchBayDestinationDefinition.cpp">
<DependentUpon>MidiVirtualPatchBayDestinationDefinition.idl</DependentUpon>
</ClCompile>
<ClCompile Include="MidiVirtualPatchBayRouteCreationConfig.cpp">
<DependentUpon>MidiVirtualPatchBayRouteCreationConfig.idl</DependentUpon>
<ClCompile Include="MidiVirtualPatchBayManager.cpp">
<DependentUpon>MidiVirtualPatchBayManager.idl</DependentUpon>
</ClCompile>
<ClCompile Include="MidiVirtualPatchBayRouteCreationConfig.cpp">
<DependentUpon>MidiVirtualPatchBayRouteCreationConfig.idl</DependentUpon>
</ClCompile>
<ClCompile Include="MidiVirtualPatchBayRouteDefinition.cpp">
<DependentUpon>MidiVirtualPatchBayRouteDefinition.idl</DependentUpon>
</ClCompile>
<ClCompile Include="MidiVirtualPatchBayRouteRemovalConfig.cpp">
<DependentUpon>MidiVirtualPatchBayRouteRemovalConfig.idl</DependentUpon>
</ClCompile>
<ClCompile Include="MidiVirtualPatchBayRouteUpdateConfig.cpp">
<DependentUpon>MidiVirtualPatchBayRouteUpdateConfig.idl</DependentUpon>
</ClCompile>
<ClCompile Include="MidiVirtualPatchBayRouteRemovalConfig.cpp">
<DependentUpon>MidiVirtualPatchBayRouteRemovalConfig.idl</DependentUpon>
<ClCompile Include="MidiVirtualPatchBaySourceDefinition.cpp">
<DependentUpon>MidiVirtualPatchBaySourceDefinition.idl</DependentUpon>
</ClCompile>
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Midl Include="MidiVirtualPatchBayDestinationDefinition.idl" />
<Midl Include="MidiVirtualPatchBayManager.idl" />
<Midl Include="MidiVirtualPatchBayRouteCreationResult.idl" />
<Midl Include="MidiVirtualPatchBayRouteDefinition.idl" />
<Midl Include="MidiVirtualPatchBayRouteCreationConfig.idl" />
<Midl Include="MidiVirtualPatchBayRouteRemovalConfig.idl" />
<Midl Include="MidiVirtualPatchBayRouteUpdateResult.idl" />
<Midl Include="MidiVirtualPatchBaySourceDefinition.idl" />
<Midl Include="MidiVirtualPatchBayRouteUpdateConfig.idl" />
</ItemGroup>
<ItemGroup>
<None Include="midi-app-sdk.def" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
<Midl Include="MidiVirtualPatchBayRouteCreationConfig.idl">
<Filter>SDK\Configuration</Filter>
</Midl>
<Midl Include="MidiVirtualPatchBayRouteDefinition.idl">
<Filter>SDK\Configuration</Filter>
</Midl>
<Midl Include="MidiVirtualPatchBayRouteRemovalConfig.idl">
<Filter>SDK\Configuration</Filter>
</Midl>
Expand All @@ -44,6 +41,21 @@
<Midl Include="MidiVirtualPatchBayRouteCreationResult.idl">
<Filter>SDK\Management</Filter>
</Midl>
<Midl Include="MidiVirtualPatchBayDestinationDefinition.idl">
<Filter>SDK\Definitions</Filter>
</Midl>
<Midl Include="MidiVirtualPatchBaySourceDefinition.idl">
<Filter>SDK\Definitions</Filter>
</Midl>
<Midl Include="MidiVirtualPatchBayRouteUpdateConfig.idl">
<Filter>SDK\Configuration</Filter>
</Midl>
<Midl Include="MidiVirtualPatchBayRouteDefinition.idl">
<Filter>SDK\Definitions</Filter>
</Midl>
<Midl Include="MidiVirtualPatchBayRouteUpdateResult.idl">
<Filter>SDK\Management</Filter>
</Midl>
</ItemGroup>
<ItemGroup>
<None Include="midi-app-sdk.def" />
Expand All @@ -60,5 +72,8 @@
<Filter Include="SDK\Management">
<UniqueIdentifier>{656ea1ee-7afd-4546-89aa-1e2ed9d80f83}</UniqueIdentifier>
</Filter>
<Filter Include="SDK\Definitions">
<UniqueIdentifier>{1d805a69-c470-459d-be7d-59011bb9d8d9}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation and Contributors.
// 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://aka.ms/midi
// ============================================================================

#include "pch.h"
#include "MidiVirtualPatchBayDestinationDefinition.h"
#include "MidiVirtualPatchBayDestinationDefinition.g.cpp"

namespace winrt::Microsoft::Windows::Devices::Midi2::VirtualPatchBay::implementation
{


collections::IMap<midi2::MidiGroup, midi2::MidiGroup> MidiVirtualPatchBayDestinationDefinition::GroupTransformMap()
{
throw hresult_not_implemented();
}

void MidiVirtualPatchBayDestinationDefinition::GroupTransformMap(collections::IMap<midi2::MidiGroup, midi2::MidiGroup> const& value)
{
UNREFERENCED_PARAMETER(value);

throw hresult_not_implemented();
}
}
Loading

0 comments on commit 7672adf

Please sign in to comment.