2016-05-15 07:34:03 +05:30
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-12-13 05:46:46 +05:30
|
|
|
#pragma once
|
|
|
|
|
2018-09-09 01:58:19 +05:30
|
|
|
#include <array>
|
2016-05-15 07:34:03 +05:30
|
|
|
#include <cstddef>
|
|
|
|
#include <memory>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
2018-09-09 01:58:19 +05:30
|
|
|
namespace soundtouch {
|
|
|
|
class SoundTouch;
|
|
|
|
}
|
|
|
|
|
2016-05-15 07:34:03 +05:30
|
|
|
namespace AudioCore {
|
|
|
|
|
2018-09-09 01:58:19 +05:30
|
|
|
class TimeStretcher {
|
2016-05-15 07:34:03 +05:30
|
|
|
public:
|
|
|
|
TimeStretcher();
|
|
|
|
~TimeStretcher();
|
|
|
|
|
|
|
|
void SetOutputSampleRate(unsigned int sample_rate);
|
|
|
|
|
2018-09-09 01:58:19 +05:30
|
|
|
/// @param in Input sample buffer
|
|
|
|
/// @param num_in Number of input frames in `in`
|
|
|
|
/// @param out Output sample buffer
|
|
|
|
/// @param num_out Desired number of output frames in `out`
|
|
|
|
/// @returns Actual number of frames written to `out`
|
|
|
|
std::size_t Process(const s16* in, std::size_t num_in, s16* out, std::size_t num_out);
|
2016-05-15 07:34:03 +05:30
|
|
|
|
2018-09-09 01:58:19 +05:30
|
|
|
void Clear();
|
2016-05-15 07:34:03 +05:30
|
|
|
|
2018-09-09 01:58:19 +05:30
|
|
|
void Flush();
|
2016-05-15 07:34:03 +05:30
|
|
|
|
|
|
|
private:
|
2018-09-09 01:58:19 +05:30
|
|
|
unsigned int sample_rate;
|
|
|
|
std::unique_ptr<soundtouch::SoundTouch> sound_touch;
|
|
|
|
double stretch_ratio = 1.0;
|
2016-05-15 07:34:03 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace AudioCore
|