Skip to content

Commit

Permalink
ossia: allow nodes to be aware of the ossia address
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Dec 23, 2024
1 parent 59eb477 commit 842b947
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/avnd/binding/ossia/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ class safe_node_base : public safe_node_base_base<T>
this->frame_count_for_this_tick = frames;

// Process inputs of all sorts
this->process_all_ports<set_ossia_node_in_port<safe_node_base, T>>();
this->process_all_ports<process_before_run<safe_node_base, T>>(start, frames);

// Process messages
Expand Down
28 changes: 28 additions & 0 deletions include/avnd/binding/ossia/port_run_preprocess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
#include <avnd/wrappers/widgets.hpp>
#include <fmt/printf.h>
#include <ossia/audio/fft.hpp>
#include <ossia/dataflow/dataflow.hpp>
#include <ossia/dataflow/graph_node.hpp>
#include <ossia/dataflow/port.hpp>
#include <ossia/detail/math.hpp>
#include <ossia/editor/curve/curve_segment/easing.hpp>
#include <ossia/network/base/node.hpp>
#include <ossia/network/base/parameter.hpp>
#include <ossia/network/value/format_value.hpp>

namespace oscr
Expand All @@ -32,6 +35,31 @@ inline void update_value(
}
}

struct node_from_destination
{
ossia::net::node_base* operator()(ossia::net::parameter_base* p)
{
if(p)
return &p->get_node();
}
// ossia::traversal::path, ossia::net::node_base*
};

template <typename Exec_T, typename Obj_T>
struct set_ossia_node_in_port
{
Exec_T& self;
Obj_T& impl;

inline void operator()(auto& ctrl, auto& port, auto) const noexcept
{
if constexpr(requires { ctrl.ossia_node = nullptr; })
{
ctrl.ossia_node = impl.ossia_state.get_first_destination(port.address);
}
}
};

template <typename Exec_T, typename Obj_T>
struct process_before_run
{
Expand Down

0 comments on commit 842b947

Please sign in to comment.