Skip to content

Commit

Permalink
feat(tests): Fader tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
na2axl committed Nov 24, 2024
1 parent 9f8db37 commit 762c672
Show file tree
Hide file tree
Showing 24 changed files with 241 additions and 300 deletions.
4 changes: 2 additions & 2 deletions include/SparkyStudios/Audio/Amplitude/Math/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
namespace SparkyStudios::Audio::Amplitude
{
/**
* @brief A structure containing control points for a Bezier curve.
* @brief A structure containing control points for a Bézier curve.
*
* @ingroup math
*/
struct BeizerCurveControlPoints
struct BezierCurveControlPoints
{
/**
* @brief The x coordinate of the second control point.
Expand Down
14 changes: 7 additions & 7 deletions include/SparkyStudios/Audio/Amplitude/Sound/Fader.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ namespace SparkyStudios::Audio::Amplitude
public:
/**
* @brief Create an animation transition function using
* a one-dimensional cubic bezier curve.
* a one-dimensional cubic Bézier curve.
*
* This use the exact same algorithm as in CSS. The first and last
* control points of the cubic bezier curve are fixed to (0,0)
* control points of the cubic Bézier curve are fixed to (0,0)
* and (1,1) respectively.
*/
struct Transition
Expand All @@ -69,7 +69,7 @@ namespace SparkyStudios::Audio::Amplitude
*
* @param[in] controlPoints The control points of the curve.
*/
Transition(const BeizerCurveControlPoints& controlPoints);
Transition(const BezierCurveControlPoints& controlPoints);

/**
* @brief Given an animation duration percentage (in the range [0, 1]),
Expand All @@ -84,7 +84,7 @@ namespace SparkyStudios::Audio::Amplitude
/**
* @brief The control points.
*/
BeizerCurveControlPoints m_controlPoints;
BezierCurveControlPoints m_controlPoints;

private:
[[nodiscard]] AmTime GetTFromX(AmReal64 x) const;
Expand Down Expand Up @@ -253,7 +253,7 @@ namespace SparkyStudios::Audio::Amplitude
*
* @return The control points of the transition curve used by this Fader.
*/
[[nodiscard]] virtual BeizerCurveControlPoints GetControlPoints() const = 0;
[[nodiscard]] virtual BezierCurveControlPoints GetControlPoints() const = 0;

/**
* @brief Registers a new fader.
Expand All @@ -270,7 +270,7 @@ namespace SparkyStudios::Audio::Amplitude
static void Unregister(const Fader* fader);

/**
* @brief Creates a new instance of the the fader with the given name and returns its pointer.
* @brief Creates a new instance of the fader with the given name and returns its pointer.
*
* @note The returned pointer should be deleted using @ref Destruct `Destruct()`.
*
Expand Down Expand Up @@ -298,7 +298,7 @@ namespace SparkyStudios::Audio::Amplitude
static void LockRegistry();

/**
* @brief Unlocks the faders registry.
* @brief Unlocks the fader's registry.
*
* @warning This function is mainly used for internal purposes. It's
* called after the `Engine` deinitialization, to allow the registration
Expand Down
34 changes: 1 addition & 33 deletions sample_project/pipelines/tests.double_consume.json
Original file line number Diff line number Diff line change
@@ -1,33 +1 @@
{
"id": 98,
"name": "tests.double_consume",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
1
]
},
{
"id": 2,
"name": "StereoMixer",
"consume": [
8,
8
]
},
{
"id": 9,
"name": "Output",
"consume": [
2
]
}
]
}
{"id":98,"name":"tests.double_consume","nodes":[{"id":1,"name":"Input","consume":[]},{"id":8,"name":"StereoPanning","consume":[1]},{"id":2,"name":"StereoMixer","consume":[8,8]},{"id":9,"name":"Output","consume":[2]}]}
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
{
"id": 99,
"name": "tests.invalid_consumer_node",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
3
]
},
{
"id": 9,
"name": "Output",
"consume": [
8
]
},
{
"id": 3,
"name": "InvalidConsumerNode",
"consume": [
1
]
}
]
}
{"id":99,"name":"tests.invalid_consumer_node","nodes":[{"id":1,"name":"Input","consume":[]},{"id":8,"name":"StereoPanning","consume":[3]},{"id":9,"name":"Output","consume":[8]},{"id":3,"name":"InvalidConsumerNode","consume":[1]}]}
Original file line number Diff line number Diff line change
@@ -1,33 +1 @@
{
"id": 93,
"name": "tests.invalid_producers_count",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 2,
"name": "Attenuation",
"consume": [
1
]
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
1,
2
]
},
{
"id": 9,
"name": "Output",
"consume": [
8
]
}
]
}
{"id":93,"name":"tests.invalid_producers_count","nodes":[{"id":1,"name":"Input","consume":[]},{"id":2,"name":"Attenuation","consume":[1]},{"id":8,"name":"StereoPanning","consume":[1,2]},{"id":9,"name":"Output","consume":[8]}]}
19 changes: 1 addition & 18 deletions sample_project/pipelines/tests.invalid.missing_input.json
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
{
"id": 90,
"name": "tests.missing_input",
"nodes": [
{
"id": 8,
"name": "StereoPanning",
"consume": []
},
{
"id": 9,
"name": "Output",
"consume": [
8
]
}
]
}
{"id":90,"name":"tests.missing_input","nodes":[{"id":8,"name":"StereoPanning","consume":[]},{"id":9,"name":"Output","consume":[8]}]}
19 changes: 1 addition & 18 deletions sample_project/pipelines/tests.invalid.missing_output.json
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
{
"id": 91,
"name": "tests.missing_output",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
1
]
}
]
}
{"id":91,"name":"tests.missing_output","nodes":[{"id":1,"name":"Input","consume":[]},{"id":8,"name":"StereoPanning","consume":[1]}]}
24 changes: 1 addition & 23 deletions sample_project/pipelines/tests.invalid.missing_producers.json
Original file line number Diff line number Diff line change
@@ -1,23 +1 @@
{
"id": 92,
"name": "tests.missing_producers",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": []
},
{
"id": 9,
"name": "Output",
"consume": [
8
]
}
]
}
{"id":92,"name":"tests.missing_producers","nodes":[{"id":1,"name":"Input","consume":[]},{"id":8,"name":"StereoPanning","consume":[]},{"id":9,"name":"Output","consume":[8]}]}
31 changes: 1 addition & 30 deletions sample_project/pipelines/tests.invalid.multiple_input.json
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
{
"id": 94,
"name": "tests.multiple_input",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 2,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
1
]
},
{
"id": 9,
"name": "Output",
"consume": [
2
]
}
]
}
{"id":94,"name":"tests.multiple_input","nodes":[{"id":1,"name":"Input","consume":[]},{"id":2,"name":"Input","consume":[]},{"id":8,"name":"StereoPanning","consume":[1]},{"id":9,"name":"Output","consume":[2]}]}
33 changes: 1 addition & 32 deletions sample_project/pipelines/tests.invalid.multiple_output.json
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
{
"id": 95,
"name": "tests.multiple_output",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
1
]
},
{
"id": 9,
"name": "Output",
"consume": [
8
]
},
{
"id": 3,
"name": "Output",
"consume": [
1
]
}
]
}
{"id":95,"name":"tests.multiple_output","nodes":[{"id":1,"name":"Input","consume":[]},{"id":8,"name":"StereoPanning","consume":[1]},{"id":9,"name":"Output","consume":[8]},{"id":3,"name":"Output","consume":[1]}]}
19 changes: 1 addition & 18 deletions sample_project/pipelines/tests.invalid.self_consume.json
Original file line number Diff line number Diff line change
@@ -1,18 +1 @@
{
"id": 97,
"name": "tests.self_consume",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 9,
"name": "Output",
"consume": [
9
]
}
]
}
{"id":97,"name":"tests.self_consume","nodes":[{"id":1,"name":"Input","consume":[]},{"id":9,"name":"Output","consume":[9]}]}
33 changes: 1 addition & 32 deletions sample_project/pipelines/tests.invalid.unknown_node.json
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
{
"id": 96,
"name": "tests.unknown_node",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
3
]
},
{
"id": 9,
"name": "Output",
"consume": [
8
]
},
{
"id": 3,
"name": "DoSomethingWeird",
"consume": [
1
]
}
]
}
{"id":96,"name":"tests.unknown_node","nodes":[{"id":1,"name":"Input","consume":[]},{"id":8,"name":"StereoPanning","consume":[3]},{"id":9,"name":"Output","consume":[8]},{"id":3,"name":"DoSomethingWeird","consume":[1]}]}
2 changes: 1 addition & 1 deletion sample_project/sounds/tests/test_sound_01.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"id":9991,"name":"test_sound_01","effect":0,"gain":{"kind":"Static","value":1},"pitch":{"kind":"Static","value":1},"bus":1,"priority":{"kind":"Static","value":1},"spatialization":0,"attenuation":0,"scope":0,"fader":"Linear","stream":false,"loop":{"enabled":false,"loop_count":5},"near_field_gain":{"kind":"Static","value":0},"path":"tests/test_sound_01.wav"}
{"id":9991,"name":"test_sound_01","effect":0,"gain":{"kind":"Static","value":1},"pitch":{"kind":"Static","value":1},"bus":1,"priority":{"kind":"Static","value":1},"spatialization":3,"attenuation":0,"scope":0,"fader":"Linear","stream":false,"loop":{"enabled":false,"loop_count":5},"near_field_gain":{"kind":"Static","value":0},"path":"tests/test_sound_01.wav"}
2 changes: 1 addition & 1 deletion src/Sound/Fader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace SparkyStudios::Audio::Amplitude
}
}

FaderInstance::Transition::Transition(const BeizerCurveControlPoints& controlPoints)
FaderInstance::Transition::Transition(const BezierCurveControlPoints& controlPoints)
: Transition(controlPoints.x1, controlPoints.y1, controlPoints.x2, controlPoints.y2)
{}

Expand Down
Loading

0 comments on commit 762c672

Please sign in to comment.