11 , m_context(m_config.default_value, m_config.default_value,
12 Core::InputType::HID, 0)
33 std::vector<double> output(num_samples);
34 for (
unsigned int i = 0; i < num_samples; ++i) {
70 return history.back();
91 const auto& midi = value.
as_midi();
92 return static_cast<double>(midi.data2) / 127.0;
115 double diff = target - current;
125 double diff = target - current;
184 std::optional<double> threshold,
185 std::optional<std::pair<double, double>> range,
186 std::optional<NodeCondition> condition)
189 .event_type = event_type,
190 .condition = std::move(condition),
191 .threshold = threshold,
204 if (condition(ctx)) {
210 bool should_fire =
false;
212 switch (cb.event_type) {
218 double epsilon = cb.threshold.value_or(0.0001);
224 should_fire = (
m_previous_value < cb.threshold.value() && value >= cb.threshold.value());
228 should_fire = (
m_previous_value >= cb.threshold.value() && value < cb.threshold.value());
232 auto [min, max] = cb.range.value();
233 bool in_range_now = (value >= min && value <= max);
240 auto [min, max] = cb.range.value();
241 bool in_range_now = (value >= min && value <= max);
256 should_fire = cb.condition && cb.condition.value()(ctx);
uint32_t device_id
Source device ID.
double raw_value
Unsmoothed input value.
Core::InputType source_type
Backend that produced this input.
double value
Current sample value.
Base context class for node callbacks.
virtual void on_tick_if(const NodeCondition &condition, const NodeHook &callback)
Registers a conditional callback.
std::vector< NodeHook > m_callbacks
Collection of standard callback functions.
double m_last_output
The most recent sample value generated by this oscillator.
std::vector< std::pair< NodeHook, NodeCondition > > m_conditional_callbacks
Collection of conditional callback functions with their predicates.
std::function< void(NodeContext &)> NodeHook
Callback function type for node processing events.