text
stringlengths
0
2.2M
bool isInput;
int currentBus = 0;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InputOutputConfig)
};
IOConfigurationWindow::IOConfigurationWindow (AudioProcessor& p)
: AudioProcessorEditor (&p),
title ("title", p.getName())
{
setOpaque (true);
title.setFont (title.getFont().withStyle (Font::bold));
addAndMakeVisible (title);
{
ScopedLock renderLock (p.getCallbackLock());
p.suspendProcessing (true);
p.releaseResources();
}
if (p.getBusCount (true) > 0 || p.canAddBus (true))
{
inConfig.reset (new InputOutputConfig (*this, true));
addAndMakeVisible (inConfig.get());
}
if (p.getBusCount (false) > 0 || p.canAddBus (false))
{
outConfig.reset (new InputOutputConfig (*this, false));
addAndMakeVisible (outConfig.get());
}
currentLayout = p.getBusesLayout();
setSize (400, (inConfig != nullptr && outConfig != nullptr ? 160 : 0) + 200);
}
IOConfigurationWindow::~IOConfigurationWindow()
{
if (auto* graph = getGraph())
{
if (auto* p = getAudioProcessor())
{
ScopedLock renderLock (graph->getCallbackLock());
graph->suspendProcessing (true);
graph->releaseResources();
p->prepareToPlay (graph->getSampleRate(), graph->getBlockSize());
p->suspendProcessing (false);
graph->prepareToPlay (graph->getSampleRate(), graph->getBlockSize());
graph->suspendProcessing (false);
}
}
}
void IOConfigurationWindow::paint (Graphics& g)
{
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
}
void IOConfigurationWindow::resized()
{
auto r = getLocalBounds().reduced (10);
title.setBounds (r.removeFromTop (14));
r.reduce (10, 0);
if (inConfig != nullptr)
inConfig->setBounds (r.removeFromTop (160));
if (outConfig != nullptr)
outConfig->setBounds (r.removeFromTop (160));
}
void IOConfigurationWindow::update()
{
auto nodeID = getNodeID();
if (auto* graph = getGraph())
if (nodeID != AudioProcessorGraph::NodeID())
graph->disconnectNode (nodeID);
if (auto* graphEditor = getGraphEditor())
if (auto* panel = graphEditor->graphPanel.get())
panel->updateComponents();
}
AudioProcessorGraph::NodeID IOConfigurationWindow::getNodeID() const
{
if (auto* graph = getGraph())
for (auto* node : graph->getNodes())
if (node->getProcessor() == getAudioProcessor())
return node->nodeID;
return {};
}