102 ModalNetwork(
size_t num_modes,
double fundamental = 220.0,
103 Spectrum spectrum = Spectrum::HARMONIC,
double base_decay = 1.0);
112 ModalNetwork(
const std::vector<double>& frequency_ratios,
113 double fundamental = 220.0,
double base_decay = 1.0);
119 void process_batch(
unsigned int num_samples)
override;
123 return m_modes.size();
128 void reset()
override;
130 [[nodiscard]] std::unordered_map<std::string, std::string>
131 get_metadata()
const override;
137 void map_parameter(
const std::string& param_name,
138 const std::shared_ptr<Node>& source,
139 MappingMode mode = MappingMode::BROADCAST)
override;
142 map_parameter(
const std::string& param_name,
143 const std::shared_ptr<NodeNetwork>& source_network)
override;
145 void unmap_parameter(
const std::string& param_name)
override;
158 void excite(
double strength = 1.0);
165 void excite_mode(
size_t mode_index,
double strength = 1.0);
171 void damp(
double damping_factor = 0.1);
179 void set_fundamental(
double frequency);
193 m_decay_multiplier = multiplier;
199 [[nodiscard]]
const std::vector<ModalNode>&
get_modes()
const
209 return m_modes.at(index);
217 [[nodiscard]] std::optional<double> get_node_output(
size_t index)
const override;
227 double m_decay_multiplier = 1.0;
230 mutable double m_last_output = 0.0;
239 static std::vector<double> generate_spectrum_ratios(
Spectrum spectrum,
245 void initialize_modes(
const std::vector<double>& ratios,
double base_decay);
250 void update_mapped_parameters();
255 void apply_broadcast_parameter(
const std::string& param,
double value);
260 void apply_one_to_one_parameter(
const std::string& param,
261 const std::shared_ptr<NodeNetwork>& source);
Spectrum
Predefined frequency relationship patterns.
std::vector< ModalNode > m_modes
size_t get_node_count() const override
Get the number of nodes in the network.
void initialize() override
Called once before first process_batch()
double get_fundamental() const
Get current fundamental frequency.
const ModalNode & get_mode(size_t index) const
Get specific mode.
void set_decay_multiplier(double multiplier)
Set global decay multiplier.
const std::vector< ModalNode > & get_modes() const
Get mode data (read-only access for visualization)
Network of resonant modes for modal synthesis.
Abstract base class for structured collections of nodes with defined relationships.
Contains the node-based computational processing system components.
std::shared_ptr< Generator::Generator > oscillator
Sine wave generator.
double decay_time
Time constant for amplitude decay (seconds)
double decay_coefficient
Precomputed exp factor.
double frequency_ratio
Ratio relative to fundamental.
double base_frequency
Frequency without modulation.
double current_frequency
After mapping/modulation.
size_t index
Index in network.
double initial_amplitude
Amplitude at excitation.
double amplitude
Current amplitude (0.0 to 1.0)
Represents a single resonant mode.