MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / ArrangeAudioSourceDependencies

Method ArrangeAudioSourceDependencies

Source/ModularSynth.cpp:2193–2282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2191};
2192
2193void ModularSynth::ArrangeAudioSourceDependencies()
2194{
2195 if (mIsLoadingState)
2196 {
2197 mArrangeDependenciesWhenLoadCompletes = true;
2198 return;
2199 }
2200
2201 //ofLog() << "Calculating audio source dependencies:";
2202
2203 std::vector<SourceDepInfo> deps;
2204 for (int i = 0; i < mSources.size(); ++i)
2205 deps.push_back(SourceDepInfo(mSources[i]));
2206
2207 for (int i = 0; i < mSources.size(); ++i)
2208 {
2209 for (int j = 0; j < mSources.size(); ++j)
2210 {
2211 for (int k = 0; k < mSources[i]->GetNumTargets(); ++k)
2212 {
2213 if (mSources[i]->GetTarget(k) != nullptr &&
2214 mSources[i]->GetTarget(k) == dynamic_cast<IAudioReceiver*>(mSources[j]))
2215 {
2216 deps[j].mDeps.push_back(mSources[i]);
2217 }
2218 }
2219 }
2220 }
2221
2222 /*for (int i=0; i<deps.size(); ++i)
2223 {
2224 string depStr;
2225 for (int j=0;j<deps[i].mDeps.size();++j)
2226 {
2227 depStr += dynamic_cast<IDrawableModule*>(deps[i].mDeps[j])->Name();
2228 if (j<deps[i].mDeps.size()-1)
2229 depStr += ", ";
2230 }
2231 ofLog() << dynamic_cast<IDrawableModule*>(deps[i].mMe)->Name() << "depends on:" << depStr;
2232 }*/
2233
2234 //TODO(Ryan) detect circular dependencies
2235 const int kMaxLoopCount = 1000; //how many times we loop over the graph before deciding that it must contain a circular dependency
2236 mSources.clear();
2237 int loopCount = 0;
2238 while (deps.size() > 0 && loopCount < kMaxLoopCount) //stupid circular dependency detection, make better
2239 {
2240 for (int i = 0; i < deps.size(); ++i)
2241 {
2242 bool hasDeps = false;
2243 for (int j = 0; j < deps[i].mDeps.size(); ++j)
2244 {
2245 bool found = false;
2246 for (int k = 0; k < mSources.size(); ++k)
2247 {
2248 if (deps[i].mDeps[j] == mSources[k])
2249 found = true;
2250 }

Callers 3

GoMethod · 0.80
SetPatchCableTargetMethod · 0.80
RemovePatchCableMethod · 0.80

Calls 5

SourceDepInfoClass · 0.85
ofLogClass · 0.85
sizeMethod · 0.80
GetNumTargetsMethod · 0.45
GetTargetMethod · 0.45

Tested by

no test coverage detected