From 8b448ffd4b51e72784902748ea8310dfd08a4bc9 Mon Sep 17 00:00:00 2001 From: derselbst Date: Wed, 17 Apr 2019 19:20:36 +0200 Subject: [PATCH 1/3] fix build with MSVC --- test/test_synth_process.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_synth_process.c b/test/test_synth_process.c index d273bdf2..bdae3bbd 100644 --- a/test/test_synth_process.c +++ b/test/test_synth_process.c @@ -5,12 +5,13 @@ #include "fluid_synth.h" #include -static int smpl; // static const int CHANNELS=16; -static const int SAMPLES=1024; +enum { SAMPLES=1024 }; int render_one_mock(fluid_synth_t *synth, int blocks) { + static int smpl; + fluid_real_t *left_in, *fx_left_in; fluid_real_t *right_in, *fx_right_in; From b817232f163a3e0b40f1e14a4e842bc7070ab1b0 Mon Sep 17 00:00:00 2001 From: derselbst Date: Wed, 17 Apr 2019 20:07:40 +0200 Subject: [PATCH 2/3] update API docs for 2.0.5 --- doc/fluidsynth-v20-devdoc.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/fluidsynth-v20-devdoc.txt b/doc/fluidsynth-v20-devdoc.txt index ee529a0c..997739c1 100644 --- a/doc/fluidsynth-v20-devdoc.txt +++ b/doc/fluidsynth-v20-devdoc.txt @@ -9,7 +9,7 @@ \author Tom Moebert \author Copyright © 2003-2019 Peter Hanappe, Conrad Berhörster, Antoine Schmitt, Pedro López-Cabanillas, Josh Green, David Henningsson, Tom Moebert \version Revision 2.0.5 -\date 2019-04-13 +\date 2019-04-17 All the source code examples in this document are in the public domain; you can use them as you please. This document is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ . The FluidSynth library is distributed under the GNU Lesser General Public License. A copy of the GNU Lesser General Public License is contained in the FluidSynth package; if not, visit http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @@ -21,6 +21,7 @@ All the source code examples in this document are in the public domain; you can - \ref Disclaimer - \ref Introduction +- \ref NewIn2_0_5 - \ref NewIn2_0_3 - \ref NewIn2_0_2 - \ref NewIn2_0_0 @@ -62,6 +63,11 @@ What is FluidSynth? - FluidSynth is open source, in active development. For more details, take a look at http://www.fluidsynth.org +\section NewIn2_0_5 Whats new in 2.0.5? + +- fluid_synth_process() omitted audio samples when called with arbitrary sample counts that were not a multiple of fluid_synth_get_internal_bufsize() +- fluid_synth_sfunload() was not releasing sample buffers of SoundFont3 files if "synth.dynamic-sample-loading" was set to FALSE + \section NewIn2_0_3 Whats new in 2.0.3? - fix incorrect behaviour of fluid_sample_set_sound_data() @@ -141,7 +147,7 @@ FluidSynths major version was bumped. The API was reworked, deprecated functions - remove deprecated fluid_synth_select_tuning(), use fluid_synth_activate_tuning(synth, chan, bank, prog, FALSE) instead - remove deprecated fluid_synth_reset_tuning(), use fluid_synth_deactivate_tuning(synth, chan, FALSE) instead - remove deprecated FLUID_HINT_INTEGER -- remove deprecated fluid_synth_set_gen2() as there doesnt seem to be a use case for absolute generator values +- remove deprecated fluid_synth_set_gen2() as there doesn't seem to be a use case for absolute generator values - remove deprecated "synth.parallel-render" setting - remove obsolete "audio.[out|in]put-channels" settings - remove unimplemented "synth.dump" setting From 7f11a9bf5c7304e04309a6ec9fc515ee815524bf Mon Sep 17 00:00:00 2001 From: derselbst Date: Thu, 18 Apr 2019 19:43:39 +0200 Subject: [PATCH 3/3] use a common function for opening regular files Fixes #514 --- src/midi/fluid_midi.c | 8 +------- src/sfloader/fluid_defsfont.c | 2 +- src/sfloader/fluid_sffile.c | 8 +------- src/sfloader/fluid_sfont.c | 22 +++++----------------- src/utils/fluid_sys.c | 33 +++++++++++++++++++++++++++++++++ src/utils/fluid_sys.h | 2 +- 6 files changed, 42 insertions(+), 33 deletions(-) diff --git a/src/midi/fluid_midi.c b/src/midi/fluid_midi.c index a49a2e68..262a82cb 100644 --- a/src/midi/fluid_midi.c +++ b/src/midi/fluid_midi.c @@ -99,13 +99,7 @@ int fluid_is_midifile(const char *filename) do { - if(!fluid_file_test(filename, G_FILE_TEST_IS_REGULAR)) - { - return retcode; - } - - // file seems to exist and is a regular file or a symlink to such - if((fp = FLUID_FOPEN(filename, "rb")) == NULL) + if((fp = fluid_file_open(filename, NULL)) == NULL) { return retcode; } diff --git a/src/sfloader/fluid_defsfont.c b/src/sfloader/fluid_defsfont.c index 8c6b67c9..6025d9f9 100644 --- a/src/sfloader/fluid_defsfont.c +++ b/src/sfloader/fluid_defsfont.c @@ -436,7 +436,7 @@ int fluid_defsfont_load(fluid_defsfont_t *defsfont, const fluid_file_callbacks_t if(sfdata == NULL) { - FLUID_LOG(FLUID_ERR, "Couldn't load soundfont file"); + /* error message already printed */ return FLUID_FAILED; } diff --git a/src/sfloader/fluid_sffile.c b/src/sfloader/fluid_sffile.c index b5a641b6..5fa34297 100644 --- a/src/sfloader/fluid_sffile.c +++ b/src/sfloader/fluid_sffile.c @@ -340,13 +340,7 @@ int fluid_is_soundfont(const char *filename) do { - if(!fluid_file_test(filename, G_FILE_TEST_IS_REGULAR)) - { - return retcode; - } - - // file seems to exist and is a regular file or a symlink to such - if((fp = FLUID_FOPEN(filename, "rb")) == NULL) + if((fp = fluid_file_open(filename, NULL)) == NULL) { return retcode; } diff --git a/src/sfloader/fluid_sfont.c b/src/sfloader/fluid_sfont.c index d0ce264d..04dd0017 100644 --- a/src/sfloader/fluid_sfont.c +++ b/src/sfloader/fluid_sfont.c @@ -24,26 +24,14 @@ void *default_fopen(const char *path) { - FILE* handle; + const char* msg; + FILE* handle = fluid_file_open(path, &msg); - if(!fluid_file_test(path, G_FILE_TEST_EXISTS)) + if(handle == NULL) { - FLUID_LOG(FLUID_ERR, "fluid_sfloader_load(): Unable to load non-existent file. ('%s')", path); - return NULL; + FLUID_LOG(FLUID_ERR, "fluid_sfloader_load(): Failed to open '%s': %s", path, msg); } - - if(!fluid_file_test(path, G_FILE_TEST_IS_REGULAR)) - { - FLUID_LOG(FLUID_ERR, "fluid_sfloader_load(): Refusing to load non-regular file! ('%s')", path); - return NULL; - } - - if((handle = FLUID_FOPEN(path, "rb")) == NULL) - { - FLUID_LOG(FLUID_ERR, "fluid_sfloader_load(): Specified file does not exists or insufficient permissions to open it! ('%s')", path); - return NULL; - } - + return handle; } diff --git a/src/utils/fluid_sys.c b/src/utils/fluid_sys.c index 6536b22f..3dd78307 100644 --- a/src/utils/fluid_sys.c +++ b/src/utils/fluid_sys.c @@ -1610,3 +1610,36 @@ void delete_fluid_server_socket(fluid_server_socket_t *server_socket) } #endif // NETWORK_SUPPORT + +FILE* fluid_file_open(const char* path, const char** errMsg) +{ + static const char ErrExist[] = "File does not exist."; + static const char ErrRegular[] = "File is not regular, refusing to open it."; + static const char ErrNull[] = "File does not exists or insufficient permissions to open it."; + + FILE* handle = NULL; + + if(!g_file_test(path, G_FILE_TEST_EXISTS)) + { + if(errMsg != NULL) + { + *errMsg = ErrExist; + } + } + else if(!g_file_test(path, G_FILE_TEST_IS_REGULAR)) + { + if(errMsg != NULL) + { + *errMsg = ErrRegular; + } + } + else if((handle = FLUID_FOPEN(path, "rb")) == NULL) + { + if(errMsg != NULL) + { + *errMsg = ErrNull; + } + } + + return handle; +} diff --git a/src/utils/fluid_sys.h b/src/utils/fluid_sys.h index 9d41c4cd..65c088ca 100644 --- a/src/utils/fluid_sys.h +++ b/src/utils/fluid_sys.h @@ -485,7 +485,7 @@ fluid_ostream_t fluid_socket_get_ostream(fluid_socket_t sock); typedef GStatBuf fluid_stat_buf_t; #endif -#define fluid_file_test g_file_test +FILE* fluid_file_open(const char* filename, const char** errMsg); /* Profiling */ #if WITH_PROFILING