Audacity 3.2.0
ClipTimeAndPitchSourceTest.cpp
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 ClipTimeAndPitchSourceTest.cpp
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
12#include "AudioContainer.h"
13#include "FloatVectorClip.h"
14
15#include <catch2/catch.hpp>
16
17namespace
18{
19constexpr auto sampleRate = 3;
20using FloatVectorVector = std::vector<std::vector<float>>;
21} // namespace
22
23TEST_CASE("ClipTimeAndPitchSource")
24{
25 const auto direction =
27
28 SECTION("Pull reads correctly past the end of the clip")
29 {
30 const auto clip = std::make_shared<FloatVectorClip>(
31 sampleRate, FloatVectorVector { { 1.f, 2.f, 3.f, 4.f, 5.f } });
32 ClipTimeAndPitchSource sut { *clip, 0., direction };
33 constexpr auto bufferSize = 3;
34 AudioContainer output(bufferSize, 1u);
35
36 sut.Pull(output.channelPointers.data(), bufferSize);
37 const auto firstExpected = direction == PlaybackDirection::forward ?
38 std::vector<float> { 1.f, 2.f, 3.f } :
39 std::vector<float> { 5.f, 4.f, 3.f };
40 REQUIRE(output.channelVectors[0] == firstExpected);
41
42 sut.Pull(output.channelPointers.data(), bufferSize);
43 const auto secondExpected = direction == PlaybackDirection::forward ?
44 std::vector<float> { 4.f, 5.f, 0.f } :
45 std::vector<float> { 2.f, 1.f, 0.f };
46 REQUIRE(output.channelVectors[0] == secondExpected);
47 }
48}
TEST_CASE("ClipTimeAndPitchSource")
std::vector< float * > channelPointers
std::vector< std::vector< float > > channelVectors