Browse Source

Allow sendNote for plugins with MIDI input

pull/61/head
falkTX 5 years ago
parent
commit
d5c6245dcb
4 changed files with 13 additions and 7 deletions
  1. +1
    -1
      distrho/DistrhoUI.hpp
  2. +1
    -1
      distrho/src/DistrhoUI.cpp
  3. +8
    -0
      distrho/src/DistrhoUIDSSI.cpp
  4. +3
    -5
      distrho/src/DistrhoUILV2.cpp

+ 1
- 1
distrho/DistrhoUI.hpp View File

@@ -90,7 +90,7 @@ public:
void setState(const char* key, const char* value);
#endif

#if DISTRHO_PLUGIN_IS_SYNTH
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
/**
sendNote.
@TODO Document this.


+ 1
- 1
distrho/src/DistrhoUI.cpp View File

@@ -82,7 +82,7 @@ void UI::setState(const char* key, const char* value)
}
#endif

#if DISTRHO_PLUGIN_IS_SYNTH
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
void UI::sendNote(uint8_t channel, uint8_t note, uint8_t velocity)
{
pData->sendNoteCallback(channel, note, velocity);


+ 8
- 0
distrho/src/DistrhoUIDSSI.cpp View File

@@ -26,6 +26,10 @@

START_NAMESPACE_DISTRHO

#if ! DISTRHO_PLUGIN_WANT_MIDI_INPUT
static const sendNoteFunc sendNoteCallback = nullptr;
#endif

// -----------------------------------------------------------------------

struct OscData {
@@ -180,6 +184,7 @@ protected:
fOscData.send_configure(key, value);
}

#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
void sendNote(const uint8_t channel, const uint8_t note, const uint8_t velocity)
{
if (fOscData.server == nullptr)
@@ -195,6 +200,7 @@ protected:
};
fOscData.send_midi(mdata);
}
#endif

void setSize(const uint width, const uint height)
{
@@ -222,10 +228,12 @@ private:
uiPtr->setState(key, value);
}

#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
static void sendNoteCallback(void* ptr, uint8_t channel, uint8_t note, uint8_t velocity)
{
uiPtr->sendNote(channel, note, velocity);
}
#endif

static void setSizeCallback(void* ptr, uint width, uint height)
{


+ 3
- 5
distrho/src/DistrhoUILV2.cpp View File

@@ -34,8 +34,6 @@
# define DISTRHO_PLUGIN_LV2_STATE_PREFIX "urn:distrho:"
#endif

#define DISTRHO_LV2_USE_EVENTS_IN (DISTRHO_PLUGIN_WANT_MIDI_INPUT || DISTRHO_PLUGIN_WANT_TIMEPOS || (DISTRHO_PLUGIN_WANT_STATE && DISTRHO_PLUGIN_HAS_UI))

START_NAMESPACE_DISTRHO

typedef struct _LV2_Atom_MidiEvent {
@@ -43,7 +41,7 @@ typedef struct _LV2_Atom_MidiEvent {
uint8_t data[3]; /**< MIDI data (body). */
} LV2_Atom_MidiEvent;

#if ! DISTRHO_LV2_USE_EVENTS_IN
#if ! DISTRHO_PLUGIN_WANT_MIDI_INPUT
static const sendNoteFunc sendNoteCallback = nullptr;
#endif

@@ -269,7 +267,7 @@ protected:
fWriteFunction(fController, eventInPortIndex, atomSize, fEventTransferURID, atom);
}

#if DISTRHO_LV2_USE_EVENTS_IN
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
void sendNote(const uint8_t channel, const uint8_t note, const uint8_t velocity)
{
DISTRHO_SAFE_ASSERT_RETURN(fWriteFunction != nullptr,);
@@ -340,7 +338,7 @@ private:
uiPtr->setState(key, value);
}

#if DISTRHO_LV2_USE_EVENTS_IN
#if DISTRHO_PLUGIN_WANT_MIDI_INPUT
static void sendNoteCallback(void* ptr, uint8_t channel, uint8_t note, uint8_t velocity)
{
uiPtr->sendNote(channel, note, velocity);


Loading…
Cancel
Save