2018-04-08 07:41:48 +00:00
|
|
|
|
|
|
|
#include "test.h"
|
|
|
|
#include "fluidsynth.h"
|
|
|
|
#include "sfloader/fluid_sfont.h"
|
2019-02-15 11:28:22 +00:00
|
|
|
#include "utils/fluid_sys.h"
|
2018-04-08 07:41:48 +00:00
|
|
|
|
|
|
|
|
2018-04-11 09:11:27 +00:00
|
|
|
// this tests the soundfont loading API of the synth.
|
|
|
|
// might be expanded to test the soundfont loader as well...
|
2018-04-08 07:41:48 +00:00
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
fluid_sfont_t *sfont;
|
2018-06-24 11:01:31 +00:00
|
|
|
|
2018-04-08 07:41:48 +00:00
|
|
|
fluid_settings_t *settings = new_fluid_settings();
|
|
|
|
fluid_synth_t *synth = new_fluid_synth(settings);
|
2018-06-24 11:01:31 +00:00
|
|
|
|
2018-04-11 08:23:17 +00:00
|
|
|
TEST_ASSERT(settings != NULL);
|
|
|
|
TEST_ASSERT(synth != NULL);
|
2018-06-24 11:01:31 +00:00
|
|
|
|
2018-04-08 07:41:48 +00:00
|
|
|
// no sfont loaded
|
2018-04-11 08:23:17 +00:00
|
|
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 0);
|
2018-06-24 11:01:31 +00:00
|
|
|
|
2018-12-09 09:35:21 +00:00
|
|
|
TEST_ASSERT(fluid_is_soundfont(TEST_SOUNDFONT) == TRUE);
|
|
|
|
|
2018-04-08 07:41:48 +00:00
|
|
|
// load a sfont to synth
|
2018-04-11 09:03:12 +00:00
|
|
|
TEST_SUCCESS(id = fluid_synth_sfload(synth, TEST_SOUNDFONT, 1));
|
2018-04-08 07:41:48 +00:00
|
|
|
// one sfont loaded
|
2018-04-11 08:23:17 +00:00
|
|
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 1);
|
|
|
|
TEST_ASSERT((sfont = fluid_synth_get_sfont_by_id(synth, id)) != NULL);
|
2018-06-24 11:01:31 +00:00
|
|
|
|
2018-04-08 07:41:48 +00:00
|
|
|
// this is still the same filename as we've put in
|
2018-04-11 09:03:12 +00:00
|
|
|
TEST_ASSERT(FLUID_STRCMP(TEST_SOUNDFONT, fluid_sfont_get_name(sfont)) == 0);
|
2018-04-11 08:23:17 +00:00
|
|
|
TEST_ASSERT(fluid_sfont_get_id(sfont) == id);
|
2018-06-24 11:01:31 +00:00
|
|
|
|
2018-04-08 07:41:48 +00:00
|
|
|
// still the same id?
|
2018-04-11 08:23:17 +00:00
|
|
|
TEST_ASSERT(fluid_synth_sfreload(synth, id) == id);
|
2018-04-08 07:41:48 +00:00
|
|
|
// one sfont loaded
|
2018-04-11 08:23:17 +00:00
|
|
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 1);
|
|
|
|
TEST_ASSERT((sfont = fluid_synth_get_sfont_by_id(synth, id)) != NULL);
|
2018-06-24 11:01:31 +00:00
|
|
|
|
2018-04-08 07:41:48 +00:00
|
|
|
// still the same filename?
|
2018-04-11 09:03:12 +00:00
|
|
|
TEST_ASSERT(FLUID_STRCMP(TEST_SOUNDFONT, fluid_sfont_get_name(sfont)) == 0);
|
2018-04-08 07:41:48 +00:00
|
|
|
// correct id stored?
|
2018-04-11 08:23:17 +00:00
|
|
|
TEST_ASSERT(fluid_sfont_get_id(sfont) == id);
|
2018-06-24 11:01:31 +00:00
|
|
|
|
2018-04-08 07:41:48 +00:00
|
|
|
// remove the sfont without deleting
|
|
|
|
TEST_SUCCESS(fluid_synth_remove_sfont(synth, sfont));
|
|
|
|
// no sfont loaded
|
2018-04-11 08:23:17 +00:00
|
|
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 0);
|
2018-06-24 11:01:31 +00:00
|
|
|
|
2018-04-08 07:41:48 +00:00
|
|
|
// re-add the sfont without deleting
|
|
|
|
TEST_SUCCESS(id = fluid_synth_add_sfont(synth, sfont));
|
|
|
|
// one sfont loaded
|
2018-04-11 08:23:17 +00:00
|
|
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 1);
|
2018-06-24 11:01:31 +00:00
|
|
|
|
|
|
|
|
2018-04-08 07:41:48 +00:00
|
|
|
// destroy the sfont
|
|
|
|
TEST_SUCCESS(fluid_synth_sfunload(synth, id, 0));
|
|
|
|
// no sfont loaded
|
2018-04-11 08:23:17 +00:00
|
|
|
TEST_ASSERT(fluid_synth_sfcount(synth) == 0);
|
2018-06-24 11:01:31 +00:00
|
|
|
|
2018-04-08 07:41:48 +00:00
|
|
|
delete_fluid_synth(synth);
|
|
|
|
delete_fluid_settings(settings);
|
2018-06-24 11:01:31 +00:00
|
|
|
|
2018-04-08 07:41:48 +00:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|