1
0
Fork 0

Allow basic CLAP MIDI msgs with MidiConfig::Basic

This is needed for Qtractor compatibility. Even though it always sends
notes as CLAP events, it requires the plugin to support both the CLAP
and the MIDI note event dialects. Otherwise it won't send any notes at
all. Feature, not a bug.
This commit is contained in:
Robbert van der Helm 2022-11-04 21:00:35 +01:00
parent f48b36f2a7
commit 6eccabb701

View file

@ -1574,22 +1574,25 @@ impl<P: ClapPlugin> Wrapper<P> {
false false
} }
(CLAP_CORE_EVENT_SPACE_ID, CLAP_EVENT_MIDI) => { (CLAP_CORE_EVENT_SPACE_ID, CLAP_EVENT_MIDI) => {
// TODO: We can also handle note on, note off, and polyphonic pressure events, but // In the Basic note port type, we'll still handle note on, note off, and polyphonic
// the host should not be sending us those since we prefer CLAP-style events // pressure events if the host sents us those. But we'll throw away any other MIDI
// on our note ports // messages to stay consistent with the VST3 wrapper.
if P::MIDI_INPUT >= MidiConfig::MidiCCs { let event = &*(event as *const clap_event_midi);
let event = &*(event as *const clap_event_midi);
match NoteEvent::from_midi( match NoteEvent::from_midi(raw_event.time - current_sample_idx as u32, event.data) {
raw_event.time - current_sample_idx as u32, Ok(
event.data, note_event @ (NoteEvent::NoteOn { .. }
) { | NoteEvent::NoteOff { .. }
Ok(note_event) => { | NoteEvent::PolyPressure { .. }),
input_events.push_back(note_event); ) if P::MIDI_INPUT >= MidiConfig::Basic => {
} input_events.push_back(note_event);
Err(n) => nih_debug_assert_failure!("Unhandled MIDI message type {}", n), }
}; Ok(note_event) if P::MIDI_INPUT >= MidiConfig::MidiCCs => {
} input_events.push_back(note_event);
}
Ok(_) => (),
Err(n) => nih_debug_assert_failure!("Unhandled MIDI message type {}", n),
};
false false
} }
@ -2933,10 +2936,10 @@ impl<P: ClapPlugin> Wrapper<P> {
let info = &mut *info; let info = &mut *info;
info.id = 0; info.id = 0;
info.supported_dialects = CLAP_NOTE_DIALECT_CLAP; // If `P::MIDI_OUTPUT < MidiConfig::MidiCCs` we'll throw away MIDI CCs, pitch bend
if P::MIDI_OUTPUT >= MidiConfig::MidiCCs { // messages, and other messages that are not basic note on, off and polyphonic
info.supported_dialects |= CLAP_NOTE_DIALECT_MIDI; // pressure messages. This way the behavior is the same as the VST3 wrapper.
} info.supported_dialects = CLAP_NOTE_DIALECT_CLAP | CLAP_NOTE_DIALECT_MIDI;
info.preferred_dialect = CLAP_NOTE_DIALECT_CLAP; info.preferred_dialect = CLAP_NOTE_DIALECT_CLAP;
strlcpy(&mut info.name, "Note Output"); strlcpy(&mut info.name, "Note Output");