MayaFlux 1.0.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 103 of file TemporalTransformer.hpp.

104 {
105 switch (m_operation) {
106
108 return apply_per_channel(input, [](std::span<double> ch) {
109 D::reverse(ch);
110 });
111
113 const auto fi = get_parameter_or<double>("fade_in_ratio", 0.1);
114 const auto fo = get_parameter_or<double>("fade_out_ratio", 0.1);
115 return apply_per_channel(input, [fi, fo](std::span<double> ch) {
116 D::fade(ch, fi, fo);
117 });
118 }
119
121 const auto factor = get_parameter_or<double>("stretch_factor", 1.0);
122 return apply_per_channel(input, [factor](std::span<const double> ch) {
123 return D::time_stretch(ch, factor);
124 });
125 }
126
128 const auto samples = get_parameter_or<uint32_t>("delay_samples", 1000);
129 const auto fill = get_parameter_or<double>("fill_value", 0.0);
130 return apply_per_channel(input, [samples, fill](std::span<const double> ch) {
131 return D::delay(ch, samples, fill);
132 });
133 }
134
136 const auto start = get_parameter_or<double>("start_ratio", 0.0);
137 const auto end = get_parameter_or<double>("end_ratio", 1.0);
138 return apply_per_channel(input, [start, end](std::span<const double> ch) {
139 return D::slice(ch, start, end);
140 });
141 }
142
144 const auto target = get_parameter_or<size_t>("target_size", size_t { 0 });
145 const auto cubic = get_parameter_or<bool>("use_cubic", false);
146 if (target == 0)
147 return create_output(input);
148 return apply_per_channel(input, [target, cubic](std::span<const double> ch) {
149 std::vector<double> out(target);
150 if (cubic)
152 else
154 return out;
155 });
156 }
157
158 default:
159 return create_output(input);
160 }
161 }
Core::GlobalInputConfig input
Definition Config.cpp:42
std::vector< float > * out
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.
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.
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_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.
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 reverse(std::span< double > data) noexcept
Reverse temporal order in-place.
Definition Transform.cpp:90
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.

References MayaFlux::Yantra::TemporalTransformer< InputType, OutputType >::apply_per_channel(), MayaFlux::Yantra::TemporalTransformer< InputType, OutputType >::create_output(), MayaFlux::Kinesis::Discrete::delay(), MayaFlux::Yantra::DELAY, MayaFlux::Kinesis::Discrete::fade(), MayaFlux::Yantra::FADE_IN_OUT, input, MayaFlux::Yantra::INTERPOLATE, MayaFlux::Kinesis::Discrete::interpolate_cubic(), MayaFlux::Kinesis::Discrete::interpolate_linear(), MayaFlux::Yantra::TemporalTransformer< InputType, OutputType >::m_operation, out, MayaFlux::Kinesis::Discrete::reverse(), MayaFlux::Kinesis::Discrete::slice(), MayaFlux::Yantra::SLICE, MayaFlux::Yantra::TIME_REVERSE, MayaFlux::Kinesis::Discrete::time_stretch(), and MayaFlux::Yantra::TIME_STRETCH.

+ Here is the call graph for this function: