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);
213 m_decay_multiplier = multiplier;
219 [[nodiscard]]
const std::vector<ModalNode>&
get_modes()
const
229 return m_modes.at(index);
237 [[nodiscard]] std::optional<double> get_node_output(
size_t index)
const override;
253 void set_exciter_duration(
double seconds);
259 void set_exciter_filter(
const std::shared_ptr<Filters::Filter>& filter) { m_exciter_filter = filter; }
265 void set_exciter_sample(
const std::vector<double>& sample);
273 m_exciter_node = node;
292 void excite_at_position(
double position,
double strength = 1.0);
301 void set_spatial_distribution(
const std::vector<double>& distribution);
308 return m_spatial_distribution;
331 void set_mode_coupling(
size_t mode_a,
size_t mode_b,
double strength);
336 void remove_mode_coupling(
size_t mode_a,
size_t mode_b);
362 double m_decay_multiplier = 1.0;
371 double m_exciter_duration { 0.01 };
376 size_t m_exciter_sample_position { 0 };
377 bool m_exciter_active {
false };
378 size_t m_exciter_samples_remaining { 0 };
397 bool m_coupling_enabled {
false };
406 double generate_exciter_sample();
411 void initialize_exciter(
double strength);
416 void compute_spatial_distribution();
421 void compute_mode_coupling();
430 static std::vector<double> generate_spectrum_ratios(Spectrum spectrum,
436 void initialize_modes(
const std::vector<double>& ratios,
double base_decay);
441 void update_mapped_parameters();
446 void apply_broadcast_parameter(
const std::string& param,
double value);
451 void apply_one_to_one_parameter(
const std::string& param,
452 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.
void set_exciter_type(ExciterType type)
Set exciter type.
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::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.