MayaFlux 0.3.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
7void Generator::enable_mock_process(bool mock_process)
8{
9 if (mock_process) {
11 } else {
13 }
14}
15
17{
18 return m_state.load() & NodeState::MOCK_PROCESS;
19}
20
35
36void Generator::set_amplitude(double amplitude)
37{
38 m_amplitude = amplitude;
39}
40
42{
43 return m_amplitude;
44}
45
50
52{
53 if (is_gpu_compatible()) {
54 return m_context_gpu;
55 }
56 return m_context;
57}
58
59void operator*(const std::shared_ptr<Node>& node, double value)
60{
61 if (auto gen = std::dynamic_pointer_cast<Generator>(node)) {
62 gen->set_amplitude(value);
63 } else {
65 "Cannot multiply non-generator node by a scalar. "
66 "Use set_[params] methods or create a BinaryOpNode.");
67 }
68}
69
70} // namespace MayaFlux::Nodes::Generator
#define MF_ERROR(comp, ctx,...)
double frequency
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
virtual void set_frequency(float frequency)
Sets the generator's frequency.
Definition Generator.cpp:46
virtual bool should_mock_process() const
Checks if the generator should mock process.
Definition Generator.cpp:16
virtual double get_amplitude() const
Gets the current base amplitude.
Definition Generator.cpp:41
virtual void set_amplitude(double amplitude)
Sets the generator's amplitude.
Definition Generator.cpp:36
float m_frequency
Base frequency of the generator.
NodeContext & get_last_context() override
Gets the last created context object.
Definition Generator.cpp:51
double m_amplitude
Base amplitude of the generator.
virtual void update_context(double value) override
Updates the context object for callbacks.
Definition Generator.cpp:21
virtual void enable_mock_process(bool mock_process)
Allows RootNode to process the Generator without using the processed sample.
Definition Generator.cpp:7
double m_phase
Current phase of the generator.
double value
Current sample value.
Definition Node.hpp:40
Base context class for node callbacks.
Definition Node.hpp:30
std::atomic< NodeState > m_state
Atomic state flag tracking the node's processing status.
Definition Node.hpp:470
bool is_gpu_compatible() const
Checks if the node supports GPU processing.
Definition Node.hpp:329
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:386
@ 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:59
@ MOCK_PROCESS
Node should be processed but output ignored.
Definition NodeSpec.hpp:48
void atomic_add_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically adds a flag to a node state.
Definition NodeUtils.cpp:94
void atomic_remove_flag(std::atomic< NodeState > &state, NodeState flag)
Atomically removes a flag from a node state.