mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-20 19:02:04 +00:00
fuse preset iteration tests to preset+sample loading tests
This commit is contained in:
parent
a95a4864fd
commit
044c5e3238
4 changed files with 88 additions and 105 deletions
|
@ -11,10 +11,9 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG> --output-on
|
||||||
## add unit tests here ##
|
## add unit tests here ##
|
||||||
ADD_FLUID_TEST(test_sample_cache)
|
ADD_FLUID_TEST(test_sample_cache)
|
||||||
ADD_FLUID_TEST(test_sfont_loading)
|
ADD_FLUID_TEST(test_sfont_loading)
|
||||||
ADD_FLUID_TEST(test_defsfont_preset_iteration)
|
|
||||||
ADD_FLUID_TEST(test_sample_rate_change)
|
ADD_FLUID_TEST(test_sample_rate_change)
|
||||||
|
ADD_FLUID_TEST(test_preset_sample_loading)
|
||||||
|
|
||||||
if ( LIBSNDFILE_HASVORBIS )
|
if ( LIBSNDFILE_HASVORBIS )
|
||||||
ADD_FLUID_TEST(test_sf3_sfont_loading)
|
ADD_FLUID_TEST(test_sf3_sfont_loading)
|
||||||
ADD_FLUID_TEST(test_sf3_defsfont_preset_iteration)
|
|
||||||
endif ( LIBSNDFILE_HASVORBIS )
|
endif ( LIBSNDFILE_HASVORBIS )
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
#include "test.h"
|
|
||||||
#include "fluidsynth.h"
|
|
||||||
#include "sfloader/fluid_sfont.h"
|
|
||||||
#include "utils/fluidsynth_priv.h"
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
fluid_sfont_t *sfont;
|
|
||||||
fluid_preset_t *preset;
|
|
||||||
fluid_preset_t *prev_preset = NULL;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
/* setup */
|
|
||||||
fluid_settings_t *settings = new_fluid_settings();
|
|
||||||
fluid_synth_t *synth = new_fluid_synth(settings);
|
|
||||||
|
|
||||||
/* Load the VintageDreams soundfont */
|
|
||||||
id = fluid_synth_sfload(synth, TEST_SOUNDFONT, 1);
|
|
||||||
sfont = fluid_synth_get_sfont_by_id(synth, id);
|
|
||||||
|
|
||||||
/* code under test */
|
|
||||||
fluid_sfont_iteration_start(sfont);
|
|
||||||
|
|
||||||
while ((preset = fluid_sfont_iteration_next(sfont)) != NULL) {
|
|
||||||
count++;
|
|
||||||
|
|
||||||
/* make sure we actually got a different preset */
|
|
||||||
TEST_ASSERT(preset != prev_preset);
|
|
||||||
|
|
||||||
prev_preset = preset;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* VintageDreams has 136 presets */
|
|
||||||
TEST_ASSERT(count == 136);
|
|
||||||
|
|
||||||
/* teardown */
|
|
||||||
delete_fluid_synth(synth);
|
|
||||||
delete_fluid_settings(settings);
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
87
test/test_preset_sample_loading.c
Normal file
87
test/test_preset_sample_loading.c
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
#include "test.h"
|
||||||
|
#include "fluidsynth.h"
|
||||||
|
#include "sfloader/fluid_sfont.h"
|
||||||
|
#include "sfloader/fluid_defsfont.h"
|
||||||
|
#include "utils/fluidsynth_priv.h"
|
||||||
|
#include "utils/fluid_list.h"
|
||||||
|
|
||||||
|
// load our sf2 and sf3 test soundfonts, with and without dynamic sample loading
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int id[2], sfcount;
|
||||||
|
|
||||||
|
/* setup */
|
||||||
|
fluid_settings_t *settings = new_fluid_settings();
|
||||||
|
|
||||||
|
for(int dyn_sample=0; dyn_sample <= 1; dyn_sample++)
|
||||||
|
{
|
||||||
|
fluid_synth_t *synth;
|
||||||
|
fluid_settings_setint(settings, "synth.dynamic-sample-loading", dyn_sample);
|
||||||
|
synth = new_fluid_synth(settings);
|
||||||
|
id[0] = fluid_synth_sfload(synth, TEST_SOUNDFONT, 0);
|
||||||
|
id[1] = fluid_synth_sfload(synth, TEST_SOUNDFONT_SF3, 0);
|
||||||
|
sfcount = fluid_synth_sfcount(synth);
|
||||||
|
|
||||||
|
TEST_ASSERT(id[0] != FLUID_FAILED);
|
||||||
|
|
||||||
|
#if LIBSNDFILE_SUPPORT
|
||||||
|
TEST_ASSERT(id[1] != FLUID_FAILED);
|
||||||
|
TEST_ASSERT(sfcount == 2);
|
||||||
|
#else
|
||||||
|
TEST_ASSERT(id[1] == FLUID_FAILED);
|
||||||
|
TEST_ASSERT(sfcount == 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for(int i=0; i<sfcount; i++)
|
||||||
|
{
|
||||||
|
fluid_preset_t *preset;
|
||||||
|
fluid_list_t *list;
|
||||||
|
fluid_preset_t *prev_preset = NULL;
|
||||||
|
fluid_sample_t *prev_sample = NULL;
|
||||||
|
int count = 0;
|
||||||
|
fluid_sfont_t *sfont = fluid_synth_get_sfont_by_id(synth, id[i]);
|
||||||
|
fluid_defsfont_t *defsfont = fluid_sfont_get_data(sfont);
|
||||||
|
|
||||||
|
/* Make sure we have the right number of presets */
|
||||||
|
fluid_sfont_iteration_start(sfont);
|
||||||
|
while ((preset = fluid_sfont_iteration_next(sfont)) != NULL) {
|
||||||
|
count++;
|
||||||
|
|
||||||
|
if(preset->notify != NULL)
|
||||||
|
{
|
||||||
|
preset->notify(preset, FLUID_PRESET_SELECTED, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* make sure we actually got a different preset */
|
||||||
|
TEST_ASSERT(preset != prev_preset);
|
||||||
|
prev_preset = preset;
|
||||||
|
}
|
||||||
|
/* VintageDreams has 136 presets */
|
||||||
|
TEST_ASSERT(count == 136);
|
||||||
|
|
||||||
|
/* Make sure we have the right number of samples */
|
||||||
|
count = 0;
|
||||||
|
for (list = defsfont->sample; list; list = fluid_list_next(list))
|
||||||
|
{
|
||||||
|
fluid_sample_t *sample = fluid_list_get(list);
|
||||||
|
if (sample->data != NULL)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_ASSERT(sample->amplitude_that_reaches_noise_floor_is_valid);
|
||||||
|
|
||||||
|
/* Make sure we actually got a different sample */
|
||||||
|
TEST_ASSERT(sample != prev_sample);
|
||||||
|
prev_sample = sample;
|
||||||
|
}
|
||||||
|
/* VintageDreams has 123 valid samples (one is a ROM sample and ignored) */
|
||||||
|
TEST_ASSERT(count == 123);
|
||||||
|
}
|
||||||
|
/* teardown */
|
||||||
|
delete_fluid_synth(synth);
|
||||||
|
}
|
||||||
|
delete_fluid_settings(settings);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
|
@ -1,61 +0,0 @@
|
||||||
#include "test.h"
|
|
||||||
#include "fluidsynth.h"
|
|
||||||
#include "sfloader/fluid_sfont.h"
|
|
||||||
#include "sfloader/fluid_defsfont.h"
|
|
||||||
#include "utils/fluidsynth_priv.h"
|
|
||||||
#include "utils/fluid_list.h"
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int id;
|
|
||||||
fluid_sfont_t *sfont;
|
|
||||||
fluid_list_t *list;
|
|
||||||
fluid_preset_t *preset;
|
|
||||||
fluid_preset_t *prev_preset = NULL;
|
|
||||||
fluid_defsfont_t *defsfont;
|
|
||||||
fluid_sample_t *sample;
|
|
||||||
fluid_sample_t *prev_sample = NULL;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
/* setup */
|
|
||||||
fluid_settings_t *settings = new_fluid_settings();
|
|
||||||
fluid_synth_t *synth = new_fluid_synth(settings);
|
|
||||||
id = fluid_synth_sfload(synth, TEST_SOUNDFONT_SF3, 1);
|
|
||||||
sfont = fluid_synth_get_sfont_by_id(synth, id);
|
|
||||||
defsfont = fluid_sfont_get_data(sfont);
|
|
||||||
|
|
||||||
/* Make sure we have the right number of presets */
|
|
||||||
fluid_sfont_iteration_start(sfont);
|
|
||||||
while ((preset = fluid_sfont_iteration_next(sfont)) != NULL) {
|
|
||||||
count++;
|
|
||||||
|
|
||||||
/* make sure we actually got a different preset */
|
|
||||||
TEST_ASSERT(preset != prev_preset);
|
|
||||||
prev_preset = preset;
|
|
||||||
}
|
|
||||||
/* VintageDreams has 136 presets */
|
|
||||||
TEST_ASSERT(count == 136);
|
|
||||||
|
|
||||||
/* Make sure we have the right number of samples */
|
|
||||||
count = 0;
|
|
||||||
for (list = defsfont->sample; list; list = fluid_list_next(list))
|
|
||||||
{
|
|
||||||
sample = fluid_list_get(list);
|
|
||||||
if (sample->data != NULL)
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make sure we actually got a different sample */
|
|
||||||
TEST_ASSERT(sample != prev_sample);
|
|
||||||
prev_sample = sample;
|
|
||||||
}
|
|
||||||
/* VintageDreams has 123 valid samples (one is a ROM sample and ignored) */
|
|
||||||
TEST_ASSERT(count == 123);
|
|
||||||
|
|
||||||
/* teardown */
|
|
||||||
delete_fluid_synth(synth);
|
|
||||||
delete_fluid_settings(settings);
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
Loading…
Reference in a new issue