Skip to content

Commit

Permalink
Merge pull request #217 from microsoft/pete-dev
Browse files Browse the repository at this point in the history
Update Main with WinRT MIDI 1.0 shim work, plus a couple other tweaks
  • Loading branch information
Psychlist1972 authored Jan 15, 2024
2 parents 5ac9fbe + cfc761a commit b56dd59
Show file tree
Hide file tree
Showing 53 changed files with 770 additions and 383 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 4" ?>
<?define SetupVersionNumber="1.0.24014.2024" ?>
<?define SetupVersionNumber="1.0.24014.2122" ?>
</Include>
2 changes: 1 addition & 1 deletion get-started/midi-users/docs/config-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Valid properties you can set across all supported endpoints
| -------- | ---- | ----------- |
| `userSuppliedName` | Quoted Text | The name you want to use for the endpoint. This will override the name displayed in correctly-coded applications, but won't necessarily change what you see in Device Manager. These names should be relatively short so they display fully in all/most applications, but meaningful to you. |
| `userSuppliedDescription` | Quoted Text | A text description and/or notes about the endpoint. Applications may or may not use this data |
| `forceSingleClientOnly` | Boolean true/false (no quotes) | Most endpoints are multi-client (more than one applicatation can use them simultaneously) by default. This is for forcing an endpoint to be single-client only (true). It's unusual to need this, but a typical use may be to disable multi-client for a device which has a custom driver which doesn't gracefully handle multiple client applications at the same time. |
| `forceSingleClientOnly` | Boolean true/false (no quotes) | Most endpoints are multi-client (more than one application can use them simultaneously) by default. This setting is for forcing an endpoint to be single-client only (a value of true). It's unusual to need this, but a typical use may be to disable multi-client for a device which has a custom driver which doesn't gracefully handle multiple client applications at the same time. |

## Plugin-specific settings

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ CMidi2KSMidiEndpointManager::ApplyUserConfiguration(std::wstring deviceInterface

winrt::hstring endpointSettingsKey = winrt::to_hstring(MIDI_CONFIG_JSON_ENDPOINT_IDENTIFIER_SWD) + deviceInterfaceId;

OutputDebugString(L"\n" __FUNCTION__ L" Key: ");
OutputDebugString(endpointSettingsKey.c_str());
OutputDebugString(L"\n");
//OutputDebugString(L"\n" __FUNCTION__ L" Key: ");
//OutputDebugString(endpointSettingsKey.c_str());
//OutputDebugString(L"\n");


if (m_jsonObject.HasKey(endpointSettingsKey))
Expand Down
22 changes: 22 additions & 0 deletions src/api/Client/Midi2Client/MidiEndpointDeviceInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,28 @@ namespace winrt::Windows::Devices::Midi2::implementation
}
}

_Use_decl_annotations_
winrt::hstring MidiEndpointDeviceInformation::GetGuidPropertyAsString(
winrt::hstring key,
winrt::hstring defaultValue) const noexcept
{
if (!m_properties.HasKey(key)) return defaultValue;

try
{
auto guid = winrt::unbox_value<winrt::guid>(m_properties.Lookup(key));

auto s = GuidToString(guid);

return winrt::hstring(s);

}
catch (...)
{
return defaultValue;
}
}


_Use_decl_annotations_
uint8_t MidiEndpointDeviceInformation::GetByteProperty(
Expand Down
6 changes: 5 additions & 1 deletion src/api/Client/Midi2Client/MidiEndpointDeviceInformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace winrt::Windows::Devices::Midi2::implementation
winrt::hstring EndpointSuppliedName() const noexcept { return GetStringProperty(STRING_PKEY_MIDI_EndpointProvidedName, L""); }
winrt::hstring UserSuppliedName() const noexcept { return GetStringProperty(STRING_PKEY_MIDI_UserSuppliedEndpointName, L""); }

winrt::hstring TransportId() const noexcept { return GetStringProperty(STRING_PKEY_MIDI_AbstractionLayer, L""); }
winrt::hstring TransportId() const noexcept { return GetGuidPropertyAsString(STRING_PKEY_MIDI_AbstractionLayer, L""); }
winrt::hstring TransportMnemonic() const noexcept { return GetStringProperty(STRING_PKEY_MIDI_TransportMnemonic, L""); }

winrt::hstring TransportSuppliedSerialNumber() const noexcept { return GetStringProperty(STRING_PKEY_MIDI_SerialNumber, L"");}
Expand Down Expand Up @@ -133,6 +133,10 @@ namespace winrt::Windows::Devices::Midi2::implementation
_In_ winrt::hstring key,
_In_ winrt::guid defaultValue) const noexcept;

winrt::hstring GetGuidPropertyAsString(
_In_ winrt::hstring key,
_In_ winrt::hstring defaultValue) const noexcept;


