MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Filter.hpp
Go to the documentation of this file.
1#pragma once
2
4
6
7enum coefficients : uint8_t {
10 ALL
11};
12
13/**
14 * @class FilterContext
15 * @brief Specialized context for filter node callbacks
16 *
17 * FilterContext extends the base NodeContext to provide filter-specific
18 * information to callbacks. It includes references to the filter's internal
19 * state, including input and output history buffers and coefficient vectors.
20 *
21 * This rich context enables callbacks to perform sophisticated analysis and
22 * monitoring of filter behavior, such as:
23 * - Detecting resonance conditions or instability
24 * - Analyzing filter response characteristics in real-time
25 * - Implementing adaptive processing based on filter state
26 * - Visualizing filter behavior through external interfaces
27 * - Recording filter state for later analysis or debugging
28 */
29class MAYAFLUX_API FilterContext : public NodeContext {
30public:
31 /**
32 * @brief Constructs a FilterContext with the current filter state
33 * @param value Current output sample value
34 * @param input_history Reference to the filter's input history buffer
35 * @param output_history Reference to the filter's output history buffer
36 * @param coefs_a Reference to the filter's feedback coefficients
37 * @param coefs_b Reference to the filter's feedforward coefficients
38 *
39 * Creates a context object that provides a complete snapshot of the
40 * filter's current state, including its most recent output value,
41 * history buffers, and coefficient vectors.
42 */
43 FilterContext(double value,
44 const std::vector<double>& input_history,
45 const std::vector<double>& output_history,
46 const std::vector<double>& coefs_a,
47 const std::vector<double>& coefs_b)
48 : NodeContext(value, typeid(FilterContext).name())
49 , input_history(input_history)
50 , output_history(output_history)
51 , coefs_a(coefs_a)
52 , coefs_b(coefs_b)
53 {
54 }
55
56 /**
57 * @brief Current input history buffer
58 *
59 * Contains the most recent input samples processed by the filter,
60 * with the newest sample at index 0. The size of this buffer depends
61 * on the filter's feedforward path configuration.
62 */
63 const std::vector<double>& input_history;
64
65 /**
66 * @brief Current output history buffer
67 *
68 * Contains the most recent output samples processed by the filter,
69 * with the newest sample at index 0. The size of this buffer depends
70 * on the filter's feedback path configuration.
71 */
72 const std::vector<double>& output_history;
73
74 /**
75 * @brief Current coefficients for input
76 */
77 const std::vector<double>& coefs_a;
78
79 /**
80 * @brief Current coefficients for output
81 */
82 const std::vector<double>& coefs_b;
83};
84
85/**
86 * @class FilterContextGpu
87 * @brief GPU-augmented filter context for callbacks
88 *
89 * Extends FilterContext to include GPU-uploadable data, allowing
90 * callbacks to access both CPU-side filter state and GPU-resident
91 * data for advanced processing and visualization.
92 */
93class MAYAFLUX_API FilterContextGpu : public FilterContext, public GpuVectorData {
94public:
95 FilterContextGpu(double value,
96 const std::vector<double>& input_history,
97 const std::vector<double>& output_history,
98 const std::vector<double>& coefs_a,
99 const std::vector<double>& coefs_b,
100 std::span<const float> gpu_data)
101 : FilterContext(value, input_history, output_history, coefs_a, coefs_b)
102 , GpuVectorData(gpu_data)
103 {
104 }
105};
106
107/**
108 * @brief Parses a string representation of filter order into input/output shift configuration
109 * @param str String in format "N_M" where N is input order and M is output order
110 * @return Pair of integers representing input and output shift values
111 *
112 * This utility function converts a simple string representation of filter order
113 * into the corresponding shift configuration for the filter's internal buffers.
114 */
115std::pair<int, int> shift_parser(const std::string& str);
116
117/**
118 * @class Filter
119 * @brief Base class for computational signal transformers implementing difference equations
120 *
121 * The Filter class provides a comprehensive framework for implementing digital
122 * transformations based on difference equations. It transcends traditional audio
123 * filtering concepts, offering a flexible foundation for:
124 *
125 * - Complex resonant systems for generative synthesis
126 * - Computational physical modeling components
127 * - Recursive signal transformation algorithms
128 * - Data-driven transformation design from frequency responses
129 * - Dynamic coefficient modulation for emergent behaviors
130 *
131 * At its core, the Filter implements the general difference equation:
132 * y[n] = (b₀x[n] + b₁x[n-1] + ... + bₘx[n-m]) - (a₁y[n-1] + ... + aₙy[n-n])
133 *
134 * Where:
135 * - x[n] are input values
136 * - y[n] are output values
137 * - b coefficients apply to input values (feedforward)
138 * - a coefficients apply to previous output values (feedback)
139 *
140 * This mathematical structure can represent virtually any linear time-invariant system,
141 * making it a powerful tool for signal transformation across domains. The same
142 * equations can process audio, control data, or even be applied to visual or
143 * physical simulation parameters.
144 */
145class MAYAFLUX_API Filter : public Node {
146public:
147 /**
148 * @brief Constructor using string-based filter configuration
149 * @param input Source node providing input samples
150 * @param zindex_shifts String in format "N_M" specifying filter order
151 *
152 * Creates a filter with the specified input node and order configuration.
153 * The zindex_shifts parameter provides a simple way to define filter order
154 * using a string like "2_2" for a biquad filter.
155 */
156 Filter(const std::shared_ptr<Node>& input, const std::string& zindex_shifts);
157
158 /**
159 * @brief Constructor using explicit coefficient vectors
160 * @param input Source node providing input samples
161 * @param a_coef Feedback (denominator) coefficients
162 * @param b_coef Feedforward (numerator) coefficients
163 *
164 * Creates a filter with the specified input node and coefficient vectors.
165 * This allows direct specification of filter coefficients for precise
166 * control over filter behavior.
167 */
168 Filter(const std::shared_ptr<Node>& input, const std::vector<double>& a_coef, const std::vector<double>& b_coef);
169
170 /**
171 * @brief Constructor using explicit coefficient vectors (no input node)
172 * @param a_coef Feedback (denominator) coefficients
173 * @param b_coef Feedforward (numerator) coefficients
174 *
175 * Creates a filter with the specified coefficient vectors but no input node.
176 * This can be used in scenarios where the filter operates on external data
177 * or is part of a larger processing chain.
178 */
179 Filter(const std::vector<double>& a_coef, const std::vector<double>& b_coef);
180
181 /**
182 * @brief Virtual destructor
183 */
184 ~Filter() override = default;
185
186 /**
187 * @brief Gets the current processing latency of the filter
188 * @return Latency in samples
189 *
190 * The latency is determined by the maximum of the input and output
191 * buffer sizes, representing how many samples of delay the filter introduces.
192 */
193 [[nodiscard]] inline int get_current_latency() const
194 {
195 return std::max(m_shift_config.first, m_shift_config.second);
196 }
197
198 /**
199 * @brief Gets the current shift configuration
200 * @return Pair of integers representing input and output shift values
201 *
202 * Returns the current configuration for input and output buffer sizes.
203 */
204 [[nodiscard]] inline std::pair<int, int> get_current_shift() const
205 {
206 return m_shift_config;
207 }
208
209 /**
210 * @brief Updates the filter's shift configuration
211 * @param zindex_shifts String in format "N_M" specifying new filter order
212 *
213 * Reconfigures the filter with a new order specification, resizing
214 * internal buffers as needed.
215 */
216 inline void set_shift(std::string& zindex_shifts)
217 {
218 m_shift_config = shift_parser(zindex_shifts);
219 initialize_shift_buffers();
220 }
221
222 /**
223 * @brief Updates filter coefficients
224 * @param new_coefs New coefficient values
225 * @param type Which set of coefficients to update (input, output, or both)
226 *
227 * Provides a flexible way to update filter coefficients, allowing
228 * dynamic modification of filter characteristics during processing.
229 */
230 void set_coefs(const std::vector<double>& new_coefs, coefficients type = coefficients::ALL);
231
232 /**
233 * @brief Updates coefficients from another node's output
234 * @param length Number of coefficients to update
235 * @param source Node providing coefficient values
236 * @param type Which set of coefficients to update (input, output, or both)
237 *
238 * Enables cross-domain interaction by deriving transformation coefficients from
239 * another node's output. This creates dynamic relationships between different
240 * parts of the computational graph, allowing one signal path to influence
241 * the behavior of another - perfect for generative systems where parameters
242 * evolve based on the system's own output.
243 */
244 void update_coefs_from_node(int length, const std::shared_ptr<Node>& source, coefficients type = coefficients::ALL);
245
246 /**
247 * @brief Updates coefficients from the filter's own input
248 * @param length Number of coefficients to update
249 * @param type Which set of coefficients to update (input, output, or both)
250 *
251 * Creates a self-modifying transformation where the input signal itself
252 * influences the transformation characteristics. This enables complex
253 * emergent behaviors and feedback systems where the signal's own properties
254 * determine how it will be processed, leading to evolving, non-linear responses.
255 */
256 void update_coef_from_input(int length, coefficients type = coefficients::ALL);
257
258 /**
259 * @brief Modifies a specific coefficient
260 * @param index Index of the coefficient to modify
261 * @param value New value for the coefficient
262 * @param type Which set of coefficients to update (input, output, or both)
263 *
264 * Allows precise control over individual coefficients, useful for
265 * fine-tuning filter behavior or implementing parameter automation.
266 */
267 void add_coef(int index, double value, coefficients type = coefficients::ALL);
268
269 /**
270 * @brief Resets the filter's internal state
271 *
272 * Clears the input and output history buffers, effectively
273 * resetting the filter to its initial state. This is useful
274 * when switching between audio segments to prevent artifacts.
275 */
276 virtual void reset();
277
278 /**
279 * @brief Sets the filter's output gain
280 * @param new_gain New gain value
281 *
282 * Adjusts the overall output level of the filter without
283 * changing its frequency response characteristics.
284 */
285 inline void set_gain(double new_gain) { m_gain = new_gain; }
286
287 /**
288 * @brief Gets the current gain value
289 * @return Current gain value
290 */
291 [[nodiscard]] inline double get_gain() const { return m_gain; }
292
293 /**
294 * @brief Enables or disables filter bypass
295 * @param enable True to enable bypass, false to disable
296 *
297 * When bypass is enabled, the filter passes input directly to output
298 * without applying any filtering, useful for A/B testing or
299 * temporarily disabling filters.
300 */
301 inline void set_bypass(bool enable) { m_bypass_enabled = enable; }
302
303 /**
304 * @brief Checks if bypass is currently enabled
305 * @return True if bypass is enabled, false otherwise
306 */
307 [[nodiscard]] inline bool is_bypass_enabled() const { return m_bypass_enabled; }
308
309 /**
310 * @brief Gets the filter's order
311 * @return Maximum order of the filter
312 *
313 * The filter order is determined by the maximum of the input and output
314 * coefficient counts minus one, representing the highest power of z⁻¹
315 * in the filter's transfer function.
316 */
317 [[nodiscard]] inline int get_order() const { return std::max(m_coef_a.size() - 1, m_coef_b.size() - 1); }
318
319 /**
320 * @brief Gets the input history buffer
321 * @return Constant reference to the input history vector
322 *
323 * Provides access to the filter's internal input history buffer,
324 * useful for analysis and visualization.
325 */
326 [[nodiscard]] inline const std::vector<double>& get_input_history() const { return m_input_history; }
327
328 /**
329 * @brief Gets the output history buffer
330 * @return Constant reference to the output history vector
331 *
332 * Provides access to the filter's internal output history buffer,
333 * useful for analysis and visualization.
334 */
335 [[nodiscard]] inline const std::vector<double>& get_output_history() const { return m_output_history; }
336
337 /**
338 * @brief Normalizes filter coefficients
339 * @param type Which set of coefficients to normalize (input, output, or both)
340 *
341 * Scales coefficients to ensure a[0] = 1.0 and/or maintain consistent
342 * gain at DC or Nyquist, depending on the filter type.
343 */
344 void normalize_coefficients(coefficients type = coefficients::ALL);
345
346 /**
347 * @brief Calculates the complex frequency response at a specific frequency
348 * @param frequency Frequency in Hz to analyze
349 * @param sample_rate Sample rate in Hz
350 * @return Complex frequency response (magnitude and phase)
351 *
352 * Computes the transformation's complex response at the specified frequency.
353 * This mathematical analysis can be used for visualization, further algorithmic
354 * processing, or to inform cross-domain mappings between audio properties
355 * and other computational parameters.
356 */
357 [[nodiscard]] std::complex<double> get_frequency_response(double frequency, double sample_rate) const;
358
359 /**
360 * @brief Calculates the magnitude response at a specific frequency
361 * @param frequency Frequency in Hz to analyze
362 * @param sample_rate Sample rate in Hz
363 * @return Magnitude response in linear scale
364 *
365 * Computes the filter's magnitude response at the specified frequency,
366 * representing how much the filter amplifies or attenuates that frequency.
367 */
368 [[nodiscard]] double get_magnitude_response(double frequency, double sample_rate) const;
369
370 /**
371 * @brief Calculates the phase response at a specific frequency
372 * @param frequency Frequency in Hz to analyze
373 * @param sample_rate Sample rate in Hz
374 * @return Phase response in radians
375 *
376 * Computes the filter's phase response at the specified frequency,
377 * representing the phase shift introduced by the filter at that frequency.
378 */
379 [[nodiscard]] double get_phase_response(double frequency, double sample_rate) const;
380
381 /**
382 * @brief Processes a single sample through the filter
383 * @param input The input sample
384 * @return The filtered output sample
385 *
386 * This is the core processing method that implements the difference
387 * equation for a single sample. It must be implemented by derived
388 * filter classes to define their specific filtering behavior.
389 */
390 double process_sample(double input = 0.) override = 0;
391
392 /**
393 * @brief Calculates the phase response at a specific frequency
394 * @param frequency Frequency in Hz to analyze
395 * @param sample_rate Sample rate in Hz
396 * @return Phase response in radians
397 *
398 * Computes the filter's phase response at the specified frequency,
399 * representing the phase shift introduced by the filter at that frequency.
400 */
401 std::vector<double> process_batch(unsigned int num_samples) override;
402
403 /**
404 * @brief Sets the input node for the filter
405 * @param input_node Node providing input samples
406 *
407 * Connects the filter to a source of input samples, allowing
408 * filters to be chained together or connected to generators.
409 */
410 inline void set_input_node(const std::shared_ptr<Node>& input_node) { m_input_node = input_node; }
411
412 /**
413 * @brief Gets the input node for the filter
414 * @return Node providing input samples
415 */
416 inline std::shared_ptr<Node> get_input_node() { return m_input_node; }
417
418 /**
419 * @brief Updates the feedback (denominator) coefficients
420 * @param new_coefs New coefficient values
421 *
422 * Sets the 'a' coefficients in the difference equation, which
423 * are applied to previous output samples. The method ensures
424 * proper normalization and buffer sizing.
425 */
426 void setACoefficients(const std::vector<double>& new_coefs);
427
428 /**
429 * @brief Updates the feedforward (numerator) coefficients
430 * @param new_coefs New coefficient values
431 *
432 * Sets the 'b' coefficients in the difference equation, which
433 * are applied to current and previous input samples. The method
434 * ensures proper buffer sizing.
435 */
436 void setBCoefficients(const std::vector<double>& new_coefs);
437
438 /**
439 * @brief Gets the feedback (denominator) coefficients
440 * @return Constant reference to the 'a' coefficient vector
441 *
442 * Provides access to the filter's feedback coefficients for
443 * analysis and visualization.
444 */
445 [[nodiscard]] inline const std::vector<double>& getACoefficients() const { return m_coef_a; }
446
447 /**
448 * @brief Gets the feedforward (numerator) coefficients
449 * @return Constant reference to the 'b' coefficient vector
450 *
451 * Provides access to the filter's feedforward coefficients for
452 * analysis and visualization.
453 */
454 [[nodiscard]] inline const std::vector<double>& getBCoefficients() const { return m_coef_b; }
455
456 /**
457 * @brief Provide external buffer context for input history
458 * @param context View into buffer data to use instead of internal input accumulation
459 */
460 inline void set_input_context(std::span<double> context)
461 {
462 m_external_input_context = context;
463 m_use_external_input_context = true;
464 }
465
466 /**
467 * @brief Clear external input context, resume internal accumulation
468 */
470 {
471 m_use_external_input_context = false;
472 m_external_input_context = {};
473 }
474
475 [[nodiscard]] inline bool using_external_input_context() const
476 {
477 return m_use_external_input_context;
478 }
479
480 /**
481 * @brief Gets the last created context object
482 * @return Reference to the last FilterContext object
483 */
484 NodeContext& get_last_context() override;
485
486protected:
487 /**
488 * @brief Modifies a specific coefficient in a coefficient buffer
489 * @param index Index of the coefficient to modify
490 * @param value New value for the coefficient
491 * @param buffer Reference to the coefficient buffer to modify
492 *
493 * Internal implementation for adding or modifying a coefficient
494 * in either the 'a' or 'b' coefficient vectors.
495 */
496 void add_coef_internal(uint64_t index, double value, std::vector<double>& buffer);
497
498 /**
499 * @brief Initializes the input and output history buffers
500 *
501 * Resizes the history buffers based on the current shift configuration
502 * and initializes them to zero. Called during construction and when
503 * the filter configuration changes.
504 */
505 virtual void initialize_shift_buffers();
506
507 /**
508 * @brief Updates the input history buffer with a new sample
509 * @param current_sample The new input sample
510 *
511 * Shifts the input history buffer and adds the new sample at the
512 * beginning. This maintains the history of input samples needed
513 * for the filter's feedforward path.
514 */
515 virtual void update_inputs(double current_sample);
516
517 /**
518 * @brief Updates the output history buffer with a new sample
519 * @param current_sample The new output sample
520 *
521 * Shifts the output history buffer and adds the new sample at the
522 * beginning. This maintains the history of output samples needed
523 * for the filter's feedback path.
524 */
525 virtual void update_outputs(double current_sample);
526
527 /**
528 * @brief Updates filter-specific context object
529 * @param value The current output sample value
530 *
531 * Updates FilterContext object that contains information about the filter's
532 * current state, including the current sample value, input/output history buffers,
533 * and coefficients. This context is passed to callbacks and conditions to provide
534 * them with the information they need to execute properly.
535 *
536 * The FilterContext allows callbacks to access filter-specific information
537 * beyond just the current sample value, enabling more sophisticated monitoring
538 * and analysis of filter behavior.
539 */
540 void update_context(double value) override;
541
542 /**
543 * @brief Notifies all registered callbacks with the current filter context
544 * @param value The current output sample value
545 *
546 * This method is called by the filter implementation when a new output value
547 * is produced. It creates a FilterContext object using create_context(), then
548 * calls all registered callbacks with that context.
549 *
550 * For unconditional callbacks (registered with on_tick()), the callback
551 * is always called. For conditional callbacks (registered with on_tick_if()),
552 * the callback is called only if its condition returns true.
553 *
554 * Filter implementations should call this method at appropriate points in their
555 * processing flow to trigger callbacks, typically after computing a new output value.
556 */
557 void notify_tick(double value) override;
558
559 /**
560 * @brief Builds input history from external context or internal accumulation
561 * @param current_sample Current input sample being processed
562 */
563 void build_input_history(double current_sample);
564
565 /**
566 * @brief The most recent sample value generated by this oscillator
567 *
568 * This value is updated each time process_sample() is called and can be
569 * accessed via get_last_output() without triggering additional processing.
570 * It's useful for monitoring the oscillator's state and for implementing
571 * feedback loops.
572 */
573 // double m_last_output;
574
575 /**
576 * @brief Input node providing samples to filter
577 *
578 * The filter processes samples from this node, allowing filters
579 * to be chained together or connected to generators.
580 */
581 std::shared_ptr<Node> m_input_node;
582
583 /**
584 * @brief Configuration for input and output buffer sizes
585 *
586 * Defines how many past input and output samples are stored,
587 * based on the filter's order.
588 */
589 std::pair<int, int> m_shift_config;
590
591 /**
592 * @brief Buffer storing previous input samples
593 *
594 * Maintains a history of input samples needed for the filter's
595 * feedforward path (b coefficients).
596 */
597 std::vector<double> m_input_history;
598
599 /**
600 * @brief Buffer storing previous output samples
601 *
602 * Maintains a history of output samples needed for the filter's
603 * feedback path (a coefficients).
604 */
605 std::vector<double> m_output_history;
606
607 /**
608 * @brief External input context for input history
609 *
610 * If set, the filter uses this external context for input history
611 * instead of its internal buffer. This allows sharing input history
612 * across multiple filters or nodes or from AudioBuffer sources.
613 */
614 std::span<double> m_external_input_context;
615
616 /**
617 * @brief Feedback (denominator) coefficients
618 *
619 * The 'a' coefficients in the difference equation, applied to
620 * previous output samples. a[0] is typically normalized to 1.0.
621 */
622 std::vector<double> m_coef_a;
623
624 /**
625 * @brief Feedforward (numerator) coefficients
626 *
627 * The 'b' coefficients in the difference equation, applied to
628 * current and previous input samples.
629 */
630 std::vector<double> m_coef_b;
631
632 /**
633 * @brief Overall gain factor applied to the filter output
634 *
635 * Provides a simple way to adjust the filter's output level
636 * without changing its frequency response characteristics.
637 */
638 double m_gain = 1.0;
639
640 /**
641 * @brief Flag to bypass filter processing
642 *
643 * When enabled, the filter passes input directly to output
644 * without applying any filtering.
645 */
646 bool m_bypass_enabled {};
647
648 std::vector<double> m_saved_input_history;
649 std::vector<double> m_saved_output_history;
650
651 bool m_use_external_input_context {};
652
655};
656}
FilterContextGpu(double value, const std::vector< double > &input_history, const std::vector< double > &output_history, const std::vector< double > &coefs_a, const std::vector< double > &coefs_b, std::span< const float > gpu_data)
Definition Filter.hpp:95
GPU-augmented filter context for callbacks.
Definition Filter.hpp:93
const std::vector< double > & coefs_b
Current coefficients for output.
Definition Filter.hpp:82
const std::vector< double > & input_history
Current input history buffer.
Definition Filter.hpp:63
const std::vector< double > & coefs_a
Current coefficients for input.
Definition Filter.hpp:77
FilterContext(double value, const std::vector< double > &input_history, const std::vector< double > &output_history, const std::vector< double > &coefs_a, const std::vector< double > &coefs_b)
Constructs a FilterContext with the current filter state.
Definition Filter.hpp:43
const std::vector< double > & output_history
Current output history buffer.
Definition Filter.hpp:72
Specialized context for filter node callbacks.
Definition Filter.hpp:29
void set_gain(double new_gain)
Sets the filter's output gain.
Definition Filter.hpp:285
std::vector< double > m_saved_output_history
Definition Filter.hpp:649
void set_input_context(std::span< double > context)
Provide external buffer context for input history.
Definition Filter.hpp:460
std::vector< double > m_coef_b
Feedforward (numerator) coefficients.
Definition Filter.hpp:630
std::vector< double > m_output_history
Buffer storing previous output samples.
Definition Filter.hpp:605
const std::vector< double > & get_input_history() const
Gets the input history buffer.
Definition Filter.hpp:326
const std::vector< double > & getBCoefficients() const
Gets the feedforward (numerator) coefficients.
Definition Filter.hpp:454
int get_order() const
Gets the filter's order.
Definition Filter.hpp:317
std::pair< int, int > get_current_shift() const
Gets the current shift configuration.
Definition Filter.hpp:204
bool is_bypass_enabled() const
Checks if bypass is currently enabled.
Definition Filter.hpp:307
void set_shift(std::string &zindex_shifts)
Updates the filter's shift configuration.
Definition Filter.hpp:216
std::shared_ptr< Node > m_input_node
The most recent sample value generated by this oscillator.
Definition Filter.hpp:581
std::vector< double > m_saved_input_history
Definition Filter.hpp:648
const std::vector< double > & getACoefficients() const
Gets the feedback (denominator) coefficients.
Definition Filter.hpp:445
~Filter() override=default
Virtual destructor.
void set_input_node(const std::shared_ptr< Node > &input_node)
Sets the input node for the filter.
Definition Filter.hpp:410
int get_current_latency() const
Gets the current processing latency of the filter.
Definition Filter.hpp:193
double get_gain() const
Gets the current gain value.
Definition Filter.hpp:291
std::vector< double > m_input_history
Buffer storing previous input samples.
Definition Filter.hpp:597
void clear_input_context()
Clear external input context, resume internal accumulation.
Definition Filter.hpp:469
FilterContextGpu m_context_gpu
Definition Filter.hpp:654
std::pair< int, int > m_shift_config
Configuration for input and output buffer sizes.
Definition Filter.hpp:589
std::span< double > m_external_input_context
External input context for input history.
Definition Filter.hpp:614
const std::vector< double > & get_output_history() const
Gets the output history buffer.
Definition Filter.hpp:335
std::vector< double > m_coef_a
Feedback (denominator) coefficients.
Definition Filter.hpp:622
double process_sample(double input=0.) override=0
Processes a single sample through the filter.
void set_bypass(bool enable)
Enables or disables filter bypass.
Definition Filter.hpp:301
std::shared_ptr< Node > get_input_node()
Gets the input node for the filter.
Definition Filter.hpp:416
bool using_external_input_context() const
Definition Filter.hpp:475
Base class for computational signal transformers implementing difference equations.
Definition Filter.hpp:145
GPU-uploadable 1D array data interface.
Base context class for node callbacks.
Definition Node.hpp:30
Base interface for all computational processing nodes.
Definition Node.hpp:109
std::pair< int, int > shift_parser(const std::string &str)
Parses a string representation of filter order into input/output shift configuration.
Definition Filter.cpp:7