Audacity 3.2.0
TimeAndPitchRealSource.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 TimeAndPitchRealSource.cpp
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
11#pragma once
12
14
15#include <cassert>
16
18{
19public:
20 TimeAndPitchRealSource(const std::vector<std::vector<float>>& input)
21 : mInput(input)
22 {
23 }
24
25 void Pull(float* const* buffer, size_t samplesPerChannel) override
26 {
27 const auto numFrames = mInput[0].size();
28 const auto remainingSamples =
29 numFrames > mNumPulledFrames ? numFrames - mNumPulledFrames : 0u;
30 const size_t framesToRead = std::min(
31 remainingSamples,
32 static_cast<decltype(remainingSamples)>(samplesPerChannel));
33 const auto numZerosToPad = samplesPerChannel - framesToRead;
34 for (auto i = 0u; i < mInput.size(); ++i)
35 {
36 const auto in = mInput[i].data() + mNumPulledFrames;
37 std::copy(in, in + framesToRead, buffer[i]);
38 std::fill(
39 buffer[i] + framesToRead, buffer[i] + framesToRead + numZerosToPad,
40 0.f);
41 }
42 mNumPulledFrames += framesToRead;
43 }
44
45private:
46 const std::vector<std::vector<float>>& mInput;
47 unsigned long long mNumPulledFrames = 0u;
48};
int min(int a, int b)
void Pull(float *const *buffer, size_t samplesPerChannel) override
unsigned long long mNumPulledFrames
TimeAndPitchRealSource(const std::vector< std::vector< float > > &input)
const std::vector< std::vector< float > > & mInput
void copy(const T *src, T *dst, int32_t n)
Definition: VectorOps.h:40