26class MAYAFLUX_API
Counter :
public Generator,
public std::enable_shared_from_this<Counter> {
33 Counter(uint32_t modulo = 16, int32_t step = 1);
41 Counter(
const std::shared_ptr<Node>& reset_trigger, uint32_t modulo = 16, int32_t step = 1);
45 double process_sample(
double input = 0.0)
override;
47 std::vector<double> process_batch(
unsigned int num_samples)
override;
53 void set_modulo(uint32_t modulo);
59 void set_step(int32_t step);
65 void set_reset_trigger(
const std::shared_ptr<Node>& trigger);
70 void clear_reset_trigger();
78 [[nodiscard]] uint32_t
get_count()
const {
return m_count; }
81 [[nodiscard]] uint32_t
get_modulo()
const {
return m_modulo; }
84 [[nodiscard]] int32_t
get_step()
const {
return m_step; }
105 bool remove_hook(
const NodeHook& callback)
override;
106 void remove_all_hooks()
override;
111 void save_state()
override;
112 void restore_state()
override;
118 [[nodiscard]] std::vector<std::pair<ModulatorRole, std::shared_ptr<Node>>> get_modulators()
const override;
121 void notify_tick(
double value)
override;
122 void update_context(
double value)
override;
125 uint32_t m_count { 0 };
126 uint32_t m_modulo { 16 };
127 int32_t m_step { 1 };
130 double m_last_trigger_value { 0.0 };
132 uint32_t m_saved_count { 0 };
133 double m_saved_last_trigger_value { 0.0 };
134 double m_saved_last_output { 0.0 };
136 bool m_wrapped {
false };