MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / test_velocity_and_steps

Function test_velocity_and_steps

tests/unittests/test_diffusion_math.cpp:61–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void test_velocity_and_steps() {
62 std::vector<float> velocity{3.0F, 4.0F};
63 engine::sampling::clamp_velocity_norm(velocity, {6.0F, 8.0F}, 0.5F);
64 require_vector_close(velocity, {3.0F, 4.0F}, 1.0e-5F, "velocity clamp at threshold");
65
66 std::vector<float> scaled{6.0F, 8.0F};
67 engine::sampling::clamp_velocity_norm(scaled, {3.0F, 4.0F}, 0.5F);
68 require_vector_close(scaled, {1.5F, 2.0F}, 1.0e-5F, "velocity clamp scales");
69
70 std::vector<float> zero{0.0F, 0.0F};
71 engine::sampling::clamp_velocity_norm(zero, {0.0F, 0.0F}, 0.5F);
72 require_vector_close(zero, {0.0F, 0.0F}, 0.0F, "velocity clamp zero");
73
74 const std::vector<float> x{1.0F, 2.0F, 3.0F};
75 const std::vector<float> v{0.5F, -1.0F, 4.0F};
76 const std::vector<float> v2{1.0F, 1.0F, 0.0F};
77 require_vector_close(engine::sampling::euler_step(x, v, 0.25F), {0.875F, 2.25F, 2.0F}, 0.0F, "euler");
78 require_vector_close(engine::sampling::denoise_from_velocity(x, v, 0.75F), {0.625F, 2.75F, 0.0F}, 0.0F, "denoise");
79 require_vector_close(engine::sampling::renoise(x, {-1.0F, 0.0F, 2.0F}, 0.2F), {0.6F, 1.6F, 2.8F}, 2.0e-6F, "renoise");
80 require_vector_close(engine::sampling::heun_combine_velocity(v, v2), {0.75F, 0.0F, 2.0F}, 0.0F, "heun combine");
81 require_vector_close(engine::sampling::heun_step(x, v, v2, 0.25F), {0.8125F, 2.0F, 2.5F}, 0.0F, "heun step");
82}
83
84void test_masks() {
85 require_vector_close(

Callers 1

mainFunction · 0.85

Calls 7

clamp_velocity_normFunction · 0.85
euler_stepFunction · 0.85
denoise_from_velocityFunction · 0.85
heun_combine_velocityFunction · 0.85
heun_stepFunction · 0.85
require_vector_closeFunction · 0.70
renoiseFunction · 0.50

Tested by

no test coverage detected