Audacity 3.2.0
Namespaces | Functions | Variables
StretchingSequenceIntegrationTest.cpp File Reference
#include "AudioContainerHelper.h"
#include "MockPlayableSequence.h"
#include "MockSampleBlockFactory.h"
#include "SampleFormat.h"
#include "StretchingSequence.h"
#include "TestWaveClipMaker.h"
#include "TestWaveTrackMaker.h"
#include <catch2/catch.hpp>
Include dependency graph for StretchingSequenceIntegrationTest.cpp:

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{StretchingSequenceIntegrationTest.cpp}
 

Functions

 TEST_CASE ("StretchingSequence integration tests")
 

Variables

constexpr auto anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::sampleRate = 3
 
constexpr auto anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel = 0u
 
const auto anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::sampleBlockFactory = std::make_shared<MockSampleBlockFactory>()
 
TestWaveClipMaker anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::clipMaker { sampleRate, sampleBlockFactory }
 
TestWaveTrackMaker anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::trackMaker { sampleRate, sampleBlockFactory }
 

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "StretchingSequence integration tests"  )

Definition at line 32 of file StretchingSequenceIntegrationTest.cpp.

33{
34 const auto numChannels =
35 GENERATE(1 /*, 2*/); // When wide WaveTrack is implemented this test
36 // should also run in stereo.
37 const auto mockSequence =
38 std::make_shared<MockPlayableSequence>(sampleRate, numChannels);
39
40 SECTION(
41 "StretchingSequence and WaveTrack have identical outputs when clips aren't stretched.")
42 {
43 constexpr auto totalLength =
44 sampleRate * 4; // 1s no clip, 1s minusClip, 1s no clip, 1s plusClip
45
46 const auto minusClip = clipMaker.ClipFilledWith(
47 -.5f, sampleRate, numChannels,
48 [](auto& clip) { clip.SetPlayStartTime(1.0); });
49 const auto plusClip = clipMaker.ClipFilledWith(
50 +.5f, sampleRate, numChannels,
51 [](auto& clip) { clip.SetPlayStartTime(3.0); });
52
53 const auto sut = StretchingSequence::Create(
54 *mockSequence, ClipConstHolders { minusClip, plusClip });
55 const auto track = trackMaker.Track({ minusClip, plusClip });
56 constexpr auto backwards = false;
57 AudioContainer sutOutput(totalLength, numChannels);
58 REQUIRE(sut->DoGet(
59 iChannel, numChannels,
60 AudioContainerHelper::GetData<char>(sutOutput).data(), floatSample, 0u,
61 totalLength, backwards));
62
63 AudioContainer waveTrackOutput(totalLength, numChannels);
64 REQUIRE(track->DoGet(
65 iChannel, numChannels,
66 AudioContainerHelper::GetData<char>(waveTrackOutput).data(),
67 floatSample, 0u, totalLength, backwards));
68
69 const auto outputsAreIdentical =
70 sutOutput.channelVectors == waveTrackOutput.channelVectors;
71 REQUIRE(outputsAreIdentical);
72 }
73}
std::vector< std::shared_ptr< const ClipInterface > > ClipConstHolders
constexpr sampleFormat floatSample
Definition: SampleFormat.h:45
static std::shared_ptr< StretchingSequence > Create(const PlayableSequence &, const ClipConstHolders &clips)
WaveClipHolder ClipFilledWith(const std::vector< std::vector< float > > &values, Operations operations=[](WaveClip &) {}) const
std::shared_ptr< WaveTrack > Track(const WaveClipHolders &clips) const

References AudioContainer::channelVectors, TestWaveClipMaker::ClipFilledWith(), anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::clipMaker, StretchingSequence::Create(), floatSample, anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::iChannel, anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::sampleRate, TestWaveTrackMaker::Track(), and anonymous_namespace{StretchingSequenceIntegrationTest.cpp}::trackMaker.

Here is the call graph for this function: