MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Nodes::Network::DeriveOperator Class Referencefinal

Defines one slot's block as a function of other slots' blocks. More...

#include <RelationOperators.hpp>

+ Inheritance diagram for MayaFlux::Nodes::Network::DeriveOperator:
+ Collaboration diagram for MayaFlux::Nodes::Network::DeriveOperator:

Public Types

using CoefFunction = std::function< double(std::span< const double >, std::span< double >)>
 
using Function = std::function< double(std::span< const double >)>
 

Public Member Functions

 DeriveOperator (size_t target, std::vector< size_t > inputs, CoefFunction function, std::vector< double > coefficients)
 
 DeriveOperator (size_t target, std::vector< size_t > inputs, Function function)
 
template<typename Gate >
requires (std::invocable<Gate&, const std::vector<double>&, std::span<double>> && std::same_as<std::invoke_result_t<Gate&, const std::vector<double>&, std::span<double>>, bool>)
 DeriveOperator (size_t target, std::vector< size_t > inputs, Gate function, std::vector< double > coefficients)
 
const std::vector< double > & get_coefficients () const noexcept
 
std::string_view get_type_name () const override
 Type name for introspection.
 
void process (float frames) override
 Process for one batch cycle.
 
std::optional< double > query_state (std::string_view query) const override
 
void set_coefficients (std::vector< double > coefficients)
 Replace the coefficient array.
 
void set_parameter (std::string_view param, double value) override
 Set one coefficient.
 
- Public Member Functions inherited from MayaFlux::Nodes::Network::RelationOperator
void begin_block ()
 Apply mapped parameters at the start of a block.
 
virtual std::span< const double > get_output_block (size_t) const
 
virtual size_t get_output_count () const
 
void map (std::string parameter, Source source)
 Drive an operator parameter from a source.
 
virtual bool publishes_output () const
 
void set_slots (std::vector< RelationSlot > &slots) noexcept
 Supply the current slot storage.
 
void unmap (std::string_view parameter)
 Remove the mapping of a parameter.
 
- Public Member Functions inherited from MayaFlux::Nodes::Network::NetworkOperator
virtual void apply_one_to_one (std::string_view param, const std::shared_ptr< NodeNetwork > &source)
 Apply ONE_TO_ONE parameter mapping (per-point control)
 
virtual bool demands_full_vertex_restore () const
 Whether a downstream compute pass writes the network's vertex buffer in place each cycle, so the geometry producer must keep restoring the CPU-authoritative vertex data every frame.
 
virtual ~NetworkOperator ()=default
 

Private Types

using Kernel = std::function< double(const std::vector< double > &, std::span< double >)>
 

Static Private Member Functions

static std::optional< size_t > coefficient_index (std::string_view param)
 

Private Attributes

std::vector< double > m_coefficients
 
bool m_gate {}
 
std::vector< size_t > m_inputs
 
Kernel m_kernel
 
size_t m_target
 
std::vector< double > m_values
 

Additional Inherited Members

- Protected Member Functions inherited from MayaFlux::Nodes::Network::RelationOperator
std::span< RelationSlot > slots () const noexcept
 

Detailed Description

Defines one slot's block as a function of other slots' blocks.

For each frame, calls the function with the input slots' values in the order given and writes the result to the target slot's block. An input equal to the target reads that slot's previous frame, or its previous block's last value at frame 0. Place after AdvanceOperator.

Three forms of rule:

  • a plain function of the input values;
  • a function of the input values and a coefficient array, which keeps the rule's state and can be retuned, saved and shared between rules;
  • a boolean function of the input values and a coefficient array, such as the parallel kernels of Kinesis::Discrete (Boolean.hpp). The block holds 0 or 1, and the target's activity follows the result, so its on_enter and on_leave callbacks fire on each change.

Coefficients are parameters "c0", "c1", ...: map("c2", source) retunes coefficient 2 at the start of every block.

namespace D = Kinesis::Discrete;
n->add<DeriveOperator>(2, std::vector<size_t> { 0, 1 }, D::comparator, D::comparator_state(0.2));
n->get_slot(2).on_enter.push_back([bell] { bell->excite(0.6); });
Defines one slot's block as a function of other slots' blocks.
bool comparator(const std::vector< double > &inputs, std::span< double > coefs) noexcept
Signal against signal: true once slot 0 exceeds slot 1 by the margin.
Definition Boolean.cpp:274
std::vector< double > comparator_state(double margin)
Builds the array comparator reads and writes.
Definition Boolean.cpp:269

Definition at line 292 of file RelationOperators.hpp.


The documentation for this class was generated from the following files: