mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-05-31 17:20:54 +00:00
Add VintageDreamsWaves-v2 in SF3 format and some tests for sf3 loading
This commit is contained in:
parent
3d05360f33
commit
f52bbf53a4
6 changed files with 143 additions and 0 deletions
|
@ -504,6 +504,7 @@ endif ( enable-readline )
|
||||||
if(enable-tests)
|
if(enable-tests)
|
||||||
# manipulate some variables to setup a proper test env
|
# manipulate some variables to setup a proper test env
|
||||||
set(TEST_SOUNDFONT "${CMAKE_SOURCE_DIR}/sf2/VintageDreamsWaves-v2.sf2")
|
set(TEST_SOUNDFONT "${CMAKE_SOURCE_DIR}/sf2/VintageDreamsWaves-v2.sf2")
|
||||||
|
set(TEST_SOUNDFONT_SF3 "${CMAKE_SOURCE_DIR}/sf2/VintageDreamsWaves-v2.sf3")
|
||||||
|
|
||||||
# force to build a static lib, in order to bypass the visibility control, allowing us
|
# force to build a static lib, in order to bypass the visibility control, allowing us
|
||||||
# to test fluidsynths private/internal functions
|
# to test fluidsynths private/internal functions
|
||||||
|
|
BIN
sf2/VintageDreamsWaves-v2.sf3
Normal file
BIN
sf2/VintageDreamsWaves-v2.sf3
Normal file
Binary file not shown.
|
@ -193,6 +193,9 @@
|
||||||
/* Soundfont to load for unit testing */
|
/* Soundfont to load for unit testing */
|
||||||
#cmakedefine TEST_SOUNDFONT "@TEST_SOUNDFONT@"
|
#cmakedefine TEST_SOUNDFONT "@TEST_SOUNDFONT@"
|
||||||
|
|
||||||
|
/* SF3 Soundfont to load for unit testing */
|
||||||
|
#cmakedefine TEST_SOUNDFONT_SF3 "@TEST_SOUNDFONT_SF3@"
|
||||||
|
|
||||||
/* Define to enable SIGFPE assertions */
|
/* Define to enable SIGFPE assertions */
|
||||||
#cmakedefine TRAP_ON_FPE @TRAP_ON_FPE@
|
#cmakedefine TRAP_ON_FPE @TRAP_ON_FPE@
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,11 @@ ADD_FLUID_TEST(test_sfont_loading)
|
||||||
ADD_FLUID_TEST(test_defsfont_preset_iteration)
|
ADD_FLUID_TEST(test_defsfont_preset_iteration)
|
||||||
ADD_FLUID_TEST(test_sample_rate_change)
|
ADD_FLUID_TEST(test_sample_rate_change)
|
||||||
|
|
||||||
|
if ( LIBSNDFILE_HASVORBIS )
|
||||||
|
ADD_FLUID_TEST(test_sf3_sfont_loading)
|
||||||
|
ADD_FLUID_TEST(test_sf3_defsfont_preset_iteration)
|
||||||
|
endif ( LIBSNDFILE_HASVORBIS )
|
||||||
|
|
||||||
|
|
||||||
add_custom_target(check
|
add_custom_target(check
|
||||||
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG> --output-on-failure
|
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG> --output-on-failure
|
||||||
|
@ -18,4 +23,7 @@ test_sample_cache
|
||||||
test_sfont_loading
|
test_sfont_loading
|
||||||
test_defsfont_preset_iteration
|
test_defsfont_preset_iteration
|
||||||
test_sample_rate_change
|
test_sample_rate_change
|
||||||
|
|
||||||
|
test_sf3_sfont_loading
|
||||||
|
test_sf3_defsfont_preset_iteration
|
||||||
)
|
)
|
||||||
|
|
61
test/test_sf3_defsfont_preset_iteration.c
Normal file
61
test/test_sf3_defsfont_preset_iteration.c
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#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;
|
||||||
|
}
|
70
test/test_sf3_sfont_loading.c
Normal file
70
test/test_sf3_sfont_loading.c
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#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_settings_t *settings = new_fluid_settings();
|
||||||
|
fluid_synth_t *synth = new_fluid_synth(settings);
|
||||||
|
|
||||||
|
TEST_ASSERT(settings != NULL);
|
||||||
|
TEST_ASSERT(synth != NULL);
|
||||||
|
|
||||||
|
// no sfont loaded
|
||||||
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 0);
|
||||||
|
|
||||||
|
FLUID_LOG(FLUID_INFO, "Attempt to open %s", TEST_SOUNDFONT_SF3);
|
||||||
|
|
||||||
|
// load a sfont to synth
|
||||||
|
TEST_SUCCESS(id = fluid_synth_sfload(synth, TEST_SOUNDFONT_SF3, 1));
|
||||||
|
|
||||||
|
// one sfont loaded
|
||||||
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 1);
|
||||||
|
|
||||||
|
sfont = fluid_synth_get_sfont_by_id(synth, id);
|
||||||
|
TEST_ASSERT(sfont != NULL);
|
||||||
|
|
||||||
|
// this is still the same filename as we've put in
|
||||||
|
TEST_ASSERT(FLUID_STRCMP(TEST_SOUNDFONT_SF3, fluid_sfont_get_name(sfont)) == 0);
|
||||||
|
TEST_ASSERT(fluid_sfont_get_id(sfont) == id);
|
||||||
|
|
||||||
|
// still the same id?
|
||||||
|
TEST_ASSERT(fluid_synth_sfreload(synth, id) == id);
|
||||||
|
// one sfont loaded
|
||||||
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 1);
|
||||||
|
|
||||||
|
sfont = fluid_synth_get_sfont_by_id(synth, id);
|
||||||
|
TEST_ASSERT(sfont != NULL);
|
||||||
|
|
||||||
|
// still the same filename?
|
||||||
|
TEST_ASSERT(FLUID_STRCMP(TEST_SOUNDFONT_SF3, fluid_sfont_get_name(sfont)) == 0);
|
||||||
|
// correct id stored?
|
||||||
|
TEST_ASSERT(fluid_sfont_get_id(sfont) == id);
|
||||||
|
|
||||||
|
// remove the sfont without deleting
|
||||||
|
TEST_SUCCESS(fluid_synth_remove_sfont(synth, sfont));
|
||||||
|
|
||||||
|
// no sfont loaded
|
||||||
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 0);
|
||||||
|
|
||||||
|
// re-add the sfont without deleting
|
||||||
|
TEST_SUCCESS(id = fluid_synth_add_sfont(synth, sfont));
|
||||||
|
|
||||||
|
// one sfont loaded
|
||||||
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 1);
|
||||||
|
|
||||||
|
// destroy the sfont
|
||||||
|
TEST_SUCCESS(fluid_synth_sfunload(synth, id, 0));
|
||||||
|
// no sfont loaded
|
||||||
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 0);
|
||||||
|
|
||||||
|
delete_fluid_synth(synth);
|
||||||
|
delete_fluid_settings(settings);
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue