|
MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
|
Computational stochastic signal generator with multiple probability distributions. More...
#include <Stochastic.hpp>
Inheritance diagram for MayaFlux::Nodes::Generator::Stochastics::Random:
Collaboration diagram for MayaFlux::Nodes::Generator::Stochastics::Random:Public Member Functions | |
| Random (Utils::distribution type=Utils::distribution::UNIFORM) | |
| Constructor for the stochastic generator. | |
| ~Random () override=default | |
| Virtual destructor. | |
| void | set_type (Utils::distribution type) |
| Changes the probability distribution type. | |
| double | process_sample (double input=0.) override |
| Generates a single stochastic value. | |
| double | random_sample (double start, double end) |
| Generates a stochastic value within a specified range. | |
| std::vector< double > | process_batch (unsigned int num_samples) override |
| Generates multiple stochastic values at once. | |
| std::vector< double > | random_array (double start, double end, unsigned int num_samples) |
| Generates an array of stochastic values within a specified range. | |
| void | printGraph () override |
| Visualizes the distribution characteristics. | |
| void | printCurrent () override |
| Outputs the current configuration parameters. | |
| void | set_normal_spread (double spread) |
| Sets the variance parameter for normal distribution. | |
| void | save_state () override |
| Saves the node's current state for later restoration Recursively cascades through all connected modulator nodes Protected - only NodeSourceProcessor and NodeBuffer can call. | |
| void | restore_state () override |
| Restores the node's state from the last save Recursively cascades through all connected modulator nodes Protected - only NodeSourceProcessor and NodeBuffer can call. | |
Public Member Functions inherited from MayaFlux::Nodes::Generator::Generator | |
| virtual | ~Generator ()=default |
| Virtual destructor for proper cleanup. | |
| virtual void | set_amplitude (double amplitude) |
| Sets the generator's amplitude. | |
| virtual double | get_amplitude () const |
| Gets the current base amplitude. | |
| virtual void | enable_mock_process (bool mock_process) |
| Allows RootNode to process the Generator without using the processed sample. | |
| virtual bool | should_mock_process () const |
| Checks if the generator should mock process. | |
| virtual void | set_frequency (float frequency) |
| Sets the generator's frequency. | |
Public Member Functions inherited from MayaFlux::Nodes::Node | |
| virtual | ~Node ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
| virtual void | on_tick (const NodeHook &callback) |
| Registers a callback to be called on each tick. | |
| virtual void | on_tick_if (const NodeCondition &condition, const NodeHook &callback) |
| Registers a conditional callback. | |
| virtual bool | remove_hook (const NodeHook &callback) |
| Removes a previously registered callback. | |
| virtual bool | remove_conditional_hook (const NodeCondition &callback) |
| Removes a previously registered conditional callback. | |
| virtual void | remove_all_hooks () |
| Removes all registered callbacks. | |
| virtual void | reset_processed_state () |
| Resets the processed state of the node and any attached input nodes. | |
| virtual double | get_last_output () |
| Retrieves the most recent output value produced by the node. | |
| void | register_channel_usage (uint32_t channel_id) |
| Mark the specificed channel as a processor/user. | |
| void | unregister_channel_usage (uint32_t channel_id) |
| Removes the specified channel from the usage tracking. | |
| bool | is_used_by_channel (uint32_t channel_id) const |
| Checks if the node is currently used by a specific channel. | |
| void | request_reset_from_channel (uint32_t channel_id) |
| Requests a reset of the processed state from a specific channel. | |
| const std::atomic< uint32_t > & | get_channel_mask () const |
| Retrieves the current bitmask of active channels using this node. | |
| void | set_gpu_compatible (bool compatible) |
| Sets whether the node is compatible with GPU processing. | |
| bool | is_gpu_compatible () const |
| Checks if the node supports GPU processing. | |
| std::span< const float > | get_gpu_data_buffer () const |
| Provides access to the GPU data buffer. | |
| bool | try_claim_snapshot_context (uint64_t context_id) |
| Attempt to claim snapshot context for this processing cycle. | |
| bool | is_in_snapshot_context (uint64_t context_id) const |
| Check if currently in a snapshot context. | |
| void | release_snapshot_context (uint64_t context_id) |
| Release snapshot context. | |
| bool | has_active_snapshot () const |
| Check if node is currently being snapshotted by any context. | |
| uint64_t | get_active_snapshot_context () const |
| Get the active snapshot context ID. | |
| void | add_buffer_reference () |
| Increments the buffer reference count This method is called when a new buffer starts using this node to ensure proper lifecycle management. | |
| void | remove_buffer_reference () |
| Decrements the buffer reference count This method is called when a buffer stops using this node to ensure proper lifecycle management. | |
| bool | mark_buffer_processed () |
| Marks the node as having been processed by a buffer. | |
| void | request_buffer_reset () |
| Requests a reset of the buffer state. | |
| bool | is_buffer_processed () const |
| Checks if the buffer has been processed. | |
| bool | is_in_network () const |
| Sets whether the node is part of a NodeNetwork. | |
| void | set_in_network (bool networked) |
| Marks the node as being part of a NodeNetwork. | |
Protected Member Functions | |
| void | update_context (double value) override |
| Updates the context object with the current node state. | |
| void | notify_tick (double value) override |
| Notifies all registered callbacks about a new value. | |
| NodeContext & | get_last_context () override |
| Gets the last created context object. | |
Protected Member Functions inherited from MayaFlux::Nodes::Node | |
| virtual void | reset_processed_state_internal () |
| Resets the processed state of the node directly. | |
Private Member Functions | |
| double | generate_distributed_sample () |
| Generates a raw value according to the current distribution. | |
| double | transform_sample (double sample, double start, double end) const |
| Transforms a raw value to fit within the specified range. | |
| void | validate_range (double start, double end) const |
| Validates that the specified range is mathematically valid. | |
| double | fast_uniform () noexcept |
| Fast uniform random number generator using xorshift algorithm. | |
| void | rebuild_distributions_if_needed () noexcept |
| Rebuilds distribution objects if parameters have changed. | |
Private Attributes | |
| std::mt19937 | m_random_engine |
| Mersenne Twister entropy generator. | |
| Utils::distribution | m_type |
| Current probability distribution algorithm. | |
| double | m_current_start |
| Lower bound of the current output range. | |
| double | m_current_end |
| Upper bound of the current output range. | |
| double | m_normal_spread |
| Variance parameter for normal distribution. | |
| std::normal_distribution< double > | m_normal_dist { 0.0, 1.0 } |
| Normal distribution with mean 0 and standard deviation 1. | |
| std::exponential_distribution< double > | m_exponential_dist { 1.0 } |
| Exponential distribution with lambda = 1. | |
| uint64_t | m_xorshift_state |
| Internal state for xorshift random number generation. | |
| StochasticContext | m_context |
| StochasticContextGpu | m_context_gpu |
| double | m_cached_start = -1.0 |
| double | m_cached_end = 1.0 |
| double | m_cached_spread = 4.0 |
| bool | m_dist_dirty = true |
Additional Inherited Members | |
Public Attributes inherited from MayaFlux::Nodes::Node | |
| bool | m_fire_events_during_snapshot = false |
| Internal flag controlling whether notify_tick fires during state snapshots Default: false (events don't fire during isolated buffer processing) Can be exposed in future if needed via concrete implementation in parent. | |
| std::atomic< Utils::NodeState > | m_state { Utils::NodeState::INACTIVE } |
| Atomic state flag tracking the node's processing status. | |
| std::atomic< uint32_t > | m_modulator_count { 0 } |
| Counter tracking how many other nodes are using this node as a modulator. | |
Protected Attributes inherited from MayaFlux::Nodes::Generator::Generator | |
| double | m_amplitude { 1.0 } |
| Base amplitude of the generator. | |
| float | m_frequency { 440.0F } |
| Base frequency of the generator. | |
| double | m_phase {} |
| Current phase of the generator. | |
| GeneratorContext | m_context { 0., m_frequency, m_amplitude, m_phase } |
| GeneratorContextGpu | m_context_gpu { 0., m_frequency, m_amplitude, m_phase, get_gpu_data_buffer() } |
Protected Attributes inherited from MayaFlux::Nodes::Node | |
| double | m_last_output { 0 } |
| The most recent sample value generated by this oscillator. | |
| bool | m_gpu_compatible {} |
| Flag indicating if the node supports GPU processing This flag is set by derived classes to indicate whether the node can be processed on the GPU. | |
| std::vector< float > | m_gpu_data_buffer |
| GPU data buffer for context objects. | |
| std::vector< NodeHook > | m_callbacks |
| Collection of standard callback functions. | |
| std::vector< std::pair< NodeHook, NodeCondition > > | m_conditional_callbacks |
| Collection of conditional callback functions with their predicates. | |
| bool | m_networked_node {} |
| Flag indicating if the node is part of a NodeNetwork This flag is used to disable event firing when the node is managed within a NodeNetwork, preventing redundant or conflicting event notifications. | |
| bool | m_state_saved {} |
| tracks if the node's state has been saved by a snapshot operation | |
Computational stochastic signal generator with multiple probability distributions.
The Random generates algorithmic signals based on mathematical probability distributions, serving as a foundational component for generative composition, procedural sound design, and data-driven audio transformation. Unlike deterministic processes, stochastic generators introduce controlled mathematical randomness into computational signal paths.
Stochastic processes are fundamental in computational audio for:
This implementation supports multiple probability distributions:
The Random can function at any rate - from audio-rate signal generation to control-rate parameter modulation, to event-level algorithmic decision making. It can be integrated with other computational domains (graphics, physics, data) to create cross-domain generative systems.
Definition at line 128 of file Stochastic.hpp.