MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Generator.cpp
Go to the documentation of this file.
1#include "Generator.hpp"
2
4
6
21
22void Generator::set_amplitude(double amplitude)
23{
24 m_amplitude = amplitude;
25}
26
28{
29 return m_amplitude;
30}
31
36
38{
39 if (is_gpu_compatible()) {
40 return m_context_gpu;
41 }
42 return m_context;
43}
44
45void operator*(const std::shared_ptr<Node>& node, double value)
46{
47 if (auto gen = std::dynamic_pointer_cast<Generator>(node)) {
48 gen->set_amplitude(value);
49 } else {
51 "Cannot multiply non-generator node by a scalar. "
52 "Use set_[params] methods or create a BinaryOpNode.");
53 }
54}
55
63
68
73
74} // namespace MayaFlux::Nodes::Generator
#define MF_ERROR(comp, ctx,...)
PickCallback callback
Definition Picker.cpp:22
double frequency
glm::vec3 value
double amplitude
Current amplitude of the generator.
Definition Generator.hpp:57
double phase
Current phase of the generator.
Definition Generator.hpp:62
float frequency
Current frequency of the generator.
Definition Generator.hpp:52
void notify_tick(double value) override
Notifies all registered callbacks with the current context.
Definition Generator.cpp:56
virtual void set_frequency(float frequency)
Sets the generator's frequency.
Definition Generator.cpp:32
HookId on_tick(const TypedHook< GeneratorContext > &callback)
Registers a typed callback receiving GeneratorContext directly.
Definition Generator.cpp:64
virtual double get_amplitude() const
Gets the current base amplitude.
Definition Generator.cpp:27
virtual void set_amplitude(double amplitude)
Sets the generator's amplitude.
Definition Generator.cpp:22
HookId on_tick_if(const NodeCondition &condition, const TypedHook< GeneratorContext > &callback)
Registers a conditional typed callback receiving GeneratorContext directly.
Definition Generator.cpp:69
float m_frequency
Base frequency of the generator.
NodeContext & get_last_context() override
Gets the last created context object.
Definition Generator.cpp:37
double m_amplitude
Base amplitude of the generator.
virtual void update_context(double value) override
Updates the context object for callbacks.
Definition Generator.cpp:7
double m_phase
Current phase of the generator.
HookId add(NodeHook hook, const std::type_info &key, uint8_t tag=0, std::array< double, 2 > params={})
Appends a hook with no duplicate check and returns its id.
HookId add_conditional(NodeHook hook, NodeCondition condition, const std::type_info &key, uint8_t tag=0)
Appends a hook that fires only while condition holds.
void fire(NodeContext &ctx) const
Calls every entry whose condition, if any, holds.
Definition NodeUtils.cpp:68
double value
Current sample value.
Definition Node.hpp:63
Base context class for node callbacks.
Definition Node.hpp:53
HookList m_conditional_callbacks
Hooks fired on a tick only while their condition holds.
Definition Node.hpp:485
HookList m_callbacks
Hooks fired on every tick.
Definition Node.hpp:478
bool is_gpu_compatible() const
Checks if the node supports GPU processing.
Definition Node.hpp:390
bool m_gpu_compatible
Flag indicating if the node supports GPU processing This flag is set by derived classes to indicate w...
Definition Node.hpp:450
@ NodeProcessing
Node graph processing (Nodes::NodeGraphManager)
@ API
MayaFlux/API Wrapper and convenience functions.
void operator*(const std::shared_ptr< Node > &node, double value)
Sets the generator's amplitude.
Definition Generator.cpp:45
uint64_t HookId
Identifies one registration inside a HookList.
Definition NodeUtils.hpp:60
std::function< void(ContextT &)> TypedHook
Callback function type for node processing events, parameterised on context type.
Definition NodeUtils.hpp:28
std::function< bool(NodeContext &)> NodeCondition
Predicate function type for conditional callbacks.
Definition NodeUtils.hpp:54
NodeHook adapt_hook(const TypedHook< ContextT > &hook)
Wraps a context-typed hook into a NodeHook.