Why did MidiKeyboardComponent::handleNoteOn/handleNoteOff get made private?

Why did MidiKeyboardComponent::handleNoteOn/handleNoteOff get made private?

It’s not listed in breaking changes, but it broke my build.

How are you using those functions?

Before the change they were marked as @internal, so not part of the public API of the class.

I have a MidiKeyboard that is connected to a MidiOutput. For every call to handleNoteOn/handleNoteOff, I’d create a midi event and send it to the output.

Can you achieve the same with your own MidiKeyboardState listener, which could then send MIDI events to the output?

I don’t think I can inherit from MidiKeyboardState::Listener since MidiKeyboardComponent already does.

I get:

Showing All Messages /Users/rrabien/dev.github/waveform/waveform/common/Source/ui/edit/plugins/ChordCompanionPluginUI.cpp:16:24: Ambiguous conversion from derived class 'ChordCompanionKeyboardComponent' to base class 'juce::MidiKeyboardState::Listener': struct ChordCompanionKeyboardComponent -> class juce::MidiKeyboardComponent -> class MidiKeyboardState::Listener struct ChordCompanionKeyboardComponent -> class MidiKeyboardState::Listener

You could use a separate forwarder class. Something like:

struct Forwarder : MidiKeyboardState::Listener
{
    Forwarder (MidiOutput& o)
        : output (o)
    {}

    void handleNoteOn (MidiKeyboardState*, int, int, float) override
    {
        // Do something with output
    }

    void handleNoteOff (MidiKeyboardState*, int, int, float) override
    {
        // Do something with output
    }

    MidiOutput& output;
};

Or, depending on your use case, Forwarder could instead be a MidiOutputWrapper and hold its own MidiOutput.