119 ModalNetwork(
size_t num_modes,
double fundamental = 220.0,
120 Spectrum spectrum = Spectrum::HARMONIC,
double base_decay = 1.0);
129 ModalNetwork(
const std::vector<double>& frequency_ratios,
130 double fundamental = 220.0,
double base_decay = 1.0);
136 void process_batch(
unsigned int num_samples)
override;
140 return m_modes.size();
145 void reset()
override;
147 [[nodiscard]] std::unordered_map<std::string, std::string>
148 get_metadata()
const override;
150 [[nodiscard]] std::optional<std::span<const double>>
151 get_node_audio_buffer(
size_t index)
const override;
157 void map_parameter(
const std::string& param_name,
158 const std::shared_ptr<Node>& source,
159 MappingMode mode = MappingMode::BROADCAST)
override;
162 map_parameter(
const std::string& param_name,
163 const std::shared_ptr<NodeNetwork>& source_network)
override;
165 void unmap_parameter(
const std::string& param_name)
override;
178 void excite(
double strength = 1.0);
185 void excite_mode(
size_t mode_index,
double strength = 1.0);
191 void damp(
double damping_factor = 0.1);
218 m_decay_multiplier = multiplier;
224 [[nodiscard]]
const std::vector<ModalNode>&
get_modes()
const
234 return m_modes.at(index);
242 [[nodiscard]] std::optional<double> get_node_output(
size_t index)
const override;
252 void set_exciter_type(ExciterType type);
258 void set_exciter_duration(
double seconds);
264 void set_exciter_filter(
const std::shared_ptr<Filters::Filter>& filter) { m_exciter_filter = filter; }
270 void set_exciter_sample(
const std::vector<double>& sample);
278 m_exciter_node = node;
297 void excite_at_position(
double position,
double strength = 1.0);
306 void set_spatial_distribution(
const std::vector<double>& distribution);
313 return m_spatial_distribution;
336 void set_mode_coupling(
size_t mode_a,
size_t mode_b,
double strength);
341 void remove_mode_coupling(
size_t mode_a,
size_t mode_b);
367 double m_decay_multiplier = 1.0;
376 double m_exciter_duration { 0.01 };
377 double m_exciter_strength { 1.0 };
383 size_t m_exciter_sample_position {};
384 size_t m_exciter_node_buffer_pos {};
385 bool m_exciter_active {};
386 size_t m_exciter_samples_remaining {};
405 bool m_coupling_enabled {};
414 double generate_exciter_sample();
419 void initialize_exciter(
double strength);
424 void compute_spatial_distribution();
429 void compute_mode_coupling();
438 static std::vector<double> generate_spectrum_ratios(Spectrum spectrum,
444 void initialize_modes(
const std::vector<double>& ratios,
double base_decay);
449 void update_mapped_parameters();
454 void apply_broadcast_parameter(
const std::string& param,
double value);
459 void apply_one_to_one_parameter(
const std::string& param,
460 const std::shared_ptr<NodeNetwork>& source);
Unified generative infrastructure for stochastic and procedural algorithms.
double get_fundamental() const
Get current fundamental frequency.
std::shared_ptr< Filters::Filter > m_exciter_filter
std::vector< std::vector< double > > m_node_buffers
Per-mode sample buffers populated each process_batch()
ExciterType
Excitation signal types for modal synthesis.
void set_exciter_filter(const std::shared_ptr< Filters::Filter > &filter)
Set filter for shaped noise excitation.
void set_coupling_enabled(bool enable)
Enable/disable modal coupling.
void set_exciter_node(const std::shared_ptr< Node > &node)
Set continuous exciter node.
void set_decay_multiplier(double multiplier)
Set global decay multiplier.
Kinesis::Stochastic::Stochastic m_random_generator
const std::vector< ModalNode > & get_modes() const
Get mode data (read-only access for visualization)
const ModalNode & get_mode(size_t index) const
Get specific mode.
ExciterType get_exciter_type() const
std::vector< ModeCoupling > m_couplings
bool is_coupling_enabled() const
Check if coupling is enabled.
size_t get_node_count() const override
Get the number of nodes in the network.
void initialize() override
Called once before first process_batch()
const auto & get_couplings() const
Get all active couplings.
std::vector< ModalNode > m_modes
std::vector< double > m_exciter_node_buffer
std::shared_ptr< Node > m_exciter_node
void clear_couplings()
Clear all mode couplings.
std::vector< double > m_exciter_sample
Spectrum
Predefined frequency relationship patterns.
std::vector< double > m_spatial_distribution
const std::vector< double > & get_spatial_distribution() const
Get current spatial distribution.
Network of resonant modes for modal synthesis.
Abstract base class for structured collections of nodes with defined relationships.
MappingMode
Defines how nodes map to external entities (e.g., audio channels, graphics objects)
double base_frequency
Frequency without modulation.
double decay_coefficient
Precomputed exp factor.
double initial_amplitude
Amplitude at excitation.
size_t index
Index in network.
std::shared_ptr< Generator::Generator > oscillator
Sine wave generator.
double frequency_ratio
Ratio relative to fundamental.
double current_frequency
After mapping/modulation.
double decay_time
Time constant for amplitude decay (seconds)
double amplitude
Current amplitude (0.0 to 1.0)
Represents a single resonant mode.