WE Core
Loading...
Searching...
No Matches
AREnvelopeFollowerTests.cpp
Go to the documentation of this file.
1/*
2 * File: AREnvelopeFollowerTests.cpp
3 *
4 * Created: 03/06/2017
5 *
6 * This file is part of WECore.
7 *
8 * WECore is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * WECore is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with WECore. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "catch.hpp"
24
25SCENARIO("AREnvelopeFollowerSquareLaw: Parameters can be set and retrieved correctly") {
26 GIVEN("A new AREnvelopeFollower object") {
28
29 WHEN("Nothing is changed") {
30 THEN("Parameters have their default values") {
31 CHECK(mEnv.getAttackTimeMs() == Approx(20.0));
32 CHECK(mEnv.getReleaseTimeMs() == Approx(200.0));
33 CHECK(mEnv.getFilterEnabled() == false);
34 CHECK(mEnv.getLowCutHz() == Approx(0.0));
35 CHECK(mEnv.getHighCutHz() == Approx(20000.0));
36 }
37 }
38
39 WHEN("All parameters are changed to unique values") {
40 mEnv.setAttackTimeMs(21.0);
41 mEnv.setReleaseTimeMs(22.0);
42 mEnv.setFilterEnabled(true);
43 mEnv.setLowCutHz(23.0);
44 mEnv.setHighCutHz(24.0);
45
46 THEN("They all get their correct unique values") {
47 CHECK(mEnv.getAttackTimeMs() == Approx(21.0));
48 CHECK(mEnv.getReleaseTimeMs() == Approx(22.0));
49 CHECK(mEnv.getFilterEnabled() == true);
50 CHECK(mEnv.getLowCutHz() == Approx(23.0));
51 CHECK(mEnv.getHighCutHz() == Approx(24.0));
52 }
53 }
54 }
55}
56
57SCENARIO("AREnvelopeFollowerSquareLaw: Parameters enforce their bounds correctly") {
58 GIVEN("A new AREnvelopeFollower object") {
60
61 WHEN("All parameter values are too low") {
62 mEnv.setAttackTimeMs(0);
63 mEnv.setReleaseTimeMs(0);
64 mEnv.setLowCutHz(-1);
65 mEnv.setHighCutHz(-1);
66
67 THEN("Parameters enforce their lower bounds") {
68 CHECK(mEnv.getAttackTimeMs() == Approx(0.1));
69 CHECK(mEnv.getReleaseTimeMs() == Approx(0.1));
70 CHECK(mEnv.getLowCutHz() == Approx(0.0));
71 CHECK(mEnv.getHighCutHz() == Approx(0.0));
72 }
73 }
74
75 WHEN("All parameter values are too high") {
76 mEnv.setAttackTimeMs(10001);
77 mEnv.setReleaseTimeMs(10001);
78 mEnv.setLowCutHz(20001);
79 mEnv.setHighCutHz(20001);
80
81 THEN("Parameters enforce their upper bounds") {
82 CHECK(mEnv.getAttackTimeMs() == Approx(10000));
83 CHECK(mEnv.getReleaseTimeMs() == Approx(10000));
84 CHECK(mEnv.getLowCutHz() == Approx(20000.0));
85 CHECK(mEnv.getHighCutHz() == Approx(20000.0));
86 }
87 }
88 }
89}
SCENARIO("CarveNoiseFilter: Silence in = silence out")