Skip to content

Commit

Permalink
Merge branch 'main' into midi2merge
Browse files Browse the repository at this point in the history
  • Loading branch information
garydan42 committed Aug 5, 2024
2 parents 1bc926d + 6b1eaa6 commit d69266c
Show file tree
Hide file tree
Showing 87 changed files with 2,318 additions and 295 deletions.
3 changes: 3 additions & 0 deletions build/nuke_build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ class Build : NukeBuild
"Microsoft.Windows.Devices.Midi2.Endpoints.Loopback",
"Microsoft.Windows.Devices.Midi2.Endpoints.Virtual",
"Microsoft.Windows.Devices.Midi2.Utilities.SysEx",
"Microsoft.Windows.Devices.Midi2.VirtualPatchBay",
"Microsoft.Windows.Devices.Midi2.Initialization" // this last one gets packed 100% in the nuget, including the impl
})
{
Expand Down Expand Up @@ -540,6 +541,7 @@ void UpdateSetupBundleInfoIncludeFile(string platform)
FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.Endpoints.Loopback.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.Endpoints.Virtual.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.Utilities.SysEx.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.VirtualPatchBay.dll", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.Initialization.dll", stagingFolder, FileExistsPolicy.Overwrite, true);

FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.pri", stagingFolder, FileExistsPolicy.Overwrite, true);
Expand All @@ -550,6 +552,7 @@ void UpdateSetupBundleInfoIncludeFile(string platform)
FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.Messages.pri", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.Endpoints.Loopback.pri", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.Endpoints.Virtual.pri", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.VirtualPatchBay.pri", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.Utilities.SysEx.pri", stagingFolder, FileExistsPolicy.Overwrite, true);
FileSystemTasks.CopyFileToDirectory(runtimesFolder / "Microsoft.Windows.Devices.Midi2.Initialization.pri", stagingFolder, FileExistsPolicy.Overwrite, true);

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.24212.1326" ?>
<?define SetupVersionNumber="1.0.24215.1710" ?>
</Include>
2 changes: 1 addition & 1 deletion docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.3.2)
rexml (3.3.3)
strscan
rouge (4.2.0)
rubyzip (2.3.2)
Expand Down
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
35 changes: 35 additions & 0 deletions src/app-sdk/MyMidiApp.exe.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,43 @@
name="Microsoft.Windows.Devices.Midi2.Utilities.SysEx.MidiSystemExclusiveSender"
threadingModel="both"
xmlns="urn:schemas-microsoft-com:winrt.v1" />
<activatableClass
name="Microsoft.Windows.Devices.Midi2.Utilities.SysEx.MidiSystemExclusiveMessageHelper"
threadingModel="both"
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
22 changes: 22 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 Expand Up @@ -64,6 +67,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "midiusbinfo", "midiusbinfo\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Windows.Devices.Midi2.Utilities.SysEx", "winrt-utilities-sysex\Microsoft.Windows.Devices.Midi2.Utilities.SysEx.vcxproj", "{0D4739EF-C0D3-441C-AC25-20A55909E1DC}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Windows.Devices.Midi2.VirtualPatchBay", "winrt-virtual-patchbay\Microsoft.Windows.Devices.Midi2.VirtualPatchBay.vcxproj", "{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -348,6 +353,22 @@ Global
{0D4739EF-C0D3-441C-AC25-20A55909E1DC}.Release|ARM64EC.Build.0 = Release|ARM64EC
{0D4739EF-C0D3-441C-AC25-20A55909E1DC}.Release|x64.ActiveCfg = Release|x64
{0D4739EF-C0D3-441C-AC25-20A55909E1DC}.Release|x64.Build.0 = Release|x64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Debug|Any CPU.ActiveCfg = Debug|x64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Debug|Any CPU.Build.0 = Debug|x64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Debug|ARM64.ActiveCfg = Debug|ARM64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Debug|ARM64.Build.0 = Debug|ARM64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Debug|ARM64EC.Build.0 = Debug|ARM64EC
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Debug|x64.ActiveCfg = Debug|x64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Debug|x64.Build.0 = Debug|x64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Release|Any CPU.ActiveCfg = Release|x64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Release|Any CPU.Build.0 = Release|x64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Release|ARM64.ActiveCfg = Release|ARM64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Release|ARM64.Build.0 = Release|ARM64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Release|ARM64EC.ActiveCfg = Release|ARM64EC
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Release|ARM64EC.Build.0 = Release|ARM64EC
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Release|x64.ActiveCfg = Release|x64
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -375,6 +396,7 @@ Global
{4DABE157-7DD5-422A-8C77-B83EAC9987D0} = {900D72D2-91F0-4E6C-B694-192FD48393D2}
{0F688DE9-BE99-4A86-BE79-C5BE32BC471D} = {C8B31D71-0226-4D2D-AC78-53D5C84F472F}
{0D4739EF-C0D3-441C-AC25-20A55909E1DC} = {F5AE94B4-47A7-4D35-A9EE-65FD4CF58C4B}
{7BCB819F-CA97-4312-BF7B-1919A5CCDE69} = {F5AE94B4-47A7-4D35-A9EE-65FD4CF58C4B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AE1DF8B9-9FAB-4E20-8AC6-FF316882222F}
Expand Down
3 changes: 3 additions & 0 deletions src/app-sdk/coalesce/coalesce.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@
<ProjectReference Include="..\winrt-utilities-sysex\Microsoft.Windows.Devices.Midi2.Utilities.SysEx.vcxproj">
<Project>{0d4739ef-c0d3-441c-ac25-20a55909e1dc}</Project>
</ProjectReference>
<ProjectReference Include="..\winrt-virtual-patchbay\Microsoft.Windows.Devices.Midi2.VirtualPatchBay.vcxproj">
<Project>{7bcb819f-ca97-4312-bf7b-1919a5ccde69}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
62 changes: 62 additions & 0 deletions src/app-sdk/mididiag/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,34 @@ void OutputNumericField(_In_ std::wstring const& fieldName, _In_ uint32_t const
<< std::endl;
}

void OutputDoubleField(_In_ std::wstring const& fieldName, _In_ double const value, _In_ uint32_t precision)
{
OutputFieldLabel(fieldName);

std::wcout
<< fieldSeparator
<< std::dec
<< std::setprecision(precision)
<< value
<< std::endl;
}

void OutputDecimalMillisecondsField(_In_ std::wstring const& fieldName, _In_ double const value, _In_ uint32_t precision)
{
OutputFieldLabel(fieldName);

std::wcout
<< fieldSeparator
<< std::dec
<< std::setprecision(precision)
<< std::fixed
<< value
<< " ms"
<< std::endl;
}



void OutputHexNumericField(_In_ std::wstring const& fieldName, _In_ uint32_t const value)
{
OutputFieldLabel(fieldName);
Expand Down Expand Up @@ -519,6 +547,40 @@ bool DoSectionSystemInfo(_In_ bool verbose)
::GetNativeSystemInfo(&sysinfoNative);
OutputSystemInfo(sysinfoNative);

TIMECAPS timecaps;
auto tcresult = ::timeGetDevCaps(&timecaps, sizeof(timecaps));

OutputBlankLine();

if (tcresult == MMSYSERR_NOERROR)
{
OutputNumericField(MIDIDIAG_FIELD_LABEL_SYSTEM_INFO_TIMECAPS_MIN_PERIOD, timecaps.wPeriodMin);
OutputNumericField(MIDIDIAG_FIELD_LABEL_SYSTEM_INFO_TIMECAPS_MAX_PERIOD, timecaps.wPeriodMax);
}
else
{
OutputStringField(MIDIDIAG_FIELD_LABEL_SYSTEM_INFO_TIMECAPS_ERROR, std::wstring{ L"Could not get timecaps" });
}

ULONG minResolution;
ULONG maxResolution;
ULONG actualResolution;

auto resresult = NtQueryTimerResolution(&maxResolution, &minResolution, &actualResolution);

if (resresult == STATUS_SUCCESS)
{
double minResolutionMilliseconds = (double)minResolution / 10000.0; // minResolution is in 100 nanosecond units
double maxResolutionMilliseconds = (double)maxResolution / 10000.0; // maxResolution is in 100 nanosecond units
double actualResolutionMilliseconds = (double)actualResolution / 10000.0; // actualResolution is in 100 nanosecond units

// results here are in 100ns units
OutputBlankLine();
OutputDecimalMillisecondsField(MIDIDIAG_FIELD_LABEL_SYSTEM_INFO_TIMER_RESOLUTION_MIN_MS, minResolutionMilliseconds, 3);
OutputDecimalMillisecondsField(MIDIDIAG_FIELD_LABEL_SYSTEM_INFO_TIMER_RESOLUTION_MAX_MS, maxResolutionMilliseconds, 3);
OutputDecimalMillisecondsField(MIDIDIAG_FIELD_LABEL_SYSTEM_INFO_TIMER_RESOLUTION_CURRENT_MS, actualResolutionMilliseconds, 3);
}

return true;
}

Expand Down
Loading

0 comments on commit d69266c

Please sign in to comment.