2016-05-15 03:04:03 +01:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2016-12-13 00:16:46 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-09-08 21:28:19 +01:00
|
|
|
#include <array>
|
2016-05-15 03:04:03 +01:00
|
|
|
#include <cstddef>
|
|
|
|
#include <memory>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
2018-09-08 21:28:19 +01:00
|
|
|
namespace soundtouch {
|
|
|
|
class SoundTouch;
|
|
|
|
}
|
|
|
|
|
2016-05-15 03:04:03 +01:00
|
|
|
namespace AudioCore {
|
|
|
|
|
2018-09-08 21:28:19 +01:00
|
|
|
class TimeStretcher {
|
2016-05-15 03:04:03 +01:00
|
|
|
public:
|
|
|
|
TimeStretcher();
|
|
|
|
~TimeStretcher();
|
|
|
|
|
|
|
|
void SetOutputSampleRate(unsigned int sample_rate);
|
|
|
|
|
2018-09-08 21:28:19 +01:00
|
|
|
/// @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 03:04:03 +01:00
|
|
|
|
2018-09-08 21:28:19 +01:00
|
|
|
void Clear();
|
2016-05-15 03:04:03 +01:00
|
|
|
|
2018-09-08 21:28:19 +01:00
|
|
|
void Flush();
|
2016-05-15 03:04:03 +01:00
|
|
|
|
|
|
|
private:
|
2018-09-08 21:28:19 +01:00
|
|
|
unsigned int sample_rate;
|
|
|
|
std::unique_ptr<soundtouch::SoundTouch> sound_touch;
|
|
|
|
double stretch_ratio = 1.0;
|
2016-05-15 03:04:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace AudioCore
|