This repository has been archived on 2024-03-23. You can view files and clone it, but cannot push or open issues or pull requests.
2018-09-08 15:48:13 +00:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
|
2020-10-15 18:49:45 +00:00
|
|
|
#if defined(__GNUC__)
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
|
|
|
#endif
|
|
|
|
#include <SoundTouch.h>
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
#endif
|
|
|
|
|
2018-09-08 15:48:13 +00:00
|
|
|
namespace AudioCore {
|
|
|
|
|
|
|
|
class TimeStretcher {
|
|
|
|
public:
|
|
|
|
TimeStretcher(u32 sample_rate, u32 channel_count);
|
|
|
|
|
|
|
|
/// @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`
|
2018-09-15 13:21:06 +00:00
|
|
|
std::size_t Process(const s16* in, std::size_t num_in, s16* out, std::size_t num_out);
|
2018-09-08 15:48:13 +00:00
|
|
|
|
|
|
|
void Clear();
|
|
|
|
|
2018-09-12 17:07:16 +00:00
|
|
|
void Flush();
|
|
|
|
|
2018-09-08 15:48:13 +00:00
|
|
|
private:
|
|
|
|
u32 m_sample_rate;
|
|
|
|
soundtouch::SoundTouch m_sound_touch;
|
|
|
|
double m_stretch_ratio = 1.0;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace AudioCore
|