25{
26 const auto direction =
28
29 SECTION("simple test case")
30 {
31 const auto numChannels = GENERATE(1u, 2u);
32 const auto clip =
33 numChannels == 1u ?
34 std::make_shared<FloatVectorClip>(
36 std::make_shared<FloatVectorClip>(
42 if (numChannels == 1u)
43 {
45 std::vector<float> { 1.f, 2.f, 3.f } :
46 std::vector<float> { 3.f, 2.f, 1.f };
47 const auto asExpected = output.channelVectors[0] == expected;
48 REQUIRE(asExpected);
49 }
50 else
51 {
52 const auto expected =
54 std::vector<std::vector<float>> { { 1.f, 2.f, 3.f },
55 { -1.f, -2.f, -3.f } } :
56 std::vector<std::vector<float>> { { 3.f, 2.f, 1.f },
57 { -3.f, -2.f, -1.f } };
58 const auto asExpected = output.channelVectors == expected;
59 REQUIRE(asExpected);
60 }
61 }
62
63 SECTION("accounts for playback offset")
64 {
65 const auto clip = std::make_shared<FloatVectorClip>(
67 const auto numSamples = clip->GetVisibleSampleCount().as_size_t();
68
69 constexpr auto playbackOffset = 2 /
static_cast<double>(
sampleRate);
70 ClipSegment sut { *clip, playbackOffset, direction };
72 REQUIRE(sut.GetFloats(output.channelPointers.data(), numSamples) == 3);
74 std::vector<float> { 3.f, 4.f, 5.f, 0.f, 0.f } :
75 std::vector<float> { 3.f, 2.f, 1.f, 0.f, 0.f };
76 REQUIRE(output.channelVectors[0] == expected);
77 }
78}
std::vector< std::vector< float > > FloatVectorVector
constexpr auto sampleRate