Skip to content

Commit

Permalink
Updated JUCE MIDI CI module with files from receivemidi
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Apr 12, 2024
1 parent 3b770a1 commit bd5476c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
9 changes: 9 additions & 0 deletions JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,15 @@ class Device::Impl : private SubscriptionManagerDelegate

device.profileHost->setProfileEnablement (profileAtAddress, enabled ? jmax (1, numChannels) : 0);
}

virtual std::vector<std::byte> profileDetailsInquired (MUID x, ProfileAtAddress profileAtAddress, std::byte target) override
{
if (auto* d = device.options.getProfileDelegate())
return d->profileDetailsInquired (x, profileAtAddress, target);

return std::vector<std::byte>();
}


private:
Impl& device;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ struct ProfileDelegate
[[maybe_unused]] ProfileAtAddress profileAtAddress,
[[maybe_unused]] int numChannels,
[[maybe_unused]] bool enabled) = 0;

virtual std::vector<std::byte> profileDetailsInquired ([[maybe_unused]] MUID x,
[[maybe_unused]] ProfileAtAddress profileAtAddress,
[[maybe_unused]] std::byte target) { return std::vector<std::byte>(); }
};

} // namespace juce::midi_ci
24 changes: 19 additions & 5 deletions JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIProfileHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,37 @@ class ProfileHost::Visitor : public detail::MessageTypeUtils::MessageVisitor

bool messageReceived (const Message::ProfileDetails& body) const
{
const auto address = ChannelAddress{}.withGroup (output->getIncomingGroup())
.withChannel (output->getIncomingHeader().deviceID);
const ProfileAtAddress profileAtAddress { body.profile, address };

if (body.target == std::byte{})
{
const auto address = ChannelAddress{}.withGroup (output->getIncomingGroup())
.withChannel (output->getIncomingHeader().deviceID);
const ProfileAtAddress profileAtAddress { body.profile, address };
const auto state = host->getState (profileAtAddress);
std::vector<std::byte> extraData;
detail::Marshalling::Writer { extraData } (state.active, state.supported);
detail::MessageTypeUtils::send (*output, Message::ProfileDetailsResponse { body.profile, body.target, extraData });
sendProfileDetailsResponse(body, extraData);
}
else
{
detail::MessageTypeUtils::sendNAK (*output, std::byte { 0x04 });
const auto extraData = host->delegate.profileDetailsInquired(output->getIncomingHeader().source, profileAtAddress, body.target);
if (extraData.empty())
{
detail::MessageTypeUtils::sendNAK (*output, std::byte { 0x04 });
}
else
{
sendProfileDetailsResponse(body, extraData);
}
}

return true;
}

void sendProfileDetailsResponse (const Message::ProfileDetails& body, const std::vector<std::byte>& extraData) const
{
detail::MessageTypeUtils::send (*output, Message::ProfileDetailsResponse { body.profile, body.target, extraData });
}

template <typename Body>
bool profileEnablementReceived (const Body& request) const
Expand Down

0 comments on commit bd5476c

Please sign in to comment.