Browse Source

Implement midi-out for juce based plugins

tags/1.9.4
falkTX 10 years ago
parent
commit
c50052dc55
3 changed files with 93 additions and 57 deletions
  1. +2
    -2
      source/Makefile.mk
  2. +37
    -1
      source/backend/plugin/JucePlugin.cpp
  3. +54
    -54
      source/widgets/qgraphicsembedscene.py

+ 2
- 2
source/Makefile.mk View File

@@ -62,7 +62,7 @@ CFLAGS += -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual
ifeq ($(LINUX),true)
CFLAGS += -isystem /opt/kxstudio/include
CXXFLAGS += -isystem /opt/kxstudio/include -isystem /usr/include/qt5
CXXFLAGS += -isystem /opt/kxstudio/include -isystem /usr/include/qt4
endif
ifeq ($(MACOS),true)
CFLAGS += -isystem /opt/local/include/
@@ -70,7 +70,7 @@ CXXFLAGS += -isystem /opt/local/include/
endif
ifeq ($(WIN32),true)
CFLAGS += -isystem /opt/mingw32/include
CXXFLAGS += -isystem /opt/mingw32/include -isystem /opt/mingw32/include/qt5
CXXFLAGS += -isystem /opt/mingw32/include -isystem /opt/mingw32/include/qt4
endif
endif



+ 37
- 1
source/backend/plugin/JucePlugin.cpp View File

@@ -30,7 +30,8 @@ using namespace juce;
CARLA_BACKEND_START_NAMESPACE

