37template <ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = InputType>
85 const auto a = get_parameter_or<double>(
"gain_factor", 1.0);
92 const auto b = get_parameter_or<double>(
"offset_value", 0.0);
99 const auto exp = get_parameter_or<double>(
"exponent", 2.0);
106 const auto a = get_parameter_or<double>(
"scale", 1.0);
107 const auto b = get_parameter_or<double>(
"input_scale", 1.0);
108 const auto c = get_parameter_or<double>(
"offset", 1.0);
109 const auto base = get_parameter_or<double>(
"base", std::numbers::e);
116 const auto a = get_parameter_or<double>(
"scale", 1.0);
117 const auto b = get_parameter_or<double>(
"rate", 1.0);
118 const auto base = get_parameter_or<double>(
"base", std::numbers::e);
125 const auto fn = get_parameter_or<std::string>(
"trig_function",
"sin");
126 const auto freq = get_parameter_or<double>(
"frequency", 1.0);
127 const auto amp = get_parameter_or<double>(
"amplitude", 1.0);
128 const auto ph = get_parameter_or<double>(
"phase", 0.0);
131 D::apply_trig(ch, [](
double x) {
return std::cos(x); }, freq, amp, ph);
135 D::apply_trig(ch, [](
double x) {
return std::tan(x); }, freq, amp, ph);
138 D::apply_trig(ch, [](
double x) {
return std::sin(x); }, freq, amp, ph);
143 const auto bits = get_parameter_or<uint8_t>(
"bits", 16);
150 const auto peak = get_parameter_or<double>(
"target_peak", 1.0);
157 const auto coeffs = get_parameter_or<std::vector<double>>(
158 "coefficients", std::vector<double> { 0.0, 1.0 });
159 auto poly = std::make_shared<Nodes::Generator::Polynomial>(coeffs);
161 std::ranges::transform(ch, ch.begin(),
162 [&poly](
double x) { return poly->process_sample(x); });
181 if (name ==
"operation") {
182 if (
auto r = safe_any_cast<MathematicalOperation>(value)) {
186 if (
auto r = safe_any_cast<std::string>(value)) {
187 if (
auto e = Reflect::string_to_enum_case_insensitive<MathematicalOperation>(*r.value)) {
208 template <
typename Func>
213 for (
size_t i = 0; i < channels.size(); ++i) {
218 for (
size_t i = 0; i < channels.size(); ++i)
221 OperationHelper::reconstruct_from_double<InputType>(
m_working_buffer, structure_info));
243 this->
set_parameter(
"coefficients", std::vector<double> { 0.0, 1.0 });
256 template <
typename T>
260 if (!param.has_value())
261 return default_value;
263 auto result = safe_any_cast<T>(param);
264 return result.value_or(default_value);
277 if constexpr (std::is_same_v<InputType, OutputType>) {
Core::GlobalInputConfig input
output_type convert_result(std::vector< std::vector< double > > &result_data, DataStructureInfo &metadata)
Convert processed double data back to OutputType using metadata and optional callback.
static std::tuple< std::vector< std::span< double > >, DataStructureInfo > extract_structured_double(T &compute_data)
Extract structured double data from Datum container or direct ComputeData with automatic container ha...
void logarithmic(std::span< double > data, double a, double b, double c, double base) noexcept
Logarithmic map y = a * log_base(b*x + c) applied in-place Values where (b*x + c) <= 0 are mapped to ...
void exponential(std::span< double > data, double a, double b, double base) noexcept
Exponential map y = a * base^(b*x) applied in-place Scalar transcendental — not SIMD hot-path.
void quantize(std::span< double > data, uint8_t bits) noexcept
Quantize to n-bit resolution in-place Input is assumed to be in [-1, 1]; values outside are clamped f...
std::vector< double > power(std::span< const double > data, size_t n_windows, uint32_t hop_size, uint32_t window_size)
Power (sum of squares) per window.
void normalize(std::span< double > data, double target_min, double target_max) noexcept
Normalize to [target_min, target_max] in-place Single-pass min/max reduction followed by a single tra...
void linear(std::span< double > data, double a, double b) noexcept
Linear map y = a*x + b applied in-place.
void apply_trig(std::span< double > data, TrigFunc func, double frequency, double amplitude, double phase) noexcept
Trigonometric map y = amplitude * f(frequency*x + phase) applied in-place.
constexpr std::string_view enum_to_string(EnumType value) noexcept
Universal enum to string converter using magic_enum (original case)
@ POWER
Power (sum of squares)
MathematicalOperation
Specific mathematical operations supported.
@ GAIN
Linear gain/attenuation.
@ NORMALIZE
Normalization.
@ QUANTIZE
Quantization/bit reduction.
@ TRIGONOMETRIC
Trigonometric functions.
@ LOGARITHMIC
Logarithmic transform.
@ EXPONENTIAL
Exponential transform.
@ POLYNOMIAL
Polynomial transform.
TransformationType
Categories of transformation operations for discovery and organization.
@ MATHEMATICAL
Mathematical transformations (polynomial mapping, matrix operations)
double peak(const std::vector< double > &data)
Find peak amplitude in single-channel data.
Input/Output container for computation pipeline data flow with structure preservation.