Skip to content

Commit

Permalink
Replace uses of std::vector with SampleBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
robbert-vdh committed Dec 7, 2022
1 parent a7171a2 commit 7016e0f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/engine/bufferscalers/enginebufferscalerubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ constexpr size_t kRubberBandBlockSize = 256;
EngineBufferScaleRubberBand::EngineBufferScaleRubberBand(
ReadAheadManager* pReadAheadManager)
: m_pReadAheadManager(pReadAheadManager),
m_buffers{std::vector<CSAMPLE>(MAX_BUFFER_LEN), std::vector<CSAMPLE>(MAX_BUFFER_LEN)},
m_buffers{mixxx::SampleBuffer(MAX_BUFFER_LEN), mixxx::SampleBuffer(MAX_BUFFER_LEN)},
m_bufferPtrs{m_buffers[0].data(), m_buffers[1].data()},
m_interleavedReadBuffer(MAX_BUFFER_LEN),
m_bBackwards(false),
Expand Down Expand Up @@ -297,8 +297,8 @@ void EngineBufferScaleRubberBand::reset() {
// https://github.com/breakfastquay/rubberband/blob/c5f99d5ff2cba2f4f1def6c38c7843bbb9ac7a78/main/main.cpp#L652
size_t remaining_padding = m_pRubberBand->getLatency();
#endif
std::fill_n(m_buffers[0].begin(), kRubberBandBlockSize, 0.0f);
std::fill_n(m_buffers[1].begin(), kRubberBandBlockSize, 0.0f);
std::fill_n(m_buffers[0].span().begin(), kRubberBandBlockSize, 0.0f);
std::fill_n(m_buffers[1].span().begin(), kRubberBandBlockSize, 0.0f);
while (remaining_padding > 0) {
const size_t pad_samples = std::min<size_t>(remaining_padding, kRubberBandBlockSize);
m_pRubberBand->process(m_bufferPtrs.data(), pad_samples, false);
Expand Down
6 changes: 3 additions & 3 deletions src/engine/bufferscalers/enginebufferscalerubberband.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include <rubberband/RubberBandStretcher.h>

#include <array>
#include <vector>

#include "engine/bufferscalers/enginebufferscale.h"
#include "util/memory.h"
#include "util/samplebuffer.h"

class ReadAheadManager;

Expand Down Expand Up @@ -61,14 +61,14 @@ class EngineBufferScaleRubberBand final : public EngineBufferScale {
/// The audio buffers samples used to send audio to Rubber Band and to
/// receive processed audio from Rubber Band. This is needed because Mixxx
/// uses interleaved buffers in most other places.
std::array<std::vector<CSAMPLE>, 2> m_buffers;
std::array<mixxx::SampleBuffer, 2> m_buffers;
/// These point to the buffers in `m_buffers`. They can be defined here
/// since this object cannot be moved or copied.
std::array<float*, 2> m_bufferPtrs;

/// Contains interleaved samples read from `m_pReadAheadManager`. These need
/// to be deinterleaved before they can be passed to Rubber Band.
std::vector<CSAMPLE> m_interleavedReadBuffer;
mixxx::SampleBuffer m_interleavedReadBuffer;

// Holds the playback direction
bool m_bBackwards;
Expand Down

0 comments on commit 7016e0f

Please sign in to comment.