2016-07-13 03:04:55 +00:00
|
|
|
#include "amuse/Studio.hpp"
|
2019-09-11 00:20:17 +00:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
2016-07-13 03:04:55 +00:00
|
|
|
#include "amuse/Engine.hpp"
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
namespace amuse {
|
2016-07-13 03:04:55 +00:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
2019-09-11 00:20:17 +00:00
|
|
|
bool Studio::_cyclicCheck(const Studio* leaf) const {
|
|
|
|
return std::any_of(m_studiosOut.cbegin(), m_studiosOut.cend(), [leaf](const auto& studio) {
|
|
|
|
return leaf == studio.m_targetStudio.get() || studio.m_targetStudio->_cyclicCheck(leaf);
|
|
|
|
});
|
2016-07-13 03:04:55 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
Studio::Studio(Engine& engine, bool mainOut) : m_engine(engine), m_master(engine), m_auxA(engine), m_auxB(engine) {
|
|
|
|
if (mainOut && engine.m_defaultStudioReady)
|
|
|
|
addStudioSend(engine.getDefaultStudio(), 1.f, 1.f, 1.f);
|
2016-07-13 03:04:55 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
void Studio::addStudioSend(ObjToken<Studio> studio, float dry, float auxA, float auxB) {
|
2019-09-11 00:23:26 +00:00
|
|
|
m_studiosOut.emplace_back(std::move(studio), dry, auxA, auxB);
|
2016-07-14 04:54:46 +00:00
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
/* Cyclic check */
|
|
|
|
assert(!_cyclicCheck(this));
|
2016-07-13 03:04:55 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:20:09 +00:00
|
|
|
void Studio::resetOutputSampleRate(double sampleRate) {
|
|
|
|
m_master.resetOutputSampleRate(sampleRate);
|
|
|
|
m_auxA.resetOutputSampleRate(sampleRate);
|
|
|
|
m_auxB.resetOutputSampleRate(sampleRate);
|
2016-07-13 03:04:55 +00:00
|
|
|
}
|
2018-12-08 05:20:09 +00:00
|
|
|
} // namespace amuse
|