mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-18 18:11:05 +00:00
Add a unit test for fluid_ct2hz_real()
This commit is contained in:
parent
5919be2ceb
commit
3c4861c752
2 changed files with 37 additions and 0 deletions
|
@ -16,6 +16,7 @@ ADD_FLUID_TEST(test_seqbind_unregister)
|
|||
ADD_FLUID_TEST(test_synth_chorus_reverb)
|
||||
ADD_FLUID_TEST(test_snprintf)
|
||||
ADD_FLUID_TEST(test_synth_process)
|
||||
ADD_FLUID_TEST(test_ct2hz)
|
||||
|
||||
# if ( LIBSNDFILE_HASVORBIS )
|
||||
# ADD_FLUID_TEST(test_sf3_sfont_loading)
|
||||
|
|
36
test/test_ct2hz.c
Normal file
36
test/test_ct2hz.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
#include "test.h"
|
||||
#include "utils/fluid_conv.h"
|
||||
#include "utils/fluid_sys.h"
|
||||
|
||||
// this test makes sure FLUID_SNPRINTF uses a proper C99 compliant implementation
|
||||
|
||||
int float_eq(fluid_real_t x, fluid_real_t y)
|
||||
{
|
||||
static const float EPS = 1e-5;
|
||||
return fabs(x-y) < EPS;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// 440 * 2^((x-6900)/1200) where x is the cent value given to ct2hz()
|
||||
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(13500), 19912.12696));
|
||||
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(12900), 14080));
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(12899), 14071.86942));
|
||||
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(12700), 12543.85395));
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(6900), 440));
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(5700), 220));
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(4500), 110));
|
||||
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(901), 13.75794461));
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(900), 13.75));
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(899), 13.74205998));
|
||||
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(1), 8.180522806));
|
||||
TEST_ASSERT(float_eq(fluid_ct2hz_real(0), 8.175798916)); // often referred to as Absolute zero in the SF2 spec
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in a new issue