### instance Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Static function to get the singleton instance of ConfigParserRegistry. ```C++ static inline ConfigParserRegistry &instance() { // Static function to get the singleton instance of ConfigParserRegistry. } ``` -------------------------------- ### DSP Object Creation from Configuration JSON Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Demonstrates how to get a DSP object from a provided configuration JSON object, with an option to also retrieve the configuration data. ```C++ std::unique_ptr get_dsp(const nlohmann::json &config, dspData &returnedConfig) std::unique_ptr get_dsp(const nlohmann::json &config) ``` -------------------------------- ### Activation processing (gated mode example) Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt This C++ code snippet demonstrates the activation processing logic when the gating mode is set to GATED. It applies a gating activation and optionally a post-activation FiLM. ```cpp if (this->_gating_mode == GatingMode::GATED) { auto input_block = this->_z.leftCols(num_frames); auto output_block = this->_z.topRows(bottleneck).leftCols(num_frames); this->_gating_activation->apply(input_block, output_block); if (this->_activation_post_film) { this->_activation_post_film->Process(this->_z.topRows(bottleneck), condition, num_frames); this->_z.topRows(bottleneck).leftCols(num_frames).noalias() = this->_activation_post_film->GetOutput().leftCols(num_frames); } } ``` -------------------------------- ### Helper Registration Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Registration helper for factories (external code compatibility). Wraps a FactoryFunction into a ConfigParserRegistry entry via FactoryConfig. Use this to register external architectures. Create a static instance to automatically register a factory when the program starts. ```cpp struct Helper { inline Helper(const std::string &name, FactoryFunction factory) // Parameters: // name – Architecture name // factory – Factory function } ``` -------------------------------- ### Process Input to Output (Legacy) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html A legacy method for processing input and writing to an output matrix. It allows specifying start indices and the number of columns to process, maintaining compatibility with older versions. ```cpp void process_(const Eigen::MatrixXf &input, Eigen::MatrixXf &output, const long i_start, const long ncols, const long j_start) const ``` -------------------------------- ### GetOutput (const) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Get the entire internal output buffer (const version). ```C++ inline const Eigen::MatrixXf &GetOutput() const { // Get the entire internal output buffer (const version) // Returns: // Const reference to the output buffer } ``` -------------------------------- ### DSP Object Creation from dspData Struct Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Provides a way to get a DSP object directly from a dspData structure containing the model's configuration and weights. ```C++ std::unique_ptr get_dsp(dspData &conf) ``` -------------------------------- ### Get Sample Rate from .nam File Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Retrieves the sample rate from a .nam file's JSON object. ```C++ double get_sample_rate_from_nam_file(const nlohmann::json &j) ``` -------------------------------- ### BatchNorm Process Method Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/convnet.html Processes input in-place within specified start and end indices. ```cpp void process_(Eigen::MatrixXf &input, const long i_start, const long i_end) const ``` -------------------------------- ### GetOutput (non-const) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Get the entire internal output buffer. This is intended for internal wiring between layers; callers should treat the buffer as pre-allocated storage and only consider the first num_frames columns valid for a given processing call. Slice with .leftCols(num_frames) as needed. ```C++ inline Eigen::MatrixXf &GetOutput() { // Get the entire internal output buffer. // This is intended for internal wiring between layers; callers should treat the buffer as pre-allocated storage and only consider the first num_frames columns valid for a given processing call. Slice with .leftCols(num_frames) as needed. // Returns: // Reference to the output buffer } ``` -------------------------------- ### DSP Object Creation from Directory (Legacy) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Illustrates the legacy method for loading DSP models from a directory structure. ```C++ std::unique_ptr get_dsp_legacy(const std::filesystem::path dirname) ``` -------------------------------- ### Get Kernel Size Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html Returns the kernel size of the convolution layer. ```cpp long get_kernel_size() const ``` -------------------------------- ### DSP Object Creation from .nam File Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Shows how to load a DSP object from a .nam file, with an option to store the model's configuration data. ```C++ std::unique_ptr get_dsp(const std::filesystem::path config_filename) std::unique_ptr get_dsp(const std::filesystem::path config_filename, dspData &returnedConfig) ``` -------------------------------- ### RingBuffer GetChannels Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/ring_buffer.html Get the number of channels (rows) configured for the RingBuffer. ```C++ inline int GetChannels() const ``` -------------------------------- ### RingBuffer GetMaxBufferSize Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/ring_buffer.html Get the maximum buffer size that was set during initialization. ```C++ inline int GetMaxBufferSize() const ``` -------------------------------- ### Head scaling and output Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt Scales the final head output from the last LayerArray and writes it to the output buffers. ```cpp Eigen::MatrixXf& final_head = this->_layer_arrays.back().GetHeadOutputs(); // Apply head scale and write to output buffers // (implementation details in wavenet.cpp) ``` -------------------------------- ### Conv1x1 GetOutput Function Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/dsp.html Gets the internal output buffer of the Conv1x1 layer. ```C++ inline Eigen::MatrixXf &GetOutput() ``` ```C++ inline const Eigen::MatrixXf &GetOutput() const ``` -------------------------------- ### ConfigParserHelper Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Auto-registration helper for config parsers. Create a static instance to register a config parser at program startup. ```C++ #include Auto-registration helper for config parsers. Create a static instance to register a config parser at program startup. ``` -------------------------------- ### Get Dilation Factor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html Returns the dilation factor currently set for the Conv1D layer. ```cpp inline int get_dilation() const ``` -------------------------------- ### BlendingActivation Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Constructor for BlendingActivation. ```cpp inline BlendingActivation(activations::Activation::Ptr input_act, activations::Activation::Ptr blend_act, int input_channels = 1) ``` -------------------------------- ### Input mixin processing Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt This code snippet shows the processing steps for the input mixin, which handles the conditioning input separately and adds it to the convolution output, including optional pre-FiLM, input mixin convolution, and optional post-FiLM. ```cpp if (this->_input_mixin_pre_film) { this->_input_mixin_pre_film->Process(condition, condition, num_frames); this->_input_mixin.process_(this->_input_mixin_pre_film->GetOutput(), num_frames); } else { this->_input_mixin.process_(condition, num_frames); } if (this->_input_mixin_post_film) { Eigen::MatrixXf& input_mixin_output = this->_input_mixin.GetOutput(); this->_input_mixin_post_film->Process_(input_mixin_output, condition, num_frames); } ``` -------------------------------- ### Get Output Channels Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html Returns the number of output channels configured for the Conv1D layer. ```cpp long get_out_channels() const ``` -------------------------------- ### ConvNetConfig create Method Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/convnet.html Constructs a DSP object from the ConvNet configuration. ```cpp virtual std::unique_ptr create(std::vector weights, double sampleRate) override ``` -------------------------------- ### Get Input Channels Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html Returns the number of input channels configured for the Conv1D layer. ```cpp long get_in_channels() const ``` -------------------------------- ### GatingActivation Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Constructor for GatingActivation. ```cpp inline GatingActivation(activations::Activation::Ptr input_act, activations::Activation::Ptr gating_act, int input_channels = 1) // Parameters: // input_act – Activation function for input channels // gating_act – Activation function for gating channels // input_channels – Number of input channels (default: 1) // gating_channels – Number of gating channels (default: 1) ``` -------------------------------- ### Sum and pre-activation FiLM Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt This code snippet demonstrates the summation of the convolution output and input mixin output, followed by an optional pre-activation FiLM modulation. ```cpp this->_z.leftCols(num_frames).noalias() = ``` -------------------------------- ### Get Number of Weights Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html Calculates and returns the total number of weight parameters required for the Conv1D layer based on its configuration. ```cpp long get_num_weights() const ``` -------------------------------- ### Input convolution processing Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt This code snippet illustrates the processing steps for the input convolution within a WaveNet layer, including optional pre-FiLM, dilated convolution, and optional post-FiLM. ```cpp if (this->_conv_pre_film) { this->_conv_pre_film->Process(input, condition, num_frames); this->_conv.Process(this->_conv_pre_film->GetOutput(), num_frames); } else { this->_conv.Process(input, num_frames); } if (this->_conv_post_film) { Eigen::MatrixXf& conv_output = this->_conv.GetOutput(); this->_conv_post_film->Process_(conv_output, condition, num_frames); } ``` -------------------------------- ### Get Output Buffer (Const Version) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html Retrieves a const reference to the entire internal output buffer. This version is used when the object is not modifiable. ```cpp inline const Eigen::MatrixXf &GetOutput() const ``` -------------------------------- ### Conv1D Constructor (Default) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Default constructor. Initializes with dilation=1 and groups=1. Use set_size_() to configure. ```C++ inline Conv1D() { // Default constructor. // Initializes with dilation=1 and groups=1. Use set_size_() to configure. } ``` -------------------------------- ### set_size_and_weights_ Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Set size and weights in one call. ```C++ void set_size_and_weights_(const int in_channels, const int out_channels, const int kernel_size, const int _dilation, const bool do_bias, const int groups, std::vector::iterator &weights) { // Set size and weights in one call. // Parameters: // * **in_channels** – Number of input channels // * **out_channels** – Number of output channels // * **kernel_size** – Size of the convolution kernel // * **_dilation** – Dilation factor for the convolution // * **do_bias** – Whether to use bias // * **groups** – Number of groups for grouped convolution // * **weights** – Iterator to the weights vector. Will be advanced as weights are consumed. } ``` -------------------------------- ### Head 1x1 processing Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt This C++ code snippet illustrates the processing performed by a head 1x1 convolution if it is configured. This step is optional and handles the skip connection. ```cpp if (this->_head1x1) { this->_head1x1->process_(this->_z.topRows(bottleneck).leftCols(num_frames), num_frames); if (this->_head1x1_post_film) { Eigen::MatrixXf& head1x1_output = this->_head1x1->GetOutput(); this->_head1x1_post_film->Process_(head1x1_output, condition, num_frames); } this->_output_head.leftCols(num_frames).noalias() = this->_head1x1->GetOutput().leftCols(num_frames); } ``` -------------------------------- ### Get Output Buffer Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html Retrieves a reference to the entire internal output buffer. This is primarily for internal layer wiring. Callers should treat it as pre-allocated storage and use .leftCols(num_frames) to access valid data for a given processing call. ```cpp inline Eigen::MatrixXf &GetOutput() ``` -------------------------------- ### Condition processing Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt Processes the input through a condition DSP if provided, otherwise uses the input directly as the condition. ```cpp void WaveNet::_process_condition(const int num_frames) { if (this->_condition_dsp != nullptr) { // Process input through condition DSP this->_condition_dsp->process(/* input */, /* output */, num_frames); // Copy output to condition buffer } else { // Use input directly as condition this->_condition_output = this->_condition_input; } } ``` -------------------------------- ### Linear Config Creator Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Config parser for ConfigParserRegistry. ```cpp std::unique_ptr create_config(const nlohmann::json &config, double sampleRate) // Parameters: // * **config** – JSON configuration object // * **sampleRate** – Expected sample rate in Hz // Returns: // unique_ptr wrapping a LinearConfig ``` -------------------------------- ### ConfigParserRegistry Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Singleton registry mapping architecture names to config parser functions. Both built-in and external architectures register here. There is one construction path for all architectures. ```C++ #include Singleton registry mapping architecture names to config parser functions. Both built-in and external architectures register here. There is one construction path for all architectures. ``` -------------------------------- ### Version Support Checking Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Functions for checking and registering version support for model configurations. ```C++ void verify_config_version(const std::string version) void register_version_support_checker(std::shared_ptr checker) Supported is_version_supported(const std::string version) ``` -------------------------------- ### BlendingActivation Apply Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Apply blending activation to input matrix. ```cpp template inline void apply(const Eigen::MatrixBase &input, Eigen::MatrixBase &output) ``` -------------------------------- ### Process Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Process input and write to internal output buffer. ```C++ void Process(const Eigen::MatrixXf &input, const int num_frames) { // Process input and write to internal output buffer. // Parameters: // * **input** – Input matrix (channels x num_frames) // * **num_frames** – Number of frames to process } ``` -------------------------------- ### Input rechanneling Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt The input is first projected (rechanneled) to match the layer channel count. ```cpp this->_rechannel.process_(layer_inputs, num_frames); Eigen::MatrixXf& rechannel_output = _rechannel.GetOutput(); ``` -------------------------------- ### ModelConfig::create Function Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Abstract function to construct a DSP object from configuration. ```cpp virtual std::unique_ptr create(std::vector weights, double sampleRate) = 0 Construct a DSP object from this configuration. Parameters: * **weights** – Model weights (taken by value to allow move for WaveNet) * **sampleRate** – Expected sample rate in Hz Returns: Unique pointer to a DSP object ``` -------------------------------- ### Linear Config Parser Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Parse Linear configuration from JSON. ```cpp LinearConfig parse_config_json(const nlohmann::json &config) // Parameters: // **config** – JSON configuration object // Returns: // LinearConfig ``` -------------------------------- ### Conv1D Constructor (Parameterized) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Constructor for Conv1D layer. ```C++ inline Conv1D(const int in_channels, const int out_channels, const int kernel_size, const int bias, const int dilation, const int groups = 1) { // Constructor. // Parameters: // * **in_channels** – Number of input channels // * **out_channels** – Number of output channels // * **kernel_size** – Size of the convolution kernel // * **bias** – Whether to use bias (1 for true, 0 for false) // * **dilation** – Dilation factor for the convolution // * **groups** – Number of groups for grouped convolution (default: 1) } ``` -------------------------------- ### Layer processing loop Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt Each layer processes the output of the previous layer, accumulating head outputs. ```cpp for (size_t i = 0; i < this->_layers.size(); i++) { if (i == 0) { // First layer consumes the rechannel output buffer this->_layers[i].Process(rechannel_output, condition, num_frames); } else { // Subsequent layers consume the previous layer's output Eigen::MatrixXf& prev_output = this->_layers[i - 1].GetOutputNextLayer(); this->_layers[i].Process(prev_output, condition, num_frames); } // Accumulate head output from this layer this->_head_inputs.leftCols(num_frames).noalias() += this->_layers[i].GetOutputHead().leftCols(num_frames); } ``` -------------------------------- ### BatchNorm Default Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/convnet.html Default constructor for BatchNorm. ```cpp inline BatchNorm() ``` -------------------------------- ### FiLM Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Constructor for the FiLM class, which applies per-channel scaling and optional shifting. ```cpp inline FiLM(const int condition_dim, const int input_dim, const bool shift, const int groups = 1) ``` -------------------------------- ### LayerArray processing Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt Processes LayerArrays sequentially, with the first processing the input and subsequent ones processing the previous output. ```cpp // First layer array this->_layer_arrays[0].Process(input, condition, num_frames); // Subsequent layer arrays for (size_t i = 1; i < this->_layer_arrays.size(); i++) { ``` -------------------------------- ### Version Class Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Represents a version with major, minor, and patch components. ```C++ #include class Version { public: inline Version(int major, int minor, int patch); inline std::string toString() const; inline bool operator>(const Version &other) const; inline bool operator<(const Version &other) const; int major; int minor; int patch; }; ``` -------------------------------- ### Residual and skip connections Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt This C++ code snippet implements the final step of computing the residual and skip connections. It calculates the output for the next layer and the output for the head. ```cpp // Store output to next layer (residual connection) this->_output_next_layer.leftCols(num_frames).noalias() = input.leftCols(num_frames) + _1x1.GetOutput().leftCols(num_frames); // Store output to head (skip connection) if (this->_head1x1) { this->_output_head.leftCols(num_frames).noalias() = this->_head1x1->GetOutput().leftCols(num_frames); } else { this->_output_head.leftCols(num_frames).noalias() = this->_z.topRows(bottleneck).leftCols(num_frames); } ``` -------------------------------- ### ConvNet Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/convnet.html Constructor for the ConvNet class, initializing various parameters for the convolutional neural network. ```cpp ConvNet(const int in_channels, const int out_channels, const int channels, const std::vector &dilations, const bool batchnorm, const activations::ActivationConfig &activation_config, std::vector &weights, const double expected_sample_rate = -1.0, const int groups = 1) ``` -------------------------------- ### Activation Functions Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Various activation functions. ```C++ inline float relu(float x); inline float sigmoid(float x); inline float hard_tanh(float x); inline float leaky_hardtanh(float x, float min_val, float max_val, float min_slope, float max_slope); inline float fast_tanh(const float x); inline float fast_sigmoid(const float x); inline float leaky_relu(float x, float negative_slope); inline float leaky_relu(float x); inline float swish(float x); inline float hardswish(float x); inline float softsign(float x); ``` -------------------------------- ### 1x1 convolution Source: https://neuralampmodelercore.readthedocs.io/en/latest/_sources/wavenet_walkthrough.rst.txt This C++ code snippet shows the processing step involving a 1x1 convolution, which reduces the bottleneck channels back to the layer channel count. It also includes optional post-FiLM processing. ```cpp _1x1.process_(this->_z.topRows(bottleneck), num_frames); if (this->_1x1_post_film) { Eigen::MatrixXf& _1x1_output = this->_1x1.GetOutput(); this->_1x1_post_film->Process_(_1x1_output, condition, num_frames); } ``` -------------------------------- ### BatchNorm Constructor with Weights Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/convnet.html Constructor for BatchNorm that takes dimension and an iterator to weights. The weights iterator will be advanced as weights are consumed. ```cpp BatchNorm(const int dim, std::vector::iterator &weights) ``` -------------------------------- ### IVersionSupportChecker::support Function Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Pure virtual function to check version support. ```cpp virtual Supported support(const std::string &version) const = 0 ``` -------------------------------- ### Linear Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Constructor for the Linear class, implementing a simple linear convolution. ```cpp Linear(const int in_channels, const int out_channels, const int receptive_field, const bool _bias, const std::vector &weights, const double expected_sample_rate = -1.0) Constructor. Parameters: * **in_channels** – Number of input channels * **out_channels** – Number of output channels * **receptive_field** – Size of the impulse response * **_bias** – Whether to use bias * **weights** – Model weights (impulse response coefficients) * **expected_sample_rate** – Expected sample rate in Hz (-1.0 if unknown) ``` -------------------------------- ### ConvNetBlock Process Method (Legacy) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/convnet.html Processes input using indices for compatibility with older versions. ```cpp void process_(const Eigen::MatrixXf &input, Eigen::MatrixXf &output, const long i_start, const long i_end) ``` -------------------------------- ### LSTM Config Creator Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Config parser for ConfigParserRegistry. ```cpp std::unique_ptr create_config(const nlohmann::json &config, double sampleRate) ``` -------------------------------- ### set_weights_ Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Set the parameters (weights) of this module. ```C++ void set_weights_(std::vector::iterator &weights) { // Set the parameters (weights) of this module. // Parameters: // **weights** – Iterator to the weights vector. Will be advanced as weights are consumed. } ``` -------------------------------- ### ConvNet Process Method Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/convnet.html Processes audio frames using the ConvNet model. ```cpp virtual void process(NAM_SAMPLE **input, NAM_SAMPLE **output, const int num_frames) override ``` -------------------------------- ### Buffer Class Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Constructor for the Buffer class, which is a base class for DSP models requiring input buffering. This class is deprecated. ```C++ Buffer(const int in_channels, const int out_channels, const int receptive_field, const double expected_sample_rate = -1.0) ``` -------------------------------- ### has Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Check whether an architecture name is registered. ```C++ bool has(const std::string &name) const { // Check whether an architecture name is registered. } ``` -------------------------------- ### Activation Class Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Class for activation functions. ```C++ #include class Activation; ``` -------------------------------- ### SetMaxBufferSize Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Reset the ring buffer and pre-allocate output buffer. ```C++ void SetMaxBufferSize(const int maxBufferSize) { // Reset the ring buffer and pre-allocate output buffer. // Parameters: // **maxBufferSize** – Maximum buffer size for output buffer and to size ring buffer } ``` -------------------------------- ### Process_ Function (In-place) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Processes input data using conditioning in-place, modifying the input matrix directly. ```cpp inline void Process_(Eigen::Ref input, const Eigen::Ref &condition, const int num_frames) Process input with conditioning (in-place) Uses Eigen::Ref to accept matrices and block expressions without creating temporaries (real-time safe). Modifies the input matrix directly. Parameters: * **input** – Input matrix (input_dim x num_frames), will be modified in-place * **condition** – Conditioning matrix (condition_dim x num_frames) * **num_frames** – Number of frames to process ``` -------------------------------- ### DSP Object Construction Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html The primary construction path for DSP objects, used by both JSON and binary loaders. It handles construction, metadata application, and prewarming. ```C++ std::unique_ptr create_dsp(std::unique_ptr config, std::vector weights, const ModelMetadata &metadata) ``` -------------------------------- ### Conv1x1 Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/dsp.html Constructor for the 1x1 convolution, which performs a pointwise convolution. ```C++ Conv1x1(const int in_channels, const int out_channels, const bool _bias, const int groups = 1) ``` -------------------------------- ### process_ Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Internal processing function for Conv1D. ```C++ void process_(const Eigen::MatrixXf &input, Eigen::MatrixXf &output, const long i_start, const long ncols, const long j_start) const { // Internal processing function for Conv1D. } ``` -------------------------------- ### Model Configuration Parsing Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Parses a ModelConfig from a JSON architecture name and config block, given an expected sample rate. ```C++ std::unique_ptr parse_model_config_json(const std::string &architecture, const nlohmann::json &config, double sample_rate) ``` -------------------------------- ### ConvNetBlock GetOutput Method Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/convnet.html Retrieves a block reference to the output from the last Process() call. ```cpp Eigen::Block GetOutput(const int num_frames) ``` -------------------------------- ### Conv1D Default Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html Initializes a Conv1D layer with default dilation=1 and groups=1. The size parameters can be configured later using set_size_(). ```cpp inline Conv1D() { // Initializes with dilation=1 and groups=1. Use set_size_() to configure. } ``` -------------------------------- ### Linear Model Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/dsp.html Constructor for the basic linear model, which implements a simple linear convolution. ```C++ Linear(const int in_channels, const int out_channels, const int receptive_field, const bool _bias, const std::vector &weights, const double expected_sample_rate = -1.0) ``` -------------------------------- ### Conv1x1 Process Function (Matrix Input) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/dsp.html Processes an input matrix and returns the output matrix. ```C++ inline Eigen::MatrixXf process(const Eigen::MatrixXf &input) const ``` -------------------------------- ### LSTM Config Parser Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Parse LSTM configuration from JSON. ```cpp LSTMConfig parse_config_json(const nlohmann::json &config) // Parameters: // **config** – JSON configuration object // Returns: // LSTMConfig ``` -------------------------------- ### parse Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Parse a ModelConfig from an architecture name, JSON config, and sample rate. ```C++ std::unique_ptr parse(const std::string &name, const nlohmann::json &config, double sampleRate) const { // Parse a ModelConfig from an architecture name, JSON config, and sample rate. // Throws: // std::runtime_error – If no parser is registered for the given name } ``` -------------------------------- ### ModelMetadata Structure Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Metadata common to all model formats. ```C++ #include struct ModelMetadata { std::string version; double sample_rate = -1.0; std::optional loudness; std::optional input_level; std::optional output_level; }; ``` -------------------------------- ### Conv1x1 Process Function (Matrix and Frames Input) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/dsp.html Processes an input matrix for a specified number of frames and returns the output matrix. ```C++ Eigen::MatrixXf process(const Eigen::MatrixXf &input, const int num_frames) const ``` -------------------------------- ### GetOutput Function Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Retrieves the internal output buffer of the FiLM layer. ```cpp inline Eigen::MatrixXf &GetOutput() Get the entire internal output buffer. This is intended for internal wiring between layers; callers should treat the buffer as pre-allocated storage and only consider the first num_frames columns valid for a given processing call. Slice with .leftCols(num_frames) as needed. Returns: Reference to the output buffer ``` ```cpp inline const Eigen::MatrixXf &GetOutput() const Get the entire internal output buffer (const version) Returns: Const reference to the output buffer ``` -------------------------------- ### FiLM Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/film.html Constructor for the FiLM class. Initializes the module with specified dimensions and options for scaling and shifting. ```cpp inline FiLM(const int condition_dim, const int input_dim, const bool shift, const int groups = 1) { // ... (implementation details) } ``` -------------------------------- ### Conv1x1 Process Function (In-place) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/dsp.html Processes input and stores output to a pre-allocated buffer. Uses Eigen::Ref for real-time safety. ```C++ void process_(const Eigen::Ref &input, const int num_frames) ``` -------------------------------- ### Process Input Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html Processes the input matrix and writes the result to the internal output buffer. The number of frames to process is specified. ```cpp void Process(const Eigen::MatrixXf &input, const int num_frames) ``` -------------------------------- ### lowercase() function signature Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/util.html The signature for the `lowercase()` function, which converts a string to lowercase. ```cpp std::string lowercase(const std::string &s) ``` -------------------------------- ### registerParser Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Register a config parser for an architecture. ```C++ void registerParser(const std::string &name, ConfigParserFunction func) { // Register a config parser for an architecture. // Parameters: // * **name** – Architecture name (e.g., “WaveNet”, “LSTM”) // * **func** – Parser function that returns a unique_ptr // Throws: // std::runtime_error – If the name is already registered } ``` -------------------------------- ### Conv1D Constructor Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html Constructs a Conv1D layer with specified input channels, output channels, kernel size, bias, and dilation. Grouped convolution is supported with an optional groups parameter. ```cpp inline Conv1D(const int in_channels, const int out_channels, const int kernel_size, const int bias, const int dilation, const int groups = 1) ``` -------------------------------- ### Process_ Method (In-place) Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/film.html Processes the input matrix in-place using the conditioning matrix. Modifies the input matrix directly. ```cpp inline void Process_(Eigen::Ref input, const Eigen::Ref &condition, const int num_frames) { // ... (implementation details) } ``` -------------------------------- ### ConvNetBlock set_weights_ Method Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/convnet.html Sets the parameters (weights) for a ConvNetBlock. ```cpp void set_weights_(const int in_channels, const int out_channels, const int _dilation, const bool batchnorm, const activations::ActivationConfig &activation_config, const int groups, std::vector::iterator &weights) ``` -------------------------------- ### SetMaxBufferSize Function Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Resizes internal buffers to accommodate a specified maximum number of frames. ```cpp inline void SetMaxBufferSize(const int maxBufferSize) Resize buffers to handle maxBufferSize frames. Parameters: **maxBufferSize** – Maximum number of frames to process in a single call ``` -------------------------------- ### SlimmableModel Class Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/get_dsp.html Interface for models that support dynamic size reduction. Models implementing this interface can reduce their computational cost at the expense of quality. The interpretation of the size parameter is model-specific (e.g., selecting a sub-model, pruning channels, etc.). ```C++ #include class SlimmableModel { public: virtual ~SlimmableModel() = default; virtual void SetSlimmableSize(const double val) = 0; }; ``` -------------------------------- ### Set Size Parameters Source: https://neuralampmodelercore.readthedocs.io/en/latest/api/conv1d.html Configures the size parameters of the convolution layer, including input/output channels, kernel size, bias usage, dilation factor, and number of groups for grouped convolution. ```cpp void set_size_(const int in_channels, const int out_channels, const int kernel_size, const bool do_bias, const int _dilation, const int groups = 1) ```