1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added a MIDI output node to the AudioPluginHost

This commit is contained in:
ed 2020-01-14 18:16:01 +00:00
parent b2d8f45e14
commit 4b118bb45b
5 changed files with 45 additions and 7 deletions

View file

@ -357,6 +357,11 @@ InternalPluginFormat::InternalPluginFormat()
AudioProcessorGraph::AudioGraphIOProcessor p (AudioProcessorGraph::AudioGraphIOProcessor::midiInputNode);
p.fillInPluginDescription (midiInDesc);
}
{
AudioProcessorGraph::AudioGraphIOProcessor p (AudioProcessorGraph::AudioGraphIOProcessor::midiOutputNode);
p.fillInPluginDescription (midiOutDesc);
}
}
std::unique_ptr<AudioPluginInstance> InternalPluginFormat::createInstance (const String& name)
@ -364,6 +369,7 @@ std::unique_ptr<AudioPluginInstance> InternalPluginFormat::createInstance (const
if (name == audioOutDesc.name) return std::make_unique<AudioProcessorGraph::AudioGraphIOProcessor> (AudioProcessorGraph::AudioGraphIOProcessor::audioOutputNode);
if (name == audioInDesc.name) return std::make_unique<AudioProcessorGraph::AudioGraphIOProcessor> (AudioProcessorGraph::AudioGraphIOProcessor::audioInputNode);
if (name == midiInDesc.name) return std::make_unique<AudioProcessorGraph::AudioGraphIOProcessor> (AudioProcessorGraph::AudioGraphIOProcessor::midiInputNode);
if (name == midiOutDesc.name) return std::make_unique<AudioProcessorGraph::AudioGraphIOProcessor> (AudioProcessorGraph::AudioGraphIOProcessor::midiOutputNode);
if (name == SineWaveSynth::getIdentifier()) return std::make_unique<SineWaveSynth> (SineWaveSynth::getPluginDescription());
if (name == ReverbPlugin::getIdentifier()) return std::make_unique<ReverbPlugin> (ReverbPlugin::getPluginDescription());
@ -388,7 +394,6 @@ bool InternalPluginFormat::requiresUnblockedMessageThreadDuringCreation (const P
void InternalPluginFormat::getAllTypes (Array<PluginDescription>& results)
{
results.add (audioInDesc, audioOutDesc, midiInDesc,
SineWaveSynth::getPluginDescription(),
ReverbPlugin::getPluginDescription());
results.add (audioInDesc, audioOutDesc, midiInDesc, midiOutDesc,
SineWaveSynth::getPluginDescription(), ReverbPlugin::getPluginDescription());
}

View file

@ -41,7 +41,7 @@ public:
~InternalPluginFormat() override {}
//==============================================================================
PluginDescription audioInDesc, audioOutDesc, midiInDesc;
PluginDescription audioInDesc, audioOutDesc, midiInDesc, midiOutDesc;
void getAllTypes (Array<PluginDescription>&);
//==============================================================================

View file

@ -202,11 +202,13 @@ void PluginGraph::newDocument()
addPlugin (internalFormat.audioInDesc, { 0.5, 0.1 });
addPlugin (internalFormat.midiInDesc, { 0.25, 0.1 });
addPlugin (internalFormat.audioOutDesc, { 0.5, 0.9 });
addPlugin (internalFormat.midiOutDesc, { 0.25, 0.9 });
MessageManager::callAsync ([this] () {
MessageManager::callAsync ([this]
{
setChangedFlag (false);
graph.addChangeListener (this);
} );
});
}
Result PluginGraph::loadDocument (const File& file)

View file

@ -1167,10 +1167,13 @@ GraphDocumentComponent::GraphDocumentComponent (AudioPluginFormatManager& fm,
deviceManager.addChangeListener (graphPanel.get());
deviceManager.addAudioCallback (&graphPlayer);
deviceManager.addMidiInputDeviceCallback ({}, &graphPlayer.getMidiMessageCollector());
deviceManager.addChangeListener (this);
}
void GraphDocumentComponent::init()
{
updateMidiOutput();
graphPanel.reset (new GraphEditorPanel (*graph));
addAndMakeVisible (graphPanel.get());
graphPlayer.setProcessor (&graph->graph);
@ -1213,6 +1216,9 @@ void GraphDocumentComponent::init()
GraphDocumentComponent::~GraphDocumentComponent()
{
if (midiOutput != nullptr)
midiOutput->stopBackgroundThread();
releaseGraph();
keyState.removeListener (&graphPlayer.getMidiMessageCollector());
@ -1326,3 +1332,23 @@ bool GraphDocumentComponent::closeAnyOpenPluginWindows()
{
return graphPanel->graph.closeAnyOpenPluginWindows();
}
void GraphDocumentComponent::changeListenerCallback (ChangeBroadcaster*)
{
updateMidiOutput();
}
void GraphDocumentComponent::updateMidiOutput()
{
auto* defaultMidiOutput = deviceManager.getDefaultMidiOutput();
if (midiOutput != defaultMidiOutput)
{
midiOutput = defaultMidiOutput;
if (midiOutput != nullptr)
midiOutput->startBackgroundThread();
graphPlayer.setMidiOutput (midiOutput);
}
}

View file

@ -100,7 +100,8 @@ private:
*/
class GraphDocumentComponent : public Component,
public DragAndDropTarget,
public DragAndDropContainer
public DragAndDropContainer,
private ChangeListener
{
public:
GraphDocumentComponent (AudioPluginFormatManager& formatManager,
@ -142,6 +143,7 @@ private:
AudioProcessorPlayer graphPlayer;
MidiKeyboardState keyState;
MidiOutput* midiOutput = nullptr;
struct TooltipBar;
std::unique_ptr<TooltipBar> statusBar;
@ -160,8 +162,11 @@ private:
SidePanel* lastOpenedSidePanel = nullptr;
//==============================================================================
void changeListenerCallback (ChangeBroadcaster*) override;
void init();
void checkAvailableWidth();
void updateMidiOutput();
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphDocumentComponent)