MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Nodes/Generators/Random.cpp
Go to the documentation of this file.
1#include "Random.hpp"
2
4
6 : m_generator(type)
7 , m_type(type)
8 , m_context(0.0, type, 1.0, m_current_start, m_current_end, m_normal_spread)
9 , m_context_gpu(0.0, type, 1.0, m_current_start, m_current_end, m_normal_spread, get_gpu_data_buffer())
10{
11}
12
18
30
31std::vector<double> Random::process_batch(unsigned int num_samples)
32{
33 auto samples = m_generator.batch(m_current_start, m_current_end, num_samples);
34
35 for (auto& sample : samples) {
36 sample *= m_amplitude;
37 }
38
39 return samples;
40}
41
42void Random::set_normal_spread(double spread)
43{
44 m_generator.configure("spread", spread);
45}
46
47void Random::set_range(double start, double end)
48{
49 m_current_start = start;
50 m_current_end = end;
51}
52
75
77{
78 if (m_gpu_compatible) {
79 return m_context_gpu;
80 }
81 return m_context;
82}
83
84}
Core::GlobalInputConfig input
Definition Config.cpp:36
void configure(const std::string &key, std::any value)
Configures algorithm-specific parameters.
std::vector< double > batch(double min, double max, size_t count)
Batch generation.
Algorithm get_algorithm() const
Gets current algorithm.
void set_algorithm(Algorithm algo)
Changes active algorithm.
void notify_tick(double value) override
Notifies all registered callbacks with the current context.
Definition Generator.cpp:70
double m_amplitude
Base amplitude of the generator.
double normal_spread
Current variance parameter for normal distribution.
double amplitude
Current amplitude scaling factor.
double range_end
Current upper bound of the range.
double range_start
Current lower bound of the range.
Kinesis::Stochastic::Algorithm distribution_type
Current distribution type.
Kinesis::Stochastic::Stochastic m_generator
Core stochastic generator instance.
void set_range(double start, double end)
Sets the output value range.
double m_normal_spread
Variance parameter for normal distribution.
Kinesis::Stochastic::Algorithm m_type
Current probability distribution algorithm.
NodeContext & get_last_context() override
Gets the last created context object.
Random(Kinesis::Stochastic::Algorithm type=Kinesis::Stochastic::Algorithm::UNIFORM)
Constructor for the stochastic generator.
std::vector< double > process_batch(unsigned int num_samples) override
Generates multiple stochastic values at once.
double m_current_start
Lower bound of the current output range.
void set_normal_spread(double spread)
Sets the variance parameter for normal distribution.
void set_type(Kinesis::Stochastic::Algorithm type)
Changes the probability distribution type.
double process_sample(double input=0.) override
Generates a single stochastic value.
void update_context(double value) override
Updates the context object with the current node state.
double m_current_end
Upper bound of the current output range.
double value
Current sample value.
Definition Node.hpp:63
Base context class for node callbacks.
Definition Node.hpp:53
bool m_state_saved
tracks if the node's state has been saved by a snapshot operation
Definition Node.hpp:457
bool m_networked_node
Flag indicating if the node is part of a NodeNetwork This flag is used to disable event firing when t...
Definition Node.hpp:452
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:405
bool m_fire_events_during_snapshot
Internal flag controlling whether notify_tick fires during state snapshots Default: false (events don...
Definition Node.hpp:487
bool m_gpu_compatible
Flag indicating if the node supports GPU processing This flag is set by derived classes to indicate w...
Definition Node.hpp:414
Algorithm
Stochastic and procedural generation algorithms.