Skip to content

Commit

Permalink
Fixed channels and profiles that are reported through profile inquiry
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Apr 11, 2024
1 parent d07812b commit fa9f76c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
36 changes: 29 additions & 7 deletions Source/MpeProfileNegotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,30 @@ MpeProfileNegotiation::MpeProfileNegotiation()
.withOutputs({ this })
.withProfileDelegate(this));
ci_->addListener(*this);
}

// support the MPE Profile on any channel as the manager channel, except on channel 16
// we support all the possible channels upwards from the manager channel
void MpeProfileNegotiation::setProfileMidiName(const String& name)
{
// remove all registered profiles
for (int ch = 0x0; ch <= 0xE; ++ch)
{
auto max_channels = 0xF - ch + 1;
ci_->getProfileHost()->addProfile({ MPE_PROFILE, ci::ChannelAddress().withChannel((ci::ChannelInGroup)ch) }, max_channels);
ci_->getProfileHost()->removeProfile({ MPE_PROFILE, ci::ChannelAddress().withChannel((ci::ChannelInGroup)ch) });
}

// register profiles for all active manager channels
if (manager_ == 0)
{
// support the MPE Profile on any channel as the manager channel, except on channel 16
for (int ch = 0x0; ch <= 0xE; ++ch)
{
addMpeProfile(ch);
}
}
else if (manager_ > 0)
{
addMpeProfile(manager_ - 1);
}
}

void MpeProfileNegotiation::setProfileMidiName(const String& name)
{
midiName_ = name;

#if (JUCE_LINUX || JUCE_MAC)
Expand All @@ -78,6 +90,16 @@ void MpeProfileNegotiation::setProfileMidiName(const String& name)
#endif
}

void MpeProfileNegotiation::addMpeProfile(int manager)
{
auto max_channels = 0xF - manager + 1;
if (members_ > 0)
{
max_channels = std::min(members_ + 1, max_channels);
}
ci_->getProfileHost()->addProfile({ MPE_PROFILE, ci::ChannelAddress().withChannel((ci::ChannelInGroup)manager) }, max_channels);
}

void MpeProfileNegotiation::setManager(int manager)
{
manager_ = manager;
Expand Down
2 changes: 2 additions & 0 deletions Source/MpeProfileNegotiation.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class MpeProfileNegotiation : ci::DeviceListener, ci::ProfileDelegate, ci::Devic
private:
static std::string muidToString(ci::MUID muid);

void addMpeProfile(int manager);

virtual void handleIncomingMidiMessage(MidiInput* source,
const MidiMessage& message) override;

Expand Down

0 comments on commit fa9f76c

Please # to comment.