11 , m_context(m_config.default_value, m_config.default_value,
12 Core::InputType::HID, 0)
32 std::vector<double> output(num_samples);
33 for (
unsigned int i = 0; i < num_samples; ++i) {
68 return history.back();
80 return value.as_scalar();
83 const auto& vec =
value.as_vector();
89 const auto& midi =
value.as_midi();
90 return static_cast<double>(midi.data2) / 127.0;
113 double diff = target -
current;
123 double diff = target -
current;
193 std::optional<std::pair<double, double>> range,
194 std::optional<NodeCondition> condition)
196 const auto tag =
static_cast<uint8_t
>(event_type);
202 std::array<double, 2> params {};
204 params = { range->first, range->second };
221 bool should_fire =
false;
229 const double epsilon = entry.params[0];
243 const double min = entry.params[0];
244 const double max = entry.params[1];
252 const double min = entry.params[0];
253 const double max = entry.params[1];
269 should_fire = entry.condition && entry.condition.value()(ctx);
HookId add(NodeHook hook, const std::type_info &key, uint8_t tag=0, std::array< double, 2 > params={})
Appends a hook with no duplicate check and returns its id.
Snapshot snapshot() const
The current entries, held stable for the lifetime of the returned object.
HookId add_conditional(NodeHook hook, NodeCondition condition, const std::type_info &key, uint8_t tag=0)
Appends a hook that fires only while condition holds.
void fire(NodeContext &ctx) const
Calls every entry whose condition, if any, holds.
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.
HookList m_conditional_callbacks
Hooks fired on a tick only while their condition holds.
double m_last_output
The most recent sample value generated by this oscillator.
HookList m_callbacks
Hooks fired on every tick.
uint64_t HookId
Identifies one registration inside a HookList.
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.
NodeHook adapt_hook(const TypedHook< ContextT > &hook)
Wraps a context-typed hook into a NodeHook.