Refactor play functionality (again)

The responsibility of resampling the buffer
and moving the frame index is now in Sample::play, allowing the removal
of both playSampleRangeLoop and playSampleRangePingPong.
This commit is contained in:
sakertooth
2023-09-25 20:27:17 -04:00
parent a5a01cf47b
commit 1f932d3d6f
2 changed files with 61 additions and 153 deletions

View File

@@ -33,11 +33,11 @@
#include "lmms_export.h"
#ifdef __MINGW32__
#include <mingw.shared_mutex.h>
#include <mingw.mutex.h>
#include <mingw.shared_mutex.h>
#else
#include <shared_mutex>
#include <mutex>
#include <shared_mutex>
#endif
class QPainter;
@@ -126,23 +126,13 @@ public:
auto setReversed(bool reversed) -> void;
private:
auto playSampleRange(PlaybackState* state, sampleFrame* dst, int numFrames, float resampleRatio = 1.0f) const
-> bool;
auto playSampleRangeLoop(PlaybackState* state, sampleFrame* dst, int numFrames, float resampleRatio = 1.0f) const
-> bool;
auto playSampleRangePingPong(
PlaybackState* state, sampleFrame* dst, int numFrames, float resampleRatio = 1.0f) const -> bool;
auto playSampleRange(PlaybackState* state, sampleFrame* dst, size_t numFrames) const -> void;
auto resampleSampleRange(SRC_STATE* state, sampleFrame* src, sampleFrame* dst, size_t numInputFrames,
size_t numOutputFrames, double ratio) const -> SRC_DATA;
auto amplifySampleRange(sampleFrame* src, int numFrames) const -> void;
auto copyBufferForward(sampleFrame* dst, int initialPosition, int advanceAmount) const -> void;
auto copyBufferBackward(sampleFrame* dst, int initialPosition, int advanceAmount) const -> void;
auto getPingPongIndex(int index, int startFrame, int endFrame) const -> int;
auto getLoopedIndex(int index, int startFrame, int endFrame) const -> int;
auto resampleSampleRange(SRC_STATE* state, sampleFrame* src, sampleFrame* dst, int numInputFrames,
int numOutputFrames, double ratio) const -> SRC_DATA;
auto amplifySampleRange(sampleFrame* src, int numFrames) const -> void;
private:
std::shared_ptr<const SampleBuffer> m_buffer = std::make_shared<SampleBuffer>();
int m_startFrame = 0;
@@ -155,4 +145,4 @@ private:
mutable std::shared_mutex m_mutex;
};
} // namespace lmms
#endif
#endif