class JucePlugin : public CarlaPlugin,
public AudioPlayHead
public AudioPlayHead,
public AudioProcessorListener
{
public:
JucePlugin(CarlaEngine* const engine, const uint id)
@@ -890,6 +891,29 @@ public:
for (uint32_t i=0; i < pData->audioOut.count; ++i)
FloatVectorOperations::copy(outBuffer[i], fAudioBuffer.getSampleData(static_cast<int>(i)), static_cast<int>(frames));

// --------------------------------------------------------------------------------------------------------
// Midi out

if (! fMidiBuffer.isEmpty())
{
if (pData->event.portOut != nullptr)
{
const uint8* midiEventData;
int midiEventSize, midiEventPosition;

for (MidiBuffer::Iterator i(fMidiBuffer); i.getNextEvent(midiEventData, midiEventSize, midiEventPosition);)
{
CARLA_SAFE_ASSERT_BREAK(midiEventPosition >= 0 && midiEventPosition < static_cast<int>(frames));
CARLA_SAFE_ASSERT_BREAK(midiEventSize > 0);

if (! pData->event.portOut->writeMidiEvent(static_cast<uint32_t>(midiEventPosition), static_cast<uint8_t>(midiEventSize), midiEventData))
break;
}
}

fMidiBuffer.clear();
}

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

pData->singleMutex.unlock();
@@ -935,6 +959,17 @@ public:
// -------------------------------------------------------------------

protected:
void audioProcessorParameterChanged(AudioProcessor*, int /*parameterIndex*/, float /*newValue*/) override
{
}

void audioProcessorChanged(AudioProcessor*) override
{
}

void audioProcessorParameterChangeGestureBegin(AudioProcessor*, int) {}
void audioProcessorParameterChangeGestureEnd(AudioProcessor*, int) {}

bool getCurrentPosition(CurrentPositionInfo& result) override
{
carla_copyStruct<CurrentPositionInfo>(result, fPosInfo);
@@ -1010,6 +1045,7 @@ public:

fInstance->fillInPluginDescription(fDesc);
fInstance->setPlayHead(this);
fInstance->addListener(this);

// ---------------------------------------------------------------
// get info


+ 54
- 54
source/widgets/qgraphicsembedscene.py View File

@@ -102,12 +102,12 @@ class QGraphicsEmbedScene(QGraphicsScene):
# Render the scene into the fbo, scaling the QPainter's view
# transform up to the power-of-two fbo size.
painter = QPainter(self.fbo)
painter.setWindow(0, 0, size.width(), size.height());
painter.setViewport(0, 0, fboSize.width(), fboSize.height());
painter.setWindow(0, 0, size.width(), size.height())
painter.setViewport(0, 0, fboSize.width(), fboSize.height())
self.render(painter)
painter.end()
self.dirty = False
return self.fbo.texture();
return self.fbo.texture()

def deliverEvent(self, event, texCoord):
# Map the texture co-ordinate into "screen" co-ordinates.
@@ -140,78 +140,78 @@ class QGraphicsEmbedScene(QGraphicsScene):
QEvent.GraphicsSceneMouseDoubleClick):
pass
#QGraphicsSceneMouseEvent *ev =
#static_cast<QGraphicsSceneMouseEvent *>(event);
#QGraphicsSceneMouseEvent e(ev->type());
#e.setPos(QPointF(screenX, screenY));
#e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()));
#e.setScreenPos(QPoint(screenX, screenY));
#e.setButtonDownScreenPos(ev->button(), d->pressedPos);
#static_cast<QGraphicsSceneMouseEvent *>(event)
#QGraphicsSceneMouseEvent e(ev->type())
#e.setPos(QPointF(screenX, screenY))
#e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()))
#e.setScreenPos(QPoint(screenX, screenY))
#e.setButtonDownScreenPos(ev->button(), d->pressedPos)
#e.setButtonDownScenePos
#(ev->button(), QPointF(d->pressedPos.x() + bounds.x(),
#d->pressedPos.y() + bounds.y()));
#e.setButtons(ev->buttons());
#e.setButton(ev->button());
#e.setModifiers(ev->modifiers());
#e.setAccepted(false);
#QApplication::sendEvent(this, &e);
#d->pressedPos.y() + bounds.y()))
#e.setButtons(ev->buttons())
#e.setButton(ev->button())
#e.setModifiers(ev->modifiers())
#e.setAccepted(false)
#QApplication::sendEvent(this, &e)

elif eventType == QEvent.GraphicsSceneWheel:
pass
#QGraphicsSceneWheelEvent *ev =
#static_cast<QGraphicsSceneWheelEvent *>(event);
#QGraphicsSceneWheelEvent e(QEvent::GraphicsSceneWheel);
#e.setPos(QPointF(screenX, screenY));
#e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()));
#e.setScreenPos(QPoint(screenX, screenY));
#e.setButtons(ev->buttons());
#e.setModifiers(ev->modifiers());
#e.setDelta(ev->delta());
#e.setOrientation(ev->orientation());
#e.setAccepted(false);
#QApplication::sendEvent(this, &e);
#static_cast<QGraphicsSceneWheelEvent *>(event)
#QGraphicsSceneWheelEvent e(QEvent::GraphicsSceneWheel)
#e.setPos(QPointF(screenX, screenY))
#e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()))
#e.setScreenPos(QPoint(screenX, screenY))
#e.setButtons(ev->buttons())
#e.setModifiers(ev->modifiers())
#e.setDelta(ev->delta())
#e.setOrientation(ev->orientation())
#e.setAccepted(false)
#QApplication::sendEvent(this, &e)

elif eventType in (QEvent.MouseButtonPress,
QEvent.MouseButtonRelease,
QEvent.MouseButtonDblClick,
QEvent.MouseMove):
pass
#QMouseEvent *ev = static_cast<QMouseEvent *>(event);
#QEvent::Type type;
#QMouseEvent *ev = static_cast<QMouseEvent *>(event)
#QEvent::Type type
#if (ev->type() == QEvent::MouseButtonPress)
#type = QEvent::GraphicsSceneMousePress;
#type = QEvent::GraphicsSceneMousePress
#else if (ev->type() == QEvent::MouseButtonRelease)
#type = QEvent::GraphicsSceneMouseRelease;
#type = QEvent::GraphicsSceneMouseRelease
#else if (ev->type() == QEvent::MouseButtonDblClick)
#type = QEvent::GraphicsSceneMouseDoubleClick;
#type = QEvent::GraphicsSceneMouseDoubleClick
#else
#type = QEvent::GraphicsSceneMouseMove;
#QGraphicsSceneMouseEvent e(type);
#e.setPos(QPointF(screenX, screenY));
#e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()));
#e.setScreenPos(QPoint(screenX, screenY));
#e.setButtonDownScreenPos(ev->button(), d->pressedPos);
#type = QEvent::GraphicsSceneMouseMove
#QGraphicsSceneMouseEvent e(type)
#e.setPos(QPointF(screenX, screenY))
#e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()))
#e.setScreenPos(QPoint(screenX, screenY))
#e.setButtonDownScreenPos(ev->button(), d->pressedPos)
#e.setButtonDownScenePos
#(ev->button(), QPointF(d->pressedPos.x() + bounds.x(),
#d->pressedPos.y() + bounds.y()));
#e.setButtons(ev->buttons());
#e.setButton(ev->button());
#e.setModifiers(ev->modifiers());
#e.setAccepted(false);
#QApplication::sendEvent(this, &e);
#d->pressedPos.y() + bounds.y()))
#e.setButtons(ev->buttons())
#e.setButton(ev->button())
#e.setModifiers(ev->modifiers())
#e.setAccepted(false)
#QApplication::sendEvent(this, &e)

elif eventType == QEvent.Wheel:
pass
#QWheelEvent *ev = static_cast<QWheelEvent *>(event);
#QGraphicsSceneWheelEvent e(QEvent::GraphicsSceneWheel);
#e.setPos(QPointF(screenX, screenY));
#e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()));
#e.setScreenPos(QPoint(screenX, screenY));
#e.setButtons(ev->buttons());
#e.setModifiers(ev->modifiers());
#e.setDelta(ev->delta());
#e.setOrientation(ev->orientation());
#e.setAccepted(false);
#QApplication::sendEvent(this, &e);
#QWheelEvent *ev = static_cast<QWheelEvent *>(event)
#QGraphicsSceneWheelEvent e(QEvent::GraphicsSceneWheel)
#e.setPos(QPointF(screenX, screenY))
#e.setScenePos(QPointF(screenX + bounds.x(), screenY + bounds.y()))
#e.setScreenPos(QPoint(screenX, screenY))
#e.setButtons(ev->buttons())
#e.setModifiers(ev->modifiers())
#e.setDelta(ev->delta())
#e.setOrientation(ev->orientation())
#e.setAccepted(false)
#QApplication::sendEvent(this, &e)

#else:
# Send the event directly without any conversion.


Loading…
Cancel
Save