81 switch (m_operation) {
83 case TemporalOperation::TIME_REVERSE:
84 return apply_per_channel(input, [](std::span<double> ch) {
88 case TemporalOperation::FADE_IN_OUT: {
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) {
96 case TemporalOperation::TIME_STRETCH: {
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);
103 case TemporalOperation::DELAY: {
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);
111 case TemporalOperation::SLICE: {
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);
119 case TemporalOperation::INTERPOLATE: {
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);
123 return create_output(input);
124 return apply_per_channel(input, [target, cubic](std::span<const double> ch) {
125 std::vector<double> out(target);
127 D::interpolate_cubic(ch, out);
129 D::interpolate_linear(ch, out);
135 return create_output(input);
189 auto [channels, structure_info] = OperationHelper::extract_structured_double(input);
190 m_working_buffer.resize(channels.size());
191 for (
size_t i = 0; i < channels.size(); ++i) {
192 if constexpr (std::is_void_v<std::invoke_result_t<Func, std::span<double>>>) {
193 m_working_buffer[i].assign(channels[i].begin(), channels[i].end());
194 func(std::span<double> { m_working_buffer[i] });
196 m_working_buffer[i] = func(std::span<const double> { channels[i] });
200 if (this->is_in_place())
201 for (
size_t i = 0; i < channels.size(); ++i)
202 std::ranges::copy(m_working_buffer[i], channels[i].begin());
203 return create_output(
204 OperationHelper::reconstruct_from_double<InputType>(m_working_buffer, structure_info));