uint8_t GetByteProperty(
_In_ winrt::hstring key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,10 @@

namespace winrt::MIDI_ROOT_NAMESPACE_CPP::implementation
{
winrt::Windows::Foundation::TimeSpan MidiActiveSensingMessage::Timestamp()
{
throw hresult_not_implemented();
}
midi1::MidiMessageType MidiActiveSensingMessage::Type()
{
throw hresult_not_implemented();
}

// TODO: Need to implement this and any methods required to populate it
streams::IBuffer MidiActiveSensingMessage::RawData()
{
throw hresult_not_implemented();
return nullptr;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ namespace winrt::MIDI_ROOT_NAMESPACE_CPP::implementation
{
MidiActiveSensingMessage() = default;

foundation::TimeSpan Timestamp();
midi1::MidiMessageType Type();
foundation::TimeSpan Timestamp() { return m_timestamp; }
midi1::MidiMessageType Type() { return m_type; }
streams::IBuffer RawData();

private:
foundation::TimeSpan m_timestamp{};
midi1::MidiMessageType m_type{ midi1::MidiMessageType::None };

};
}
namespace winrt::MIDI_ROOT_NAMESPACE_CPP::factory_implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,10 @@ namespace winrt::MIDI_ROOT_NAMESPACE_CPP::implementation
throw hresult_not_implemented();
}

uint8_t MidiChannelPressureMessage::Channel()
{
throw hresult_not_implemented();
}
uint8_t MidiChannelPressureMessage::Pressure()
{
throw hresult_not_implemented();
}
foundation::TimeSpan MidiChannelPressureMessage::Timestamp()
{
throw hresult_not_implemented();
}
midi1::MidiMessageType MidiChannelPressureMessage::Type()
{
throw hresult_not_implemented();
}

// TODO: Need to implement this and any methods required to populate it
streams::IBuffer MidiChannelPressureMessage::RawData()
{
throw hresult_not_implemented();
return nullptr;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@ namespace winrt::MIDI_ROOT_NAMESPACE_CPP::implementation
struct MidiChannelPressureMessage : MidiChannelPressureMessageT<MidiChannelPressureMessage>
{
MidiChannelPressureMessage() = default;

MidiChannelPressureMessage(_In_ uint8_t channel, _In_ uint8_t pressure);
uint8_t Channel();
uint8_t Pressure();

foundation::TimeSpan Timestamp();
midi1::MidiMessageType Type();
uint8_t Channel() { return m_channel; }
uint8_t Pressure() { return m_pressure; }

foundation::TimeSpan Timestamp() { return m_timestamp; }
midi1::MidiMessageType Type() { return m_type; }
streams::IBuffer RawData();

private:
foundation::TimeSpan m_timestamp{};
midi1::MidiMessageType m_type{ midi1::MidiMessageType::None };

uint8_t m_channel{};
uint8_t m_pressure{};
};
}
namespace winrt::MIDI_ROOT_NAMESPACE_CPP::factory_implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,9 @@

namespace winrt::MIDI_ROOT_NAMESPACE_CPP::implementation
{
foundation::TimeSpan MidiContinueMessage::Timestamp()
{
throw hresult_not_implemented();
}
midi1::MidiMessageType MidiContinueMessage::Type()
{
throw hresult_not_implemented();
}
// TODO: Need to implement this and any methods required to populate it
streams::IBuffer MidiContinueMessage::RawData()
{
throw hresult_not_implemented();
return nullptr;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ namespace winrt::MIDI_ROOT_NAMESPACE_CPP::implementation
{
MidiContinueMessage() = default;

foundation::TimeSpan Timestamp();
midi1::MidiMessageType Type();
foundation::TimeSpan Timestamp() { return m_timestamp; }
midi1::MidiMessageType Type() { return m_type; }
streams::IBuffer RawData();

private:
foundation::TimeSpan m_timestamp{};
midi1::MidiMessageType m_type{};
};
}
namespace winrt::MIDI_ROOT_NAMESPACE_CPP::factory_implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,9 @@ namespace winrt::MIDI_ROOT_NAMESPACE_CPP::implementation
throw hresult_not_implemented();
}

uint8_t MidiControlChangeMessage::Channel()
{
throw hresult_not_implemented();
}
uint8_t MidiControlChangeMessage::Controller()
{
throw hresult_not_implemented();
}
uint8_t MidiControlChangeMessage::ControlValue()
{
throw hresult_not_implemented();
}
foundation::TimeSpan MidiControlChangeMessage::Timestamp()
{
throw hresult_not_implemented();
}
midi1::MidiMessageType MidiControlChangeMessage::Type()
{
throw hresult_not_implemented();
}
// TODO: Need to implement this and any methods required to populate it
streams::IBuffer MidiControlChangeMessage::RawData()
{
throw hresult_not_implemented();
return nullptr;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,24 @@ namespace winrt::MIDI_ROOT_NAMESPACE_CPP::implementation
struct MidiControlChangeMessage : MidiControlChangeMessageT<MidiControlChangeMessage>
{
MidiControlChangeMessage() = default;

MidiControlChangeMessage(_In_ uint8_t channel, _In_ uint8_t controller, _In_ uint8_t controlValue);
uint8_t Channel();
uint8_t Controller();
uint8_t ControlValue();

foundation::TimeSpan Timestamp();
midi1::MidiMessageType Type();
uint8_t Channel() { return m_channel; }
uint8_t Controller() { return m_controller; }
uint8_t ControlValue() { return m_controlValue; }


foundation::TimeSpan Timestamp() { return m_timestamp; }
midi1::MidiMessageType Type() { return m_type; }
streams::IBuffer RawData();

private:
foundation::TimeSpan m_timestamp{};
midi1::MidiMessageType m_type{ midi1::MidiMessageType::None };

uint8_t m_channel{};
uint8_t m_controller{};
uint8_t m_controlValue{};
};
}
namespace winrt::MIDI_ROOT_NAMESPACE_CPP::factory_implementation
Expand Down
22 changes: 22 additions & 0 deletions src/api/Client/MidiRT/Windows.Devices.Midi.Shim/MidiInPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@

namespace winrt::MIDI_ROOT_NAMESPACE_CPP::implementation
{
_Use_decl_annotations_
foundation::IAsyncOperation<midi1::MidiInPort> MidiInPort::FromIdAsync(winrt::hstring deviceId)
{

}

winrt::hstring MidiInPort::GetDeviceSelector()
{
// TODO
return winrt::hstring{};
}

_Use_decl_annotations_
HRESULT MidiInPort::Callback(PVOID data, UINT size, LONGLONG timestamp, LONGLONG context)
{
UNREFERENCED_PARAMETER(data);
UNREFERENCED_PARAMETER(size);
UNREFERENCED_PARAMETER(timestamp);
UNREFERENCED_PARAMETER(context);
}


hstring MidiInPort::DeviceId()
{
throw hresult_not_implemented();
Expand Down
24 changes: 22 additions & 2 deletions src/api/Client/MidiRT/Windows.Devices.Midi.Shim/MidiInPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,33 @@

namespace winrt::MIDI_ROOT_NAMESPACE_CPP::implementation
{
struct MidiInPort : MidiInPortT<MidiInPort>
struct MidiInPort : MidiInPortT<MidiInPort, IMidiCallback>
{
public:
MidiInPort() = default;

hstring DeviceId();
static foundation::IAsyncOperation<midi1::MidiInPort> FromIdAsync(_In_ winrt::hstring deviceId);
static winrt::hstring GetDeviceSelector();

winrt::hstring DeviceId();

winrt::event_token MessageReceived(_In_ foundation::TypedEventHandler<midi1::MidiInPort, midi1::MidiMessageReceivedEventArgs> const& handler);
void MessageReceived(_In_ winrt::event_token const& token) noexcept;

void Close();


STDMETHOD(Callback)(_In_ PVOID data, _In_ UINT size, _In_ LONGLONG timestamp, _In_ LONGLONG context) override;

private:


};
}

namespace winrt::MIDI_ROOT_NAMESPACE_CPP::factory_implementation
{
struct MidiInPort : MidiInPortT<MidiInPort, implementation::MidiInPort>
{
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ namespace MIDI_ROOT_NAMESPACE_IDL
[static_name(MIDI_MIDL_INTERFACE_NAME(IMidiInPortStatics), 44C439DC-67FF-4A6E-8BAC-FDB6610CF296)]
runtimeclass MidiInPort : Windows.Foundation.IClosable
{
static Windows.Foundation.IAsyncOperation<MidiInPort> FromIdAsync(String deviceId);
static String GetDeviceSelector();


String DeviceId{ get; };

event Windows.Foundation.TypedEventHandler<MidiInPort, MidiMessageReceivedEventArgs> MessageReceived;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,11 @@ namespace winrt::MIDI_ROOT_NAMESPACE_CPP::implementation
{
throw hresult_not_implemented();
}
uint8_t MidiNoteOffMessage::Channel()
{
throw hresult_not_implemented();
}
uint8_t MidiNoteOffMessage::Note()
{
throw hresult_not_implemented();
}
uint8_t MidiNoteOffMessage::Velocity()
{
throw hresult_not_implemented();
}
foundation::TimeSpan MidiNoteOffMessage::Timestamp()
{
throw hresult_not_implemented();
}
midi1::MidiMessageType MidiNoteOffMessage::Type()
{
throw hresult_not_implemented();
}


// TODO: Need to implement this and any methods required to populate it
streams::IBuffer MidiNoteOffMessage::RawData()
{
throw hresult_not_implemented();
return nullptr;
}

}
Loading

0 comments on commit b56dd59

Please sign in to comment.