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;
201 std::optional<double> threshold,
202 std::optional<std::pair<double, double>> range,
203 std::optional<NodeCondition> condition)
205 m_input_callbacks.emplace_back(callback, event_type, std::move(condition), threshold, range);
218 if (condition(ctx)) {
224 bool should_fire =
false;
226 switch (cb.event_type) {
232 double epsilon = cb.threshold.value_or(0.0001);
238 should_fire = (
m_previous_value < cb.threshold.value() && value >= cb.threshold.value());
242 should_fire = (
m_previous_value >= cb.threshold.value() && value < cb.threshold.value());
246 auto [min, max] = cb.range.value();
247 bool in_range_now = (value >= min && value <= max);
254 auto [min, max] = cb.range.value();
255 bool in_range_now = (value >= min && value <= max);
270 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.
Context for InputNode callbacks - provides input event access.
double value
Current sample value.
Base context class for node callbacks.
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(ContextT &)> TypedHook
Callback function type for node processing events, parameterised on context type.
std::function< bool(NodeContext &)> NodeCondition
Predicate function type for conditional callbacks.