mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-08-01 11:06:30 -04:00
Formatted code (#1007)
* Updated style * Updated files * fixed new line * Updated spacing * File fix WIP * Updated to clang 13 * updated comment style * Removed old comment code
This commit is contained in:
parent
7aca7ce74d
commit
033c4e9a5b
599 changed files with 70746 additions and 66896 deletions
|
@ -26,44 +26,42 @@ namespace dsp {
|
|||
namespace interpolation {
|
||||
|
||||
class LinearResampler {
|
||||
public:
|
||||
void configure(
|
||||
const float input_rate,
|
||||
const float output_rate
|
||||
) {
|
||||
phase_increment = calculate_increment(input_rate, output_rate);
|
||||
}
|
||||
public:
|
||||
void configure(
|
||||
const float input_rate,
|
||||
const float output_rate) {
|
||||
phase_increment = calculate_increment(input_rate, output_rate);
|
||||
}
|
||||
|
||||
template<typename InterpolatedSampleHandler>
|
||||
void operator()(
|
||||
const float sample,
|
||||
InterpolatedSampleHandler interpolated_sample_handler
|
||||
) {
|
||||
const float sample_delta = sample - last_sample;
|
||||
while( phase < 1.0f ) {
|
||||
const float interpolated_value = last_sample + phase * sample_delta;
|
||||
interpolated_sample_handler(interpolated_value);
|
||||
phase += phase_increment;
|
||||
}
|
||||
last_sample = sample;
|
||||
phase -= 1.0f;
|
||||
}
|
||||
template <typename InterpolatedSampleHandler>
|
||||
void operator()(
|
||||
const float sample,
|
||||
InterpolatedSampleHandler interpolated_sample_handler) {
|
||||
const float sample_delta = sample - last_sample;
|
||||
while (phase < 1.0f) {
|
||||
const float interpolated_value = last_sample + phase * sample_delta;
|
||||
interpolated_sample_handler(interpolated_value);
|
||||
phase += phase_increment;
|
||||
}
|
||||
last_sample = sample;
|
||||
phase -= 1.0f;
|
||||
}
|
||||
|
||||
void advance(const float fraction) {
|
||||
phase += (fraction * phase_increment);
|
||||
}
|
||||
void advance(const float fraction) {
|
||||
phase += (fraction * phase_increment);
|
||||
}
|
||||
|
||||
private:
|
||||
float last_sample { 0.0f };
|
||||
float phase { 0.0f };
|
||||
float phase_increment { 0.0f };
|
||||
private:
|
||||
float last_sample{0.0f};
|
||||
float phase{0.0f};
|
||||
float phase_increment{0.0f};
|
||||
|
||||
static constexpr float calculate_increment(const float input_rate, const float output_rate) {
|
||||
return input_rate / output_rate;
|
||||
}
|
||||
static constexpr float calculate_increment(const float input_rate, const float output_rate) {
|
||||
return input_rate / output_rate;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace interpolation */
|
||||
} /* namespace dsp */
|
||||
|
||||
#endif/*__LINEAR_RESAMPLER_H__*/
|
||||
#endif /*__LINEAR_RESAMPLER_H__*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue