MCPcopy Create free account
hub / github.com/apohl79/audiogridder / setProcessorBusesLayout

Method setProcessorBusesLayout

Server/Source/ProcessorChain.cpp:89–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89bool ProcessorChain::setProcessorBusesLayout(Processor* proc, const String& targetOutputLayout) {
90 traceScope();
91
92 if (!proc->isLoaded()) {
93 return false;
94 }
95
96 auto layout = getBusesLayout();
97 int chIn = getLayoutNumChannels(layout, true), chOut = getLayoutNumChannels(layout, false);
98 auto procLayouts = proc->getSupportedBusLayouts();
99 AudioProcessor::BusesLayout targetLayout;
100 int targetChIn = 0, targetChOut = 0, extraInChannels = 0, extraOutChannels = 0;
101 bool found = false;
102
103 auto setTargetLayout = [&](const BusesLayout& l, int in, int out) {
104 targetLayout = l;
105 targetChIn = in;
106 targetChOut = out;
107 found = true;
108 };
109
110 if (procLayouts.isEmpty()) {
111 logln("no processor layouts cached, checking now...");
112 procLayouts = Processor::findSupportedLayouts(proc);
113 }
114
115 if (targetOutputLayout.isNotEmpty()) {
116 logln("requested target output layout: " << targetOutputLayout);
117 }
118
119 if (targetOutputLayout.isNotEmpty() && targetOutputLayout != "Default") {
120 for (auto& l : procLayouts) {
121 int checkChIn = getLayoutNumChannels(l, true), checkChOut = getLayoutNumChannels(l, false);
122 String sinputs = describeLayout(l, true, false, true), soutputs = describeLayout(l, false, true, true);
123 if (soutputs == targetOutputLayout) {
124 if (chIn == 0 || checkChIn == checkChOut) {
125 setTargetLayout(l, checkChIn, checkChOut);
126 if (chIn == 0 || sinputs == soutputs) {
127 break;
128 }
129 } else if (l.inputBuses.size() == 2 && l.outputBuses.size() == 1) {
130 // inputs with sidechain?
131 auto lNoSC = l;
132 lNoSC.inputBuses.remove(1);
133 if (describeLayout(lNoSC, true, false, true) == soutputs) {
134 setTargetLayout(l, checkChIn, checkChOut);
135 break;
136 }
137 } else {
138 if (found) {
139 break;
140 }
141 if (checkChIn > targetChIn) {
142 setTargetLayout(l, checkChIn, checkChOut);
143 }
144 }
145 }
146 }

Callers

nothing calls this directly

Calls 8

getLayoutNumChannelsFunction · 0.85
describeLayoutFunction · 0.85
setBusesLayoutMethod · 0.80
containsMethod · 0.80
getBusesLayoutMethod · 0.80
setExtraChannelsMethod · 0.80
isLoadedMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected