MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ transform_implementation()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = InputType>
output_type MayaFlux::Yantra::TemporalTransformer< InputType, OutputType >::transform_implementation ( input_type input)
inlineoverrideprotectedvirtual

Core transformation implementation for temporal operations.

Parameters
inputInput data to transform in the time domain
Returns
Transformed output data

Performs the temporal operation specified by m_operation on the input data. Operations modify the temporal characteristics of the data including timing, duration, ordering, and envelope shaping. Supports both in-place and out-of-place transformations based on transformer settings.

Implements MayaFlux::Yantra::UniversalTransformer< InputType, OutputType >.

Definition at line 79 of file TemporalTransformer.hpp.

80 {
81 switch (m_operation) {
82
84 return apply_per_channel(input, [](std::span<double> ch) {
85 D::reverse(ch);
86 });
87
89 const auto fi = get_parameter_or<double>("fade_in_ratio", 0.1);
90 const auto fo = get_parameter_or<double>("fade_out_ratio", 0.1);
91 return apply_per_channel(input, [fi, fo](std::span<double> ch) {
92 D::fade(ch, fi, fo);
93 });
94 }
95
97 const auto factor = get_parameter_or<double>("stretch_factor", 1.0);
98 return apply_per_channel(input, [factor](std::span<const double> ch) {
99 return D::time_stretch(ch, factor);
100 });
101 }
102
104 const auto samples = get_parameter_or<uint32_t>("delay_samples", 1000);
105 const auto fill = get_parameter_or<double>("fill_value", 0.0);
106 return apply_per_channel(input, [samples, fill](std::span<const double> ch) {
107 return D::delay(ch, samples, fill);
108 });
109 }
110
112 const auto start = get_parameter_or<double>("start_ratio", 0.0);
113 const auto end = get_parameter_or<double>("end_ratio", 1.0);
114 return apply_per_channel(input, [start, end](std::span<const double> ch) {
115 return D::slice(ch, start, end);
116 });
117 }
118
120 const auto target = get_parameter_or<size_t>("target_size", size_t { 0 });
121 const auto cubic = get_parameter_or<bool>("use_cubic", false);
122 if (target == 0)
123 return create_output(input);
124 return apply_per_channel(input, [target, cubic](std::span<const double> ch) {
125 std::vector<double> out(target);
126 if (cubic)
127 D::interpolate_cubic(ch, out);
128 else
129 D::interpolate_linear(ch, out);
130 return out;
131 });
132 }
133
134 default:
135 return create_output(input);
136 }
137 }
output_type create_output(const input_type &input)
Creates output with proper type conversion.
output_type apply_per_channel(input_type &input, Func &&func)
Extracts per-channel spans, applies func to each, and reconstructs.
TemporalOperation m_operation
Current temporal operation.
void fade(std::span< double > data, double fade_in_ratio, double fade_out_ratio) noexcept
Apply equal-power (cosine) fade-in then fade-out envelope in-place The cosine taper maintains constan...
Definition Transform.cpp:95
void interpolate_cubic(std::span< const double > src, std::span< double > dst) noexcept
Catmull-Rom cubic interpolation from src into dst (caller sizes dst) Branchless boundary clamping; Ho...
std::vector< double > slice(std::span< const double > data, double start_ratio, double end_ratio)
Extract a contiguous slice by ratio, returning a new vector.
std::vector< double > delay(std::span< const double > data, uint32_t delay_samples, double fill_value)
Prepend delay_samples zero-valued (or fill_value) samples, returning a new vector.
void reverse(std::span< double > data) noexcept
Reverse temporal order in-place.
Definition Transform.cpp:90
std::vector< double > time_stretch(std::span< const double > data, double stretch_factor)
Time-stretch via linear interpolation resampling Fast but alias-naive: no anti-aliasing pre-filter is...
void interpolate_linear(std::span< const double > src, std::span< double > dst) noexcept
Linear interpolation from src into dst (caller sizes dst) Branchless inner loop with precomputed step...
@ SLICE
Extract temporal slice.
@ TIME_REVERSE
Reverse temporal order.
@ TIME_STRETCH
Change playback speed.
@ FADE_IN_OUT
Apply fade envelope.
@ INTERPOLATE
Temporal interpolation.