Audacity 3.2.0
Functions
CompressorProcessorTests.cpp File Reference
#include "CompressorProcessor.h"
#include <catch2/catch.hpp>
Include dependency graph for CompressorProcessorTests.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("GetMaxCompressionDb", "simple test")
 
 TEST_CASE ("CompressorProcessor", "smoke test")
 

Function Documentation

◆ TEST_CASE() [1/2]

TEST_CASE ( "CompressorProcessor"  ,
"smoke test"   
)

Definition at line 42 of file CompressorProcessorTests.cpp.

43{
45 settings.lookaheadMs = 5;
47 constexpr auto sampleRate = 44100;
48 constexpr auto numChannels = 2;
49 constexpr auto blockSize = 44100;
50 constexpr auto signalSize = 2 * blockSize;
51 sut.Init(sampleRate, numChannels, blockSize);
52 std::vector<std::vector<float>> buffer(numChannels);
53 std::vector<float*> pointers(numChannels);
54 for (auto i = 0; i < numChannels; ++i)
55 {
56 auto& in = buffer[i];
57 in.resize(signalSize);
58 std::fill(in.begin(), in.begin() + signalSize / 2, 0.0f);
59 std::fill(in.begin() + signalSize / 2, in.end(), 1.0f);
60 }
61 auto progress = 0;
62 while (progress < signalSize)
63 {
64 const auto remaining = signalSize - progress;
65 const auto toProcess = std::min(remaining, blockSize);
66 std::transform(
67 buffer.begin(), buffer.end(), pointers.begin(),
68 [progress](std::vector<float>& v) { return v.data() + progress; });
69 const auto p = pointers.data();
70 sut.Process(p, p, toProcess);
71 progress += toProcess;
72 }
73}
int min(int a, int b)
static Settings & settings()
Definition: TrackInfo.cpp:51

References min(), anonymous_namespace{ClipSegmentTest.cpp}::sampleRate, and settings().

Here is the call graph for this function:

◆ TEST_CASE() [2/2]

TEST_CASE ( "GetMaxCompressionDb"  ,
"simple test"   
)

Audacity: A Digital Audio Editor

CompressorProcessorTests.cpp

Matthieu Hodgkinson

Definition at line 16 of file CompressorProcessorTests.cpp.

17{
19 settings.inCompressionThreshDb = -20;
20 settings.outCompressionThreshDb = -10;
21 settings.kneeWidthDb = 0;
22
23 // Infinite ratio -> max compression simply is the input compression
24 // threshold.
25 settings.compressionRatio = std::numeric_limits<float>::infinity();
27
28 // 2:1 ratio -> half the input compression threshold.
29 settings.compressionRatio = 2;
31
32 // So long as the knee half width is less than the input compression
33 // threshold, it shouldn't change the result.
34 settings.kneeWidthDb = 40;
36
37 // But if it's greater, it should.
38 settings.kneeWidthDb = 60;
40}
static float GetMaxCompressionDb(const DynamicRangeProcessorSettings &settings)

References CompressorProcessor::GetMaxCompressionDb(), and settings().

Here is the call graph for this function: