31class MAYAFLUX_API
Phasor :
public Generator,
public std::enable_shared_from_this<Phasor> {
53 Phasor(
const std::shared_ptr<Node>& frequency_modulator,
float frequency = 1,
double amplitude = 1,
float offset = 0);
65 Phasor(
float frequency,
const std::shared_ptr<Node>& amplitude_modulator,
double amplitude = 1,
float offset = 0);
78 Phasor(
const std::shared_ptr<Node>& frequency_modulator,
const std::shared_ptr<Node>& amplitude_modulator,
79 float frequency = 1,
double amplitude = 1,
float offset = 0);
94 double process_sample(
double input = 0.)
override;
104 std::vector<double> process_batch(
unsigned int num_samples)
override;
112 void set_frequency(
float frequency)
override;
131 m_amplitude = amplitude;
143 void set_frequency_modulator(
const std::shared_ptr<Node>& modulator);
152 void set_amplitude_modulator(
const std::shared_ptr<Node>& modulator);
160 void clear_modulators();
172 void reset(
float frequency = 1,
float amplitude = 1.0,
float offset = 0,
double phase = 0.0);
185 while (m_phase >= 1.0)
187 while (m_phase < 0.0)
242 m_conditional_callbacks.clear();
243 m_phase_wrap_callbacks.clear();
244 m_threshold_callbacks.clear();
247 void save_state()
override;
248 void restore_state()
override;
254 [[nodiscard]] std::vector<std::pair<ModulatorRole, std::shared_ptr<Node>>> get_modulators()
const override;
265 void notify_tick(
double value)
override;
284 double m_phase_inc {};
308 void update_phase_increment(
double frequency);
330 double m_saved_phase {};
331 float m_saved_frequency {};
332 float m_saved_offset {};
333 double m_saved_phase_inc {};
334 double m_saved_last_output {};
Core::GlobalInputConfig input
Base class for all signal and pattern generators in Maya Flux.
std::shared_ptr< Node > m_frequency_modulator
Node that modulates the frequency.
float get_frequency() const
Gets the current base frequency.
bool m_threshold_crossed
Flag indicating whether the threshold has been crossed in the current sample.
bool m_phase_wrapped
Flag indicating whether the phase has wrapped in the current sample.
void set_phase(double phase)
Sets the current phase of the phasor.
std::shared_ptr< Node > m_amplitude_modulator
Node that modulates the amplitude.
std::vector< std::pair< TypedHook< GeneratorContext >, double > > m_threshold_callbacks
Collection of threshold-specific callback functions with their thresholds.
double get_phase() const
Gets the current phase of the phasor.
void remove_all_hooks() override
Removes all registered callbacks.
void set_params(float frequency, double amplitude, float offset)
Sets all basic parameters at once.
~Phasor() override=default
Virtual destructor.
std::vector< TypedHook< GeneratorContext > > m_phase_wrap_callbacks
Collection of phase wrap-specific callback functions.
float m_offset
DC offset added to the output.
Phase ramp generator node.
std::function< void(ContextT &)> TypedHook
Callback function type for node processing events, parameterised on context type.