Skip to content

Commit

Permalink
API tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Psychlist1972 committed Mar 7, 2024
1 parent 4891953 commit 6cd9fe0
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/api/Client/Midi2Client/IMidiUniversalPacket.idl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ namespace Windows.Devices.Midi2


IVector<UInt32> GetAllWords();
UInt8 AppendAllMessageWordsToVector(IVector<UInt32> targetVector);
UInt8 AppendAllMessageWordsToList(IVector<UInt32> targetList);

UInt8 AddAllMessageBytesToBuffer(UInt32 byteOffset, Windows.Foundation.IMemoryBuffer buffer);
UInt8 FillBuffer(UInt32 byteOffset, Windows.Foundation.IMemoryBuffer buffer);
};
}
18 changes: 15 additions & 3 deletions src/api/Client/Midi2Client/MidiEndpointDeviceInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,22 @@ namespace winrt::Windows::Devices::Midi2::implementation
additionalProperties.Append(STRING_PKEY_MIDI_TransportMnemonic);

additionalProperties.Append(STRING_PKEY_MIDI_NativeDataFormat);
additionalProperties.Append(STRING_PKEY_MIDI_SupportsMulticlient);
additionalProperties.Append(STRING_PKEY_MIDI_SupportedDataFormats);

additionalProperties.Append(STRING_PKEY_MIDI_ManufacturerName);
additionalProperties.Append(STRING_PKEY_MIDI_GenerateIncomingTimestamp);

additionalProperties.Append(STRING_PKEY_MIDI_TransportSuppliedEndpointName);
additionalProperties.Append(STRING_PKEY_MIDI_TransportSuppliedDescription);

additionalProperties.Append(STRING_PKEY_MIDI_SupportsMulticlient);
additionalProperties.Append(STRING_PKEY_MIDI_GenerateIncomingTimestamp);


// USB / KS Properties ===============================================================
// TODO: Group Terminal Blocks will likely be a single property
additionalProperties.Append(STRING_PKEY_MIDI_IN_GroupTerminalBlocks);
additionalProperties.Append(STRING_PKEY_MIDI_OUT_GroupTerminalBlocks);
additionalProperties.Append(STRING_PKEY_MIDI_AssociatedUMP);
additionalProperties.Append(STRING_PKEY_MIDI_ManufacturerName);
additionalProperties.Append(STRING_PKEY_MIDI_SerialNumber);
additionalProperties.Append(STRING_PKEY_MIDI_UsbVID);
additionalProperties.Append(STRING_PKEY_MIDI_UsbPID);
Expand All @@ -135,13 +137,16 @@ namespace winrt::Windows::Devices::Midi2::implementation
// Major Known Endpoint Types ========================================================
additionalProperties.Append(STRING_PKEY_MIDI_EndpointDevicePurpose);

additionalProperties.Append(STRING_PKEY_MIDI_EndpointRequiresMetadataHandler);

// In-protocol Endpoint information ==================================================
additionalProperties.Append(STRING_PKEY_MIDI_EndpointSupportsMidi2Protocol);
additionalProperties.Append(STRING_PKEY_MIDI_EndpointSupportsMidi1Protocol);
additionalProperties.Append(STRING_PKEY_MIDI_EndpointSupportsReceivingJRTimestamps);
additionalProperties.Append(STRING_PKEY_MIDI_EndpointSupportsSendingJRTimestamps);
additionalProperties.Append(STRING_PKEY_MIDI_EndpointUmpVersionMajor);
additionalProperties.Append(STRING_PKEY_MIDI_EndpointUmpVersionMinor);

additionalProperties.Append(STRING_PKEY_MIDI_EndpointProvidedName);
additionalProperties.Append(STRING_PKEY_MIDI_EndpointProvidedProductInstanceId);
additionalProperties.Append(STRING_PKEY_MIDI_DeviceIdentity);
Expand Down Expand Up @@ -176,6 +181,13 @@ namespace winrt::Windows::Devices::Midi2::implementation
additionalProperties.Append(STRING_PKEY_MIDI_FunctionBlocksLastUpdateTime);


additionalProperties.Append(STRING_PKEY_MIDI_MidiOutCalculatedLatencyTicks);
additionalProperties.Append(STRING_PKEY_MIDI_MidiOutUserSuppliedLatencyTicks);
additionalProperties.Append(STRING_PKEY_MIDI_MidiOutLatencyTicksUserOverride);


additionalProperties.Append(STRING_PKEY_MIDI_VirtualMidiEndpointAssociator);


// Calculated metrics =================================================================
// we don't load them here because they would spam device information update events
Expand Down
3 changes: 0 additions & 3 deletions src/api/Client/Midi2Client/MidiEndpointDeviceInformation.idl
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ namespace Windows.Devices.Midi2






// The settings app allows the user to add some metadata, like a description
String UserSuppliedName{ get; }; // name supplied by the user, if available
String UserSuppliedDescription{ get; };
Expand Down
4 changes: 2 additions & 2 deletions src/api/Client/Midi2Client/MidiMessage128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace winrt::Windows::Devices::Midi2::implementation
}

_Use_decl_annotations_
uint8_t MidiMessage128::AppendAllMessageWordsToVector(collections::IVector<uint32_t> targetVector) const noexcept
uint8_t MidiMessage128::AppendAllMessageWordsToList(collections::IVector<uint32_t> targetVector) const noexcept
{
targetVector.Append(m_ump.word0);
targetVector.Append(m_ump.word1);
Expand All @@ -36,7 +36,7 @@ namespace winrt::Windows::Devices::Midi2::implementation
}

_Use_decl_annotations_
uint8_t MidiMessage128::AddAllMessageBytesToBuffer(uint32_t const byteOffset, foundation::IMemoryBuffer const& buffer) const noexcept
uint8_t MidiMessage128::FillBuffer(uint32_t const byteOffset, foundation::IMemoryBuffer const& buffer) const noexcept
{
const uint8_t numWordsInPacket = 4;
const uint8_t numBytesInPacket = numWordsInPacket * sizeof(uint32_t);
Expand Down
4 changes: 2 additions & 2 deletions src/api/Client/Midi2Client/MidiMessage128.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ namespace winrt::Windows::Devices::Midi2::implementation


collections::IVector<uint32_t> GetAllWords() const noexcept;
uint8_t AppendAllMessageWordsToVector(
uint8_t AppendAllMessageWordsToList(
_Inout_ collections::IVector<uint32_t> targetVector) const noexcept;

uint8_t AddAllMessageBytesToBuffer(
uint8_t FillBuffer(
_In_ uint32_t const byteOffset,
_In_ foundation::IMemoryBuffer const& buffer
) const noexcept;
Expand Down
4 changes: 2 additions & 2 deletions src/api/Client/Midi2Client/MidiMessage32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ namespace winrt::Windows::Devices::Midi2::implementation
}

_Use_decl_annotations_
uint8_t MidiMessage32::AppendAllMessageWordsToVector(collections::IVector<uint32_t> targetVector) const noexcept
uint8_t MidiMessage32::AppendAllMessageWordsToList(collections::IVector<uint32_t> targetVector) const noexcept
{
targetVector.Append(m_ump.word0);

return 1;
}

_Use_decl_annotations_
uint8_t MidiMessage32::AddAllMessageBytesToBuffer(uint32_t const byteOffset, foundation::IMemoryBuffer const& buffer) const noexcept
uint8_t MidiMessage32::FillBuffer(uint32_t const byteOffset, foundation::IMemoryBuffer const& buffer) const noexcept
{
const uint8_t numWordsInPacket = 2;
const uint8_t numBytesInPacket = numWordsInPacket * sizeof(uint32_t);
Expand Down
4 changes: 2 additions & 2 deletions src/api/Client/Midi2Client/MidiMessage32.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ namespace winrt::Windows::Devices::Midi2::implementation
uint32_t PeekFirstWord() { return Word0(); }

collections::IVector<uint32_t> GetAllWords() const noexcept;
uint8_t AppendAllMessageWordsToVector(
uint8_t AppendAllMessageWordsToList(
_Inout_ collections::IVector<uint32_t> targetVector
) const noexcept;

uint8_t AddAllMessageBytesToBuffer(
uint8_t FillBuffer(
_In_ uint32_t const byteOffset,
_In_ foundation::IMemoryBuffer const& buffer
) const noexcept;
Expand Down
4 changes: 2 additions & 2 deletions src/api/Client/Midi2Client/MidiMessage64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace winrt::Windows::Devices::Midi2::implementation
}

_Use_decl_annotations_
uint8_t MidiMessage64::AppendAllMessageWordsToVector(collections::IVector<uint32_t> targetVector) const noexcept
uint8_t MidiMessage64::AppendAllMessageWordsToList(collections::IVector<uint32_t> targetVector) const noexcept
{
targetVector.Append(m_ump.word0);
targetVector.Append(m_ump.word1);
Expand All @@ -33,7 +33,7 @@ namespace winrt::Windows::Devices::Midi2::implementation
}

_Use_decl_annotations_
uint8_t MidiMessage64::AddAllMessageBytesToBuffer(uint32_t const byteOffset, foundation::IMemoryBuffer const& buffer) const noexcept
uint8_t MidiMessage64::FillBuffer(uint32_t const byteOffset, foundation::IMemoryBuffer const& buffer) const noexcept
{
const uint8_t numWordsInPacket = 2;
const uint8_t numBytesInPacket = numWordsInPacket * sizeof(uint32_t);
Expand Down
4 changes: 2 additions & 2 deletions src/api/Client/Midi2Client/MidiMessage64.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ namespace winrt::Windows::Devices::Midi2::implementation
winrt::hstring ToString();

collections::IVector<uint32_t> GetAllWords() const noexcept;
uint8_t AppendAllMessageWordsToVector(
uint8_t AppendAllMessageWordsToList(
_Inout_ collections::IVector<uint32_t> targetVector) const noexcept;

uint8_t AddAllMessageBytesToBuffer(
uint8_t FillBuffer(
_In_ uint32_t const byteOffset,
_In_ foundation::IMemoryBuffer const& buffer
) const noexcept;
Expand Down
4 changes: 2 additions & 2 deletions src/api/Client/Midi2Client/MidiMessage96.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace winrt::Windows::Devices::Midi2::implementation
}

_Use_decl_annotations_
uint8_t MidiMessage96::AppendAllMessageWordsToVector(collections::IVector<uint32_t> targetVector) const noexcept
uint8_t MidiMessage96::AppendAllMessageWordsToList(collections::IVector<uint32_t> targetVector) const noexcept
{
targetVector.Append(m_ump.word0);
targetVector.Append(m_ump.word1);
Expand All @@ -35,7 +35,7 @@ namespace winrt::Windows::Devices::Midi2::implementation


_Use_decl_annotations_
uint8_t MidiMessage96::AddAllMessageBytesToBuffer(uint32_t const byteOffset, foundation::IMemoryBuffer const& buffer) const noexcept
uint8_t MidiMessage96::FillBuffer(uint32_t const byteOffset, foundation::IMemoryBuffer const& buffer) const noexcept
{
const uint8_t numWordsInPacket = 3;
const uint8_t numBytesInPacket = numWordsInPacket * sizeof(uint32_t);
Expand Down
4 changes: 2 additions & 2 deletions src/api/Client/Midi2Client/MidiMessage96.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ namespace winrt::Windows::Devices::Midi2::implementation
{ return midi2::MidiPacketType::UniversalMidiPacket96; }

collections::IVector<uint32_t> GetAllWords() const noexcept;
uint8_t AppendAllMessageWordsToVector(
uint8_t AppendAllMessageWordsToList(
_Inout_ collections::IVector<uint32_t> targetVector) const noexcept;

uint8_t AddAllMessageBytesToBuffer(
uint8_t FillBuffer(
_In_ uint32_t const byteOffset,
_In_ foundation::IMemoryBuffer const& buffer
) const noexcept;
Expand Down
20 changes: 20 additions & 0 deletions src/api/Client/Midi2Client/MidiMessageReceivedEventArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,26 @@ namespace winrt::Windows::Devices::Midi2::implementation
return messageWordCount;
}

_Use_decl_annotations_
uint8_t MidiMessageReceivedEventArgs::AppendWordsToList(
collections::IVector<uint32_t> wordList
)
{
uint8_t messageWordCount = GetValidMessageWordCount();

// copy over the words

uint32_t* umpData = (uint32_t*)&m_data;

for (int i = 0; i < messageWordCount; i++)
{
wordList.Append(umpData[i]);
}

return messageWordCount;
}


_Use_decl_annotations_
uint8_t MidiMessageReceivedEventArgs::FillByteArray(
uint32_t const startIndex,
Expand Down
4 changes: 4 additions & 0 deletions src/api/Client/Midi2Client/MidiMessageReceivedEventArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ namespace winrt::Windows::Devices::Midi2::implementation
_In_ foundation::IMemoryBuffer const& buffer
);

uint8_t AppendWordsToList(
_In_ collections::IVector<uint32_t> wordList
);

private:
uint8_t GetValidMessageWordCount() { return internal::GetUmpLengthInMidiWordsFromFirstWord(m_data.Word0); }

Expand Down
3 changes: 3 additions & 0 deletions src/api/Client/Midi2Client/MidiMessageReceivedEventArgs.idl
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@ namespace Windows.Devices.Midi2
// Fill a spot in an existing IMemoryBuffer controlled by the caller. Returns the number of BYTES written
UInt8 FillBuffer(UInt32 byteOffset, Windows.Foundation.IMemoryBuffer buffer);

// Adds the message words to the end of the provided list, and returns the number of words added.
UInt8 AppendWordsToList(IVector<UInt32> wordList);

}
}
2 changes: 1 addition & 1 deletion src/api/Client/Midi2Client/MidiMessageUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace winrt::Windows::Devices::Midi2::implementation

for (auto const& message : messages)
{
message.AppendAllMessageWordsToVector(result);
message.AppendAllMessageWordsToList(result);
}

return result;
Expand Down

0 comments on commit 6cd9fe0

Please sign in to comment.