Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't crossfade in first graph render sequence #4

Merged
merged 6 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions runtime/elem/GraphRenderSequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ namespace elem

// Next we prepare the render operation
bufferMap.emplace(node->getId(), ba.next());
auto* outputData = bufferMap.at(node->getId());

renderOps.push_back([=, bufferMap = this->bufferMap](HostContext<FloatType>& ctx) {
auto* outputData = bufferMap.at(node->getId());
renderOps.push_back([=](HostContext<FloatType>& ctx) {

node->process(BlockContext<FloatType> {
ctx.inputData,
Expand All @@ -117,18 +117,18 @@ namespace elem
}

// Next we prepare the render operation
bufferMap.emplace(node->getId(), ba.next());
auto* outputData = ba.next();
bufferMap.emplace(node->getId(), outputData);

// Allocate room for the child pointers here, gets moved into the lambda capture group below
std::vector<FloatType*> ptrs(children.size());
auto const numChildren = children.size();

renderOps.push_back([=, bufferMap = this->bufferMap, ptrs = std::move(ptrs)](HostContext<FloatType>& ctx) mutable {
auto* outputData = bufferMap.at(node->getId());
auto const numChildren = children.size();
for (size_t j = 0; j < numChildren; ++j) {
ptrs[j] = bufferMap.at(children[j]);
}

for (size_t j = 0; j < numChildren; ++j) {
ptrs[j] = bufferMap.at(children[j]);
}
renderOps.push_back([=, ptrs = std::move(ptrs)](HostContext<FloatType>& ctx) mutable {

node->process(BlockContext<FloatType> {
const_cast<const FloatType**>(ptrs.data()),
Expand Down
2 changes: 1 addition & 1 deletion runtime/elem/Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ namespace elem
auto ptr = std::dynamic_pointer_cast<RootNode<FloatType>>(it->second);
if (ptr)
{
ptr->setProperty("active", true);
ptr->activate(currentRoots.empty() ? FloatType(1) : FloatType(0));
active.insert(nodeId);
ELEM_DBG("[Success] Activated root: " << nodeIdToHex(nodeId));
}
Expand Down
6 changes: 6 additions & 0 deletions runtime/elem/builtins/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ namespace elem
return (t >= 0.5 || (std::abs(c - t) >= std::numeric_limits<FloatType>::epsilon()));
}

void activate(FloatType initialGain = FloatType(0))
{
setProperty("active", true);
currentGain.store(initialGain);
}

int setProperty(std::string const& key, js::Value const& val) override
{
if (key == "active") {
Expand Down