80 switch (m_operation) {
81 case MathematicalOperation::GAIN: {
82 auto gain_factor = get_parameter_or<double>(
"gain_factor", 1.0);
83 if (this->is_in_place()) {
86 return create_output(
transform_linear(input, gain_factor, 0.0, m_working_buffer));
89 case MathematicalOperation::OFFSET: {
90 auto offset_value = get_parameter_or<double>(
"offset_value", 0.0);
91 if (this->is_in_place()) {
94 return create_output(
transform_linear(input, 1.0, offset_value, m_working_buffer));
97 case MathematicalOperation::POWER: {
98 auto exponent = get_parameter_or<double>(
"exponent", 2.0);
100 if (this->is_in_place()) {
103 return create_output(
transform_power(input, exponent, m_working_buffer));
106 case MathematicalOperation::LOGARITHMIC: {
107 auto scale = get_parameter_or<double>(
"scale", 1.0);
108 auto input_scale = get_parameter_or<double>(
"input_scale", 1.0);
109 auto offset = get_parameter_or<double>(
"offset", 1.0);
110 auto base = get_parameter_or<double>(
"base", std::numbers::e);
112 if (this->is_in_place()) {
115 return create_output(
transform_logarithmic(input, scale, input_scale, offset, m_working_buffer, base));
118 case MathematicalOperation::EXPONENTIAL: {
119 auto scale = get_parameter_or<double>(
"scale", 1.0);
120 auto rate = get_parameter_or<double>(
"rate", 1.0);
121 auto base = get_parameter_or<double>(
"base", std::numbers::e);
123 if (this->is_in_place()) {
129 case MathematicalOperation::TRIGONOMETRIC: {
130 auto trig_function = get_parameter_or<std::string>(
"trig_function",
"sin");
131 auto frequency = get_parameter_or<double>(
"frequency", 1.0);
132 auto amplitude = get_parameter_or<double>(
"amplitude", 1.0);
133 auto phase = get_parameter_or<double>(
"phase", 0.0);
135 if (trig_function ==
"sin") {
136 if (this->is_in_place()) {
137 return create_output(
transform_trigonometric(input, [](
double x) {
return std::sin(x); }, frequency, amplitude, phase));
139 return create_output(
transform_trigonometric(input, [](
double x) {
return std::sin(x); }, frequency, amplitude, phase, m_working_buffer));
141 if (trig_function ==
"cos") {
142 if (this->is_in_place()) {
143 return create_output(
transform_trigonometric(input, [](
double x) {
return std::cos(x); }, frequency, amplitude, phase));
145 return create_output(
transform_trigonometric(input, [](
double x) {
return std::cos(x); }, frequency, amplitude, phase, m_working_buffer));
147 if (trig_function ==
"tan") {
148 if (this->is_in_place()) {
149 return create_output(
transform_trigonometric(input, [](
double x) {
return std::tan(x); }, frequency, amplitude, phase));
151 return create_output(
transform_trigonometric(input, [](
double x) {
return std::tan(x); }, frequency, amplitude, phase, m_working_buffer));
153 return create_output(input);
156 case MathematicalOperation::QUANTIZE: {
157 auto bits = get_parameter_or<uint8_t>(
"bits", 16);
158 if (this->is_in_place()) {
164 case MathematicalOperation::NORMALIZE: {
165 auto target_peak = get_parameter_or<double>(
"target_peak", 1.0);
166 std::pair<double, double> target_range = { -target_peak, target_peak };
167 if (this->is_in_place()) {
173 case MathematicalOperation::POLYNOMIAL: {
174 auto coefficients = get_parameter_or<std::vector<double>>(
"coefficients", std::vector<double> { 0.0, 1.0 });
175 if (this->is_in_place()) {
182 return create_output(input);