Signed-off-by: falkTX <falktx@falktx.com>tags/v2.3.0-RC1
@@ -1661,7 +1661,8 @@ public: | |||||
} | } | ||||
static intptr_t _dispatcher(NativePluginHandle handle, | static intptr_t _dispatcher(NativePluginHandle handle, | ||||
NativePluginDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt) | |||||
NativePluginDispatcherOpcode opcode, | |||||
int32_t index, intptr_t value, void* ptr, float opt) | |||||
{ | { | ||||
switch(opcode) | switch(opcode) | ||||
{ | { | ||||
@@ -1688,6 +1689,8 @@ public: | |||||
case NATIVE_PLUGIN_OPCODE_IDLE: | case NATIVE_PLUGIN_OPCODE_IDLE: | ||||
//handlePtr->idle(); | //handlePtr->idle(); | ||||
return 0; | return 0; | ||||
case NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT: | |||||
return 0; | |||||
} | } | ||||
return 0; | return 0; | ||||
@@ -2645,7 +2645,18 @@ public: | |||||
if (! fIsUiVisible) | if (! fIsUiVisible) | ||||
return; | return; | ||||
// TODO | |||||
if (fDescriptor->dispatcher != nullptr) | |||||
{ | |||||
uint8_t data[3] = { | |||||
uint8_t(MIDI_STATUS_NOTE_ON | (channel & MIDI_CHANNEL_BIT)), | |||||
note, | |||||
velo | |||||
}; | |||||
fDescriptor->dispatcher(fHandle, NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT, | |||||
3, 0, | |||||
data, | |||||
0.0f); | |||||
} | |||||
} | } | ||||
void uiNoteOff(const uint8_t channel, const uint8_t note) noexcept override | void uiNoteOff(const uint8_t channel, const uint8_t note) noexcept override | ||||
@@ -2660,7 +2671,18 @@ public: | |||||
if (fDescriptor == nullptr || fHandle == nullptr) | if (fDescriptor == nullptr || fHandle == nullptr) | ||||
return; | return; | ||||
// TODO | |||||
if (fDescriptor->dispatcher != nullptr) | |||||
{ | |||||
uint8_t data[3] = { | |||||
uint8_t(MIDI_STATUS_NOTE_OFF | (channel & MIDI_CHANNEL_BIT)), | |||||
note, | |||||
0 | |||||
}; | |||||
fDescriptor->dispatcher(fHandle, NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT, | |||||
3, 0, | |||||
data, | |||||
0.0f); | |||||
} | |||||
} | } | ||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
@@ -99,7 +99,8 @@ typedef enum { | |||||
NATIVE_PLUGIN_OPCODE_OFFLINE_CHANGED = 3, /** uses value (0=off, 1=on) */ | NATIVE_PLUGIN_OPCODE_OFFLINE_CHANGED = 3, /** uses value (0=off, 1=on) */ | ||||
NATIVE_PLUGIN_OPCODE_UI_NAME_CHANGED = 4, /** uses ptr */ | NATIVE_PLUGIN_OPCODE_UI_NAME_CHANGED = 4, /** uses ptr */ | ||||
NATIVE_PLUGIN_OPCODE_GET_INTERNAL_HANDLE = 5, /** nothing */ | NATIVE_PLUGIN_OPCODE_GET_INTERNAL_HANDLE = 5, /** nothing */ | ||||
NATIVE_PLUGIN_OPCODE_IDLE = 6 /** nothing */ | |||||
NATIVE_PLUGIN_OPCODE_IDLE = 6, /** nothing */ | |||||
NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT = 7 /** uses ptr */ | |||||
} NativePluginDispatcherOpcode; | } NativePluginDispatcherOpcode; | ||||
typedef enum { | typedef enum { | ||||
@@ -405,6 +405,15 @@ protected: | |||||
CARLA_SAFE_ASSERT_RETURN(uiName != nullptr && uiName[0] != '\0',); | CARLA_SAFE_ASSERT_RETURN(uiName != nullptr && uiName[0] != '\0',); | ||||
} | } | ||||
virtual bool uiMIDIEvent(uint8_t size, const uint8_t data[]) | |||||
{ | |||||
return false; | |||||
// unused | |||||
(void)size; | |||||
(void)data; | |||||
} | |||||
virtual const NativeInlineDisplayImageSurface* renderInlineDisplay(const uint32_t width, const uint32_t height) | virtual const NativeInlineDisplayImageSurface* renderInlineDisplay(const uint32_t width, const uint32_t height) | ||||
{ | { | ||||
CARLA_SAFE_ASSERT_RETURN(width > 0 && height > 0, nullptr); | CARLA_SAFE_ASSERT_RETURN(width > 0 && height > 0, nullptr); | ||||
@@ -545,6 +554,11 @@ public: | |||||
case NATIVE_PLUGIN_OPCODE_IDLE: | case NATIVE_PLUGIN_OPCODE_IDLE: | ||||
handlePtr->idle(); | handlePtr->idle(); | ||||
return 0; | return 0; | ||||
case NATIVE_PLUGIN_OPCODE_UI_MIDI_EVENT: | |||||
CARLA_SAFE_ASSERT_RETURN(index >= 0 && index < UINT8_MAX, 0); | |||||
CARLA_SAFE_ASSERT_RETURN(ptr != nullptr, 0); | |||||
return handlePtr->uiMIDIEvent(static_cast<uint8_t>(index), | |||||
static_cast<uint8_t*>(ptr)); | |||||
} | } | ||||
return 0; | return 0; | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* Carla Native Plugin API (C++) | * Carla Native Plugin API (C++) | ||||
* Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2012-2020 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -20,6 +20,7 @@ | |||||
#include "CarlaNative.hpp" | #include "CarlaNative.hpp" | ||||
#include "CarlaExternalUI.hpp" | #include "CarlaExternalUI.hpp" | ||||
#include "CarlaMIDI.h" | |||||
/*! | /*! | ||||
* @defgroup CarlaNativeAPI Carla Native API | * @defgroup CarlaNativeAPI Carla Native API | ||||
@@ -136,6 +137,22 @@ protected: | |||||
flushMessages(); | flushMessages(); | ||||
} | } | ||||
bool uiMIDIEvent(const uint8_t size, const uint8_t data[]) override | |||||
{ | |||||
if (size != 3) | |||||
return false; | |||||
const uint8_t status = MIDI_GET_STATUS_FROM_DATA(data); | |||||
if (! (MIDI_IS_STATUS_NOTE_ON(status) || MIDI_IS_STATUS_NOTE_OFF(status))) | |||||
return false; | |||||
writeMidiNoteMessage(MIDI_IS_STATUS_NOTE_ON(status), | |||||
MIDI_GET_CHANNEL_FROM_DATA(data), | |||||
data[1], data[2]); | |||||
return true; | |||||
} | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
// Pipe Server calls | // Pipe Server calls | ||||
@@ -161,9 +178,10 @@ protected: | |||||
if (std::strcmp(msg, "program") == 0) | if (std::strcmp(msg, "program") == 0) | ||||
{ | { | ||||
uint32_t channel, bank, program; | |||||
uint8_t channel; | |||||
uint32_t bank, program; | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(channel), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsByte(channel), true); | |||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(bank), true); | CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(bank), true); | ||||
CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(program), true); | CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(program), true); | ||||
CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, true); | CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS, true); | ||||