From fa5173cbaefed60121db057bad7be7686165f7cc Mon Sep 17 00:00:00 2001 From: Tom M Date: Fri, 29 Dec 2023 13:06:53 +0100 Subject: [PATCH 01/33] Implement MSGS-style Drum Note Cut (#1199) Address #1196 --- src/synth/fluid_synth.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index e635983ac..84960619d 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -6846,15 +6846,30 @@ fluid_synth_release_voice_on_same_note_LOCAL(fluid_synth_t *synth, int chan, && (fluid_voice_get_key(voice) == key) && (fluid_voice_get_id(voice) != synth->noteid)) { + enum fluid_midi_channel_type type = synth->channel[chan]->channel_type; + /* Id of voices that was sustained by sostenuto */ if(fluid_voice_is_sostenuto(voice)) { synth->storeid = fluid_voice_get_id(voice); } - /* Force the voice into release stage except if pedaling - (sostenuto or sustain) is active */ - fluid_voice_noteoff(voice); + switch(type) + { + case CHANNEL_TYPE_DRUM: + /* release the voice, this should make riding hi-hats or snares sound more + * realistic (Discussion #1196) */ + fluid_voice_off(voice); + break; + case CHANNEL_TYPE_MELODIC: + /* Force the voice into release stage except if pedaling (sostenuto or sustain) is active. + * This gives a more realistic sound to pianos and possibly other instruments (see PR #905). */ + fluid_voice_noteoff(voice); + break; + default: + FLUID_LOG(FLUID_ERR, "This should never happen: unknown channel type %d", (int)type); + break; + } } } } From bd04f3f6c81a114f3ad52c8e29be3b44dccd010f Mon Sep 17 00:00:00 2001 From: Alberto Salvia Novella Date: Tue, 2 Jan 2024 14:38:13 +0100 Subject: [PATCH 02/33] Make settings more pleasing, natural and subtler (#1287) --- AUTHORS | 7 +++++-- doc/fluidsettings.xml | 17 +++++++++-------- src/synth/fluid_synth.c | 2 +- src/synth/fluid_synth.h | 24 ++++++++++++------------ 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/AUTHORS b/AUTHORS index 8854b4bde..a130be0b3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -40,8 +40,11 @@ summary of contributions. changes and bug fixes and got the synthesizer to actually work. Most importantly, he used it on stage to make music. -* S. Christian Collins did much testing of FluidSynth in regards to - EMU10K1 compatibility and provided many synthesis fixes in that regard. +* S. Christian Collins provided many tests and fixes on EMU10K1 + compatibility. He also supplied reference chorus and reverb settings for + developing the default ones. + +* Alberto Salvia Novella developed the default chorus and reverb settings. * Stephane Letz from Grame wrote most of the MidiShare driver, all of the PortAudio driver, ported iiwusynth to MacOS X, and sent in many diff --git a/doc/fluidsettings.xml b/doc/fluidsettings.xml index 69ddaf0c3..c805077e4 100644 --- a/doc/fluidsettings.xml +++ b/doc/fluidsettings.xml @@ -47,7 +47,7 @@ Developers: chorus.depth num - 8.0 + 4.25 (since version 2.4.0),
8.0 (2.3.x and older)
0.0 256.0 @@ -57,7 +57,8 @@ Developers: chorus.level num - 2.0 + 0.6 (since version 2.4.0),
2.0 (2.3.x and older)
+ 0.0 10.0 @@ -77,7 +78,7 @@ Developers: chorus.speed num - 0.3 + 0.2 (since version 2.4.0),
0.3 (2.3.x and older)
0.1 5.0 @@ -140,7 +141,7 @@ Developers: gain num - 0.2 + 0.6 (since version 2.4.0),
0.2 (2.3.x and older)
0.0 10.0 @@ -312,7 +313,7 @@ Developers: reverb.damp num - 0.0 + 0.3 (since version 2.4.0),
0.0 (2.3.x and older)
0.0 1.0 @@ -322,7 +323,7 @@ Developers: reverb.level num - 0.9 + 0.7 (since version 2.4.0),
0.9 (2.3.x and older)
0.0 1.0 @@ -332,7 +333,7 @@ Developers: reverb.room-size num - 0.2 + 0.5 (since version 2.4.0),
0.2 (2.3.x and older)
0.0 1.0 @@ -342,7 +343,7 @@ Developers: reverb.width num - 0.5 + 0.8 (since version 2.4.0),
0.5 (2.3.x and older)
0.0 100.0 diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 84960619d..807564303 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -223,7 +223,7 @@ void fluid_synth_settings(fluid_settings_t *settings) fluid_settings_register_int(settings, "synth.polyphony", 256, 1, 65535, 0); fluid_settings_register_int(settings, "synth.midi-channels", 16, 16, 256, 0); - fluid_settings_register_num(settings, "synth.gain", 0.2, 0.0, 10.0, 0); + fluid_settings_register_num(settings, "synth.gain", 0.6, 0.0, 10.0, 0); fluid_settings_register_int(settings, "synth.audio-channels", 1, 1, 128, 0); fluid_settings_register_int(settings, "synth.audio-groups", 1, 1, 128, 0); fluid_settings_register_int(settings, "synth.effects-channels", 2, 2, 2, 0); diff --git a/src/synth/fluid_synth.h b/src/synth/fluid_synth.h index cb838e924..7dbcdc556 100644 --- a/src/synth/fluid_synth.h +++ b/src/synth/fluid_synth.h @@ -41,21 +41,21 @@ * * DEFINES */ -#define FLUID_NUM_PROGRAMS 128 -#define DRUM_INST_BANK 128 +#define FLUID_NUM_PROGRAMS 128 +#define DRUM_INST_BANK 128 -#define FLUID_UNSET_PROGRAM 128 /* Program number used to unset a preset */ +#define FLUID_UNSET_PROGRAM 128 /* Program number used to unset a preset */ -#define FLUID_REVERB_DEFAULT_ROOMSIZE 0.2f /**< Default reverb room size */ -#define FLUID_REVERB_DEFAULT_DAMP 0.0f /**< Default reverb damping */ -#define FLUID_REVERB_DEFAULT_WIDTH 0.5f /**< Default reverb width */ -#define FLUID_REVERB_DEFAULT_LEVEL 0.9f /**< Default reverb level */ +#define FLUID_REVERB_DEFAULT_DAMP 0.3f /**< Default reverb damping */ +#define FLUID_REVERB_DEFAULT_LEVEL 0.7f /**< Default reverb level */ +#define FLUID_REVERB_DEFAULT_ROOMSIZE 0.5f /**< Default reverb room size */ +#define FLUID_REVERB_DEFAULT_WIDTH 0.8f /**< Default reverb width */ -#define FLUID_CHORUS_DEFAULT_N 3 /**< Default chorus voice count */ -#define FLUID_CHORUS_DEFAULT_LEVEL 2.0f /**< Default chorus level */ -#define FLUID_CHORUS_DEFAULT_SPEED 0.3f /**< Default chorus speed */ -#define FLUID_CHORUS_DEFAULT_DEPTH 8.0f /**< Default chorus depth */ -#define FLUID_CHORUS_DEFAULT_TYPE FLUID_CHORUS_MOD_SINE /**< Default chorus waveform type */ +#define FLUID_CHORUS_DEFAULT_DEPTH 4.25f /**< Default chorus depth */ +#define FLUID_CHORUS_DEFAULT_LEVEL 0.6f /**< Default chorus level */ +#define FLUID_CHORUS_DEFAULT_N 3 /**< Default chorus voice count */ +#define FLUID_CHORUS_DEFAULT_SPEED 0.2f /**< Default chorus speed */ +#define FLUID_CHORUS_DEFAULT_TYPE FLUID_CHORUS_MOD_SINE /**< Default chorus waveform type */ /*************************************************************** * From 652df6f7d823ad6d7595889012eb71eeeaf1f5f8 Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 25 Mar 2024 19:04:25 +0100 Subject: [PATCH 03/33] Fix signedness warning --- src/midi/fluid_midi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/midi/fluid_midi.c b/src/midi/fluid_midi.c index 10561d216..0c516238d 100644 --- a/src/midi/fluid_midi.c +++ b/src/midi/fluid_midi.c @@ -1644,7 +1644,7 @@ fluid_player_handle_reset_synth(void *data, const char *name, int value) static int check_for_on_notes(fluid_synth_t *synth) { fluid_voice_t* v[1024]; - int i, res=FALSE; + unsigned int i, res=FALSE; fluid_synth_get_voicelist(synth, v, FLUID_N_ELEMENTS(v), -1); for(i=0; i Date: Mon, 25 Mar 2024 19:06:32 +0100 Subject: [PATCH 04/33] Fix ISO C warning --- src/drivers/fluid_pipewire.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/drivers/fluid_pipewire.c b/src/drivers/fluid_pipewire.c index b96019e87..ee75fd8e3 100644 --- a/src/drivers/fluid_pipewire.c +++ b/src/drivers/fluid_pipewire.c @@ -154,6 +154,7 @@ new_fluid_pipewire_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t char *media_category = NULL; float *buffer = NULL; const struct spa_pod *params[1]; + struct pw_properties *props; drv = FLUID_NEW(fluid_pipewire_audio_driver_t); @@ -196,7 +197,7 @@ new_fluid_pipewire_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t goto driver_cleanup; } - struct pw_properties *props = pw_properties_new(PW_KEY_MEDIA_TYPE, media_type, PW_KEY_MEDIA_CATEGORY, media_category, PW_KEY_MEDIA_ROLE, media_role, NULL); + props = pw_properties_new(PW_KEY_MEDIA_TYPE, media_type, PW_KEY_MEDIA_CATEGORY, media_category, PW_KEY_MEDIA_ROLE, media_role, NULL); pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%d/%d", period_size, (int) sample_rate); pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%d", (int) sample_rate); From 0901883d07efc7900038407a1cc8ec58e852a72d Mon Sep 17 00:00:00 2001 From: Marcus Weseloh Date: Tue, 26 Mar 2024 14:55:55 +0100 Subject: [PATCH 05/33] Stop the pipewire loop before destroying the stream Should fix #1305 --- src/drivers/fluid_pipewire.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/drivers/fluid_pipewire.c b/src/drivers/fluid_pipewire.c index ee75fd8e3..0b46765b3 100644 --- a/src/drivers/fluid_pipewire.c +++ b/src/drivers/fluid_pipewire.c @@ -295,6 +295,11 @@ void delete_fluid_pipewire_audio_driver(fluid_audio_driver_t *p) fluid_pipewire_audio_driver_t *drv = (fluid_pipewire_audio_driver_t *)p; fluid_return_if_fail(drv); + if (drv->pw_loop) + { + pw_thread_loop_stop(drv->pw_loop); + } + if(drv->pw_stream) { pw_stream_destroy(drv->pw_stream); From 05880963e812d94687c2855c26dddd829626e2c0 Mon Sep 17 00:00:00 2001 From: Marcus Weseloh Date: Tue, 26 Mar 2024 15:07:33 +0100 Subject: [PATCH 06/33] Lock thread loop before destroying stream Better fix for #1305 --- src/drivers/fluid_pipewire.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/drivers/fluid_pipewire.c b/src/drivers/fluid_pipewire.c index 0b46765b3..70f47ac58 100644 --- a/src/drivers/fluid_pipewire.c +++ b/src/drivers/fluid_pipewire.c @@ -297,7 +297,7 @@ void delete_fluid_pipewire_audio_driver(fluid_audio_driver_t *p) if (drv->pw_loop) { - pw_thread_loop_stop(drv->pw_loop); + pw_thread_loop_lock(drv->pw_loop); } if(drv->pw_stream) @@ -307,6 +307,7 @@ void delete_fluid_pipewire_audio_driver(fluid_audio_driver_t *p) if(drv->pw_loop) { + pw_thread_loop_unlock(drv->pw_loop); pw_thread_loop_destroy(drv->pw_loop); } From 56932cdc1fc6f2eb922e3bc71f1057587c338f72 Mon Sep 17 00:00:00 2001 From: derselbst Date: Tue, 26 Mar 2024 18:19:50 +0100 Subject: [PATCH 07/33] Deprecate LASH support Closes #1285 --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea8bbda11..918cec18b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,7 @@ option ( enable-openmp "enable OpenMP support (parallelization of soundfont deco # Platform specific options if ( CMAKE_SYSTEM MATCHES "Linux|FreeBSD|DragonFly" ) - option ( enable-lash "compile LASH support (if it is available)" on ) + option ( enable-lash "compile LASH support (if it is available)" off ) option ( enable-alsa "compile ALSA support (if it is available)" on ) endif ( CMAKE_SYSTEM MATCHES "Linux|FreeBSD|DragonFly" ) @@ -600,6 +600,7 @@ unset ( LASH_SUPPORT CACHE ) if ( enable-lash ) find_package ( LASH ${LASH_MINIMUM_VERSION} ) if ( LASH_FOUND ) + message ( STATUS "Lash support has been deprecated and will be removed in fluidsynth 2.4.0" ) set ( LASH_SUPPORT 1 ) add_definitions ( -DHAVE_LASH ) list( APPEND PC_REQUIRES_PRIV "lash-1.0") From a3b88ccfa41e0cecaf95af44af73d39dc1f47df0 Mon Sep 17 00:00:00 2001 From: derselbst Date: Tue, 26 Mar 2024 18:23:16 +0100 Subject: [PATCH 08/33] Make it a WARNING --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 918cec18b..606bf8e57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -600,7 +600,7 @@ unset ( LASH_SUPPORT CACHE ) if ( enable-lash ) find_package ( LASH ${LASH_MINIMUM_VERSION} ) if ( LASH_FOUND ) - message ( STATUS "Lash support has been deprecated and will be removed in fluidsynth 2.4.0" ) + message ( WARNING "LASH support has been deprecated and will be removed in fluidsynth 2.4.0" ) set ( LASH_SUPPORT 1 ) add_definitions ( -DHAVE_LASH ) list( APPEND PC_REQUIRES_PRIV "lash-1.0") From 895f07de2d5e3f4f13d6ef3877e4ffdd1065f739 Mon Sep 17 00:00:00 2001 From: derselbst Date: Tue, 26 Mar 2024 18:27:45 +0100 Subject: [PATCH 09/33] Fix XG drum bank selection logic Fixes #1307 --- src/synth/fluid_chan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/synth/fluid_chan.c b/src/synth/fluid_chan.c index 0f2eecb44..84ca446b7 100644 --- a/src/synth/fluid_chan.c +++ b/src/synth/fluid_chan.c @@ -325,7 +325,7 @@ fluid_channel_set_bank_msb(fluid_channel_t *chan, int bankmsb) /* XG bank, do drum-channel auto-switch */ /* The number "120" was based on several keyboards having drums at 120 - 127, reference: https://lists.nongnu.org/archive/html/fluid-dev/2011-02/msg00003.html */ - chan->channel_type = (120 <= bankmsb) ? CHANNEL_TYPE_DRUM : CHANNEL_TYPE_MELODIC; + chan->channel_type = (120 == bankmsb || 126 == bankmsb || 127 == bankmsb) ? CHANNEL_TYPE_DRUM : CHANNEL_TYPE_MELODIC; return; } From 72cc6b3e8a0b1a4d1081849411e72e0d316828d8 Mon Sep 17 00:00:00 2001 From: derselbst Date: Tue, 26 Mar 2024 18:41:16 +0100 Subject: [PATCH 10/33] Remove LASH --- CMakeLists.txt | 13 --- FluidSynthConfig.cmake.in | 5 -- cmake_admin/FindLASH.cmake | 84 ------------------ cmake_admin/report.cmake | 6 -- contrib/fluidsynth.spec | 3 +- doc/fluidsynth.1 | 3 - src/CMakeLists.txt | 13 --- src/bindings/fluid_lash.c | 170 ------------------------------------- src/bindings/fluid_lash.h | 41 --------- src/config.cmake | 3 - src/drivers/fluid_alsa.c | 15 ---- src/drivers/fluid_jack.c | 15 ---- src/fluidsynth.c | 37 +------- 13 files changed, 2 insertions(+), 406 deletions(-) delete mode 100644 cmake_admin/FindLASH.cmake delete mode 100644 src/bindings/fluid_lash.c delete mode 100644 src/bindings/fluid_lash.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 606bf8e57..584f2e2ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,6 @@ option ( enable-openmp "enable OpenMP support (parallelization of soundfont deco # Platform specific options if ( CMAKE_SYSTEM MATCHES "Linux|FreeBSD|DragonFly" ) - option ( enable-lash "compile LASH support (if it is available)" off ) option ( enable-alsa "compile ALSA support (if it is available)" on ) endif ( CMAKE_SYSTEM MATCHES "Linux|FreeBSD|DragonFly" ) @@ -507,7 +506,6 @@ endif(ASTYLE) set ( ALSA_MINIMUM_VERSION 0.9.1 ) set ( DBUS_MINIMUM_VERSION 1.11.12 ) set ( GLIB2_MINUMUM_VERSION 2.6.5 ) -set ( LASH_MINIMUM_VERSION 0.3 ) set ( LIBINSTPATCH_MINIMUM_VERSION 1.1.0 ) set ( LIBSNDFILE_MINIMUM_VERSION 1.0.0 ) set ( PIPEWIRE_MINIMUM_VERSION 0.3 ) @@ -596,17 +594,6 @@ if ( enable-pipewire ) endif() endif ( enable-pipewire ) -unset ( LASH_SUPPORT CACHE ) -if ( enable-lash ) - find_package ( LASH ${LASH_MINIMUM_VERSION} ) - if ( LASH_FOUND ) - message ( WARNING "LASH support has been deprecated and will be removed in fluidsynth 2.4.0" ) - set ( LASH_SUPPORT 1 ) - add_definitions ( -DHAVE_LASH ) - list( APPEND PC_REQUIRES_PRIV "lash-1.0") - endif ( LASH_FOUND ) -endif ( enable-lash ) - unset ( SYSTEMD_SUPPORT CACHE ) if ( enable-systemd ) find_package ( Systemd ) diff --git a/FluidSynthConfig.cmake.in b/FluidSynthConfig.cmake.in index 498846f10..0d251d957 100644 --- a/FluidSynthConfig.cmake.in +++ b/FluidSynthConfig.cmake.in @@ -28,7 +28,6 @@ set(FLUIDSYNTH_SUPPORT_DBUS @DBUS_SUPPORT@) set(FLUIDSYNTH_SUPPORT_GETOPT @HAVE_GETOPT_H@) set(FLUIDSYNTH_SUPPORT_IPV6 @IPV6_SUPPORT@) set(FLUIDSYNTH_SUPPORT_LADSPA @LADSPA_SUPPORT@) -set(FLUIDSYNTH_SUPPORT_LASH @LASH_SUPPORT@) set(FLUIDSYNTH_SUPPORT_NETWORK @NETWORK_SUPPORT@) set(FLUIDSYNTH_SUPPORT_READLINE @READLINE_SUPPORT@) set(FLUIDSYNTH_SUPPORT_SYSTEMD @SYSTEMD_SUPPORT@) @@ -92,10 +91,6 @@ if(NOT FLUIDSYNTH_IS_SHARED) message(WARN "LADSPA support was built in but gmodule could not be found.") endif() - if(FLUIDSYNTH_SUPPORT_LASH AND NOT TARGET LASH::LASH) - find_dependency(LASH @LASH_MINIMUM_VERSION@) - endif() - if(FLUIDSYNTH_SUPPORT_LIBINSTPATCH AND NOT TARGET InstPatch::libinstpatch) find_dependency(InstPatch @LIBINSTPATCH_MINIMUM_VERSION@) endif() diff --git a/cmake_admin/FindLASH.cmake b/cmake_admin/FindLASH.cmake deleted file mode 100644 index 7cbcbaa3d..000000000 --- a/cmake_admin/FindLASH.cmake +++ /dev/null @@ -1,84 +0,0 @@ -#[=======================================================================[.rst: -FindLASH -------- - -Finds the LASH library. - -Imported Targets -^^^^^^^^^^^^^^^^ - -This module provides the following imported targets, if found: - -``LASH::LASH`` - The LASH library - -Result Variables -^^^^^^^^^^^^^^^^ - -This will define the following variables: - -``LASH_FOUND`` - True if the system has the LASH library. -``LASH_VERSION`` - The version of the LASH library which was found. - -#]=======================================================================] - -# Use pkg-config if available -find_package(PkgConfig QUIET) -pkg_check_modules(PC_LASH QUIET lash-1.0) - -# Find the headers and library -find_path( - LASH_INCLUDE_DIR - NAMES "lash/lash.h" - HINTS "${PC_LASH_INCLUDEDIR}" - PATH_SUFFIXES "lash-1.0") - -find_library( - LASH_LIBRARY - NAMES "lash" - HINTS "${PC_LASH_LIBDIR}") - -# Get version from pkg-config or read the config header -if(PC_LASH_VERSION) - set(LASH_VERSION "${PC_LASH_VERSION}") -else() - if(NOT LASH_FIND_VERSION) - set(_assumed_version "0.5.0") - else() - set(_assumed_version "${LASH_FIND_VERSION}") - endif() - message( - NOTICE - "LASH does not expose its version outside of pkg-config. Assuming version ${_assumed_version}, expect failure if your version is lower." - ) - set(LASH_VERSION ${_assumed_version}) -endif() - -# Handle transitive dependencies -if(PC_LASH_FOUND) - get_target_properties_from_pkg_config("${LASH_LIBRARY}" "PC_LASH" "_lash") -else() - set(_lash_link_libraries "Jack::Jack" "Threads::Threads" "ALSA::ALSA" "uuid") -endif() - -# Forward the result to CMake -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - LASH - REQUIRED_VARS "LASH_LIBRARY" "LASH_INCLUDE_DIR" - VERSION_VAR "LASH_VERSION") - -if(LASH_FOUND AND NOT TARGET LASH::LASH) - add_library(LASH::LASH UNKNOWN IMPORTED) - set_target_properties( - LASH::LASH - PROPERTIES IMPORTED_LOCATION "${LASH_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${_lash_compile_options}" - INTERFACE_INCLUDE_DIRECTORIES "${LASH_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${_lash_link_libraries}" - INTERFACE_LINK_DIRECTORIES "${_lash_link_directories}") -endif() - -mark_as_advanced(LASH_INCLUDE_DIR LASH_LIBRARY) diff --git a/cmake_admin/report.cmake b/cmake_admin/report.cmake index 882b8d6d6..85b375454 100644 --- a/cmake_admin/report.cmake +++ b/cmake_admin/report.cmake @@ -153,12 +153,6 @@ else ( LADSPA_SUPPORT ) set ( MISC_REPORT "${MISC_REPORT} LADSPA support: no\n" ) endif ( LADSPA_SUPPORT ) -if ( LASH_SUPPORT ) - set ( MISC_REPORT "${MISC_REPORT} LASH support: yes (NOTE: GPL library)\n" ) -else ( LASH_SUPPORT ) - set ( MISC_REPORT "${MISC_REPORT} LASH support: no\n" ) -endif ( LASH_SUPPORT ) - if ( NETWORK_SUPPORT ) set ( MISC_REPORT "${MISC_REPORT} NETWORK Support: yes\n" ) else ( NETWORK_SUPPORT ) diff --git a/contrib/fluidsynth.spec b/contrib/fluidsynth.spec index e5fb75e04..b34da6742 100644 --- a/contrib/fluidsynth.spec +++ b/contrib/fluidsynth.spec @@ -79,8 +79,7 @@ This package contains the shared library for Fluidsynth. %build %cmake \ - -DFLUID_DAEMON_ENV_FILE=%{_fillupdir}/sysconfig.%{name} \ - -Denable-lash=0 + -DFLUID_DAEMON_ENV_FILE=%{_fillupdir}/sysconfig.%{name} %cmake_build %check diff --git a/doc/fluidsynth.1 b/doc/fluidsynth.1 index 5140312d1..9debe59db 100644 --- a/doc/fluidsynth.1 +++ b/doc/fluidsynth.1 @@ -98,9 +98,6 @@ Attempt to connect the jack outputs to the physical ports .B \-K, \-\-midi\-channels=[num] The number of midi channels [default = 16] .TP -.B \-l, \-\-disable\-lash -Don't connect to LASH server -.TP .B \-L, \-\-audio\-channels=[num] The number of stereo audio channels [default = 1] .TP diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 808b8b8f8..771075adf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -77,10 +77,6 @@ if ( OSS_SUPPORT ) set ( fluid_oss_SOURCES drivers/fluid_oss.c ) endif ( OSS_SUPPORT ) -if ( LASH_SUPPORT ) - set ( fluid_lash_SOURCES bindings/fluid_lash.c bindings/fluid_lash.h ) -endif ( LASH_SUPPORT ) - if ( DART_SUPPORT ) set ( fluid_dart_SOURCES drivers/fluid_dart.c ) endif ( DART_SUPPORT ) @@ -237,7 +233,6 @@ add_library ( libfluidsynth-OBJ OBJECT ${fluid_dbus_SOURCES} ${fluid_jack_SOURCES} ${fluid_pipewire_SOURCES} - ${fluid_lash_SOURCES} ${fluid_midishare_SOURCES} ${fluid_opensles_SOURCES} ${fluid_oboe_SOURCES} @@ -390,10 +385,6 @@ if ( TARGET PipeWire::PipeWire AND PIPEWIRE_SUPPORT ) target_link_libraries ( libfluidsynth-OBJ PUBLIC PipeWire::PipeWire ) endif() -if ( TARGET LASH::LASH AND LASH_SUPPORT ) - target_link_libraries ( libfluidsynth-OBJ PUBLIC LASH::LASH ) -endif() - if ( TARGET dbus-1 AND DBUS_SUPPORT ) target_link_libraries ( libfluidsynth-OBJ PUBLIC dbus-1 ) endif() @@ -499,10 +490,6 @@ if ( TARGET PipeWire::PipeWire AND PIPEWIRE_SUPPORT ) # because pw_init() etc. target_link_libraries ( fluidsynth PRIVATE PipeWire::PipeWire ) endif() -if ( TARGET LASH::LASH AND LASH_SUPPORT ) - target_link_libraries ( fluidsynth PRIVATE LASH::LASH ) -endif() - if ( MACOSX_FRAMEWORK ) install ( TARGETS fluidsynth libfluidsynth EXPORT FluidSynthTargets diff --git a/src/bindings/fluid_lash.c b/src/bindings/fluid_lash.c deleted file mode 100644 index 652ccb268..000000000 --- a/src/bindings/fluid_lash.c +++ /dev/null @@ -1,170 +0,0 @@ -/* FluidSynth - A Software Synthesizer - * - * Copyright (C) 2003 Peter Hanappe and others. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA - */ -#include "fluid_lash.h" - -#ifdef HAVE_LASH - -static void fluid_lash_save(fluid_synth_t *synth); -static void fluid_lash_load(fluid_synth_t *synth, const char *filename); -static void *fluid_lash_run(void *data); - -/* - * lash client - this symbol needs to be in the library else - * all clients would need a fluid_lash_client symbol. - */ -lash_client_t *fluid_lash_client; - -static pthread_t fluid_lash_thread; - - -fluid_lash_args_t * -fluid_lash_extract_args(int *pargc, char ***pargv) -{ - return lash_extract_args(pargc, pargv); -} - -int -fluid_lash_connect(fluid_lash_args_t *args) -{ - fluid_lash_client = lash_init(args, PACKAGE, LASH_Config_Data_Set | LASH_Terminal, LASH_PROTOCOL(2, 0)); - return fluid_lash_client && lash_enabled(fluid_lash_client); -} - -void -fluid_lash_create_thread(fluid_synth_t *synth) -{ - pthread_create(&fluid_lash_thread, NULL, fluid_lash_run, synth); -} - -static void -fluid_lash_save(fluid_synth_t *synth) -{ - int i; - int sfcount; - fluid_sfont_t *sfont; - lash_config_t *config; - char num[32]; - - sfcount = fluid_synth_sfcount(synth); - - config = lash_config_new(); - lash_config_set_key(config, "soundfont count"); - lash_config_set_value_int(config, sfcount); - lash_send_config(fluid_lash_client, config); - - for(i = sfcount - 1; i >= 0; i--) - { - sfont = fluid_synth_get_sfont(synth, i); - config = lash_config_new(); - - sprintf(num, "%d", i); - - lash_config_set_key(config, num); - lash_config_set_value_string(config, sfont->get_name(sfont)); - - lash_send_config(fluid_lash_client, config); - } -} - -static void -fluid_lash_load(fluid_synth_t *synth, const char *filename) -{ - fluid_synth_sfload(synth, filename, 1); -} - -static void * -fluid_lash_run(void *data) -{ - lash_event_t *event; - lash_config_t *config; - fluid_synth_t *synth; - int done = 0; - int err; - int pending_restores = 0; - - synth = (fluid_synth_t *) data; - - while(!done) - { - while((event = lash_get_event(fluid_lash_client))) - { - switch(lash_event_get_type(event)) - { - case LASH_Save_Data_Set: - fluid_lash_save(synth); - lash_send_event(fluid_lash_client, event); - break; - - case LASH_Restore_Data_Set: - lash_event_destroy(event); - break; - - case LASH_Quit: - err = kill(getpid(), SIGQUIT); - - if(err) - { - fprintf(stderr, "%s: error sending signal: %s", __FUNCTION__, strerror(errno)); - } - - lash_event_destroy(event); - done = 1; - break; - - case LASH_Server_Lost: - lash_event_destroy(event); - done = 1; - break; - - default: - fprintf(stderr, "Received unknown LASH event of type %d\n", lash_event_get_type(event)); - lash_event_destroy(event); - break; - } - } - - while((config = lash_get_config(fluid_lash_client))) - { - if(FLUID_STRCMP(lash_config_get_key(config), "soundfont count") == 0) - { - pending_restores = lash_config_get_value_int(config); - } - else - { - fluid_lash_load(synth, lash_config_get_value_string(config)); - pending_restores--; - } - - lash_config_destroy(config); - - if(!pending_restores) - { - event = lash_event_new_with_type(LASH_Restore_Data_Set); - lash_send_event(fluid_lash_client, event); - } - } - - usleep(10000); - } - - return NULL; -} - -#endif /* #if HAVE_LASH #else */ diff --git a/src/bindings/fluid_lash.h b/src/bindings/fluid_lash.h deleted file mode 100644 index 787683906..000000000 --- a/src/bindings/fluid_lash.h +++ /dev/null @@ -1,41 +0,0 @@ -/* FluidSynth - A Software Synthesizer - * - * Copyright (C) 2003 Peter Hanappe and others. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA - */ -#ifndef _FLUID_LASH_H -#define _FLUID_LASH_H - -#include "config.h" - -#ifdef HAVE_LASH - -#include "fluid_synth.h" - -#include -extern lash_client_t *fluid_lash_client; -#define fluid_lash_args_t lash_args_t -#define fluid_lash_alsa_client_id lash_alsa_client_id -#define fluid_lash_jack_client_name lash_jack_client_name - - -FLUIDSYNTH_API fluid_lash_args_t *fluid_lash_extract_args(int *pargc, char ***pargv); -FLUIDSYNTH_API int fluid_lash_connect(fluid_lash_args_t *args); -FLUIDSYNTH_API void fluid_lash_create_thread(fluid_synth_t *synth); - -#endif /* defined(HAVE_LASH) */ -#endif /* _FLUID_LASH_H */ diff --git a/src/config.cmake b/src/config.cmake index 436add7f2..94324e815 100644 --- a/src/config.cmake +++ b/src/config.cmake @@ -43,9 +43,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_IO_H @HAVE_IO_H@ -/* whether or not we are supporting lash */ -#cmakedefine HAVE_LASH @HAVE_LASH@ - /* Define if systemd support is enabled */ #cmakedefine SYSTEMD_SUPPORT @SYSTEMD_SUPPORT@ diff --git a/src/drivers/fluid_alsa.c b/src/drivers/fluid_alsa.c index 98ae8f2c0..52d051fcd 100644 --- a/src/drivers/fluid_alsa.c +++ b/src/drivers/fluid_alsa.c @@ -37,8 +37,6 @@ #include #include -#include "fluid_lash.h" - #define FLUID_ALSA_DEFAULT_MIDI_DEVICE "default" #define FLUID_ALSA_DEFAULT_SEQ_DEVICE "default" @@ -1241,19 +1239,6 @@ new_fluid_alsa_seq_driver(fluid_settings_t *settings, fluid_alsa_seq_autoconnect(dev); } - /* tell the lash server our client id */ -#ifdef HAVE_LASH - { - int enable_lash = 0; - fluid_settings_getint(settings, "lash.enable", &enable_lash); - - if(enable_lash) - { - fluid_lash_alsa_client_id(fluid_lash_client, snd_seq_client_id(dev->seq_handle)); - } - } -#endif /* HAVE_LASH */ - fluid_atomic_int_set(&dev->should_quit, 0); /* create the MIDI thread */ diff --git a/src/drivers/fluid_jack.c b/src/drivers/fluid_jack.c index 2b0084804..6ee2a4f7d 100644 --- a/src/drivers/fluid_jack.c +++ b/src/drivers/fluid_jack.c @@ -38,8 +38,6 @@ #include #include -#include "fluid_lash.h" - typedef struct _fluid_jack_audio_driver_t fluid_jack_audio_driver_t; typedef struct _fluid_jack_midi_driver_t fluid_jack_midi_driver_t; @@ -265,19 +263,6 @@ new_fluid_jack_client(fluid_settings_t *settings, int isaudio, void *driver) goto error_recovery; } - /* tell the lash server our client name */ -#ifdef HAVE_LASH - { - int enable_lash = 0; - fluid_settings_getint(settings, "lash.enable", &enable_lash); - - if(enable_lash) - { - fluid_lash_jack_client_name(fluid_lash_client, name); - } - } -#endif /* HAVE_LASH */ - client_ref->server = server; /* !! takes over allocation */ server = NULL; /* Set to NULL so it doesn't get freed below */ diff --git a/src/fluidsynth.c b/src/fluidsynth.c index 81de1a8d8..11c917dfe 100644 --- a/src/fluidsynth.c +++ b/src/fluidsynth.c @@ -29,8 +29,6 @@ #define GETOPT_SUPPORT 1 #endif -#include "fluid_lash.h" - #ifdef SYSTEMD_SUPPORT #include #endif @@ -392,13 +390,6 @@ int main(int argc, char **argv) int dump = 0; int fast_render = 0; static const char optchars[] = "a:C:c:dE:f:F:G:g:hijK:L:lm:nO:o:p:QqR:r:sT:Vvz:"; -#ifdef HAVE_LASH - int connect_lash = 1; - int enabled_lash = 0; /* set to TRUE if lash gets enabled */ - fluid_lash_args_t *lash_args; - - lash_args = fluid_lash_extract_args(&argc, &argv); -#endif #if SDL2_SUPPORT // Tell SDL that it shouldn't intercept signals, otherwise SIGINT and SIGTERM won't quit fluidsynth @@ -653,9 +644,7 @@ int main(int argc, char **argv) break; case 'l': /* disable LASH */ -#ifdef HAVE_LASH - connect_lash = 0; -#endif + // lash support removed in 2.4.0, NOOP break; case 'm': @@ -853,17 +842,6 @@ int main(int argc, char **argv) SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); #endif -#ifdef HAVE_LASH - - /* connect to the lash server */ - if(connect_lash) - { - enabled_lash = fluid_lash_connect(lash_args); - fluid_settings_setint(settings, "lash.enable", enabled_lash ? 1 : 0); - } - -#endif - /* The 'groups' setting is relevant for LADSPA operation and channel mapping * in rvoice_mixer. * If not given, set number groups to number of audio channels, because @@ -1095,15 +1073,6 @@ int main(int argc, char **argv) #endif } -#endif - -#ifdef HAVE_LASH - - if(enabled_lash) - { - fluid_lash_create_thread(synth); - } - #endif /* fast rendering audio file, if requested */ @@ -1284,10 +1253,6 @@ print_help(fluid_settings_t *settings) " Attempt to connect the jack outputs to the physical ports\n"); printf(" -K, --midi-channels=[num]\n" " The number of midi channels [default = 16]\n"); -#ifdef HAVE_LASH - printf(" -l, --disable-lash\n" - " Don't connect to LASH server\n"); -#endif printf(" -L, --audio-channels=[num]\n" " The number of stereo audio channels [default = 1]\n"); printf(" -m, --midi-driver=[label]\n" From 619fc5c3380513146cd05e17decf8d747b02bba4 Mon Sep 17 00:00:00 2001 From: derselbst Date: Tue, 26 Mar 2024 18:52:36 +0100 Subject: [PATCH 11/33] Add FLUID_HOST_COMPILER cmake variable Fixes #1301 --- src/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 808b8b8f8..181b8ae5a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -548,12 +548,19 @@ set (GENTAB_BDIR ${CMAKE_CURRENT_BINARY_DIR}/gentables) # To fix cross-compiling fluidsynth from Win32 to ARM (using vcpkg), we need to pass the current generator # on to the external project, otherwise (for some unknown reason) the target compiler will be used rather # than the host compiler. +# +# Some use-cases however cannot rely on this logic, therefore, FLUID_HOST_COMPILER can be specified to +# force using a particular host compiler, see https://github.com/FluidSynth/fluidsynth/issues/1301 +if ( FLUID_HOST_COMPILER ) + set ( EXPLICIT_HOST_COMPILER_STR "-DCMAKE_C_COMPILER=${FLUID_HOST_COMPILER}" ) +endif () + ExternalProject_Add(gentables DOWNLOAD_COMMAND "" SOURCE_DIR ${GENTAB_SDIR} BINARY_DIR ${GENTAB_BDIR} CONFIGURE_COMMAND - "${CMAKE_COMMAND}" -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} -G "${CMAKE_GENERATOR}" -B "${GENTAB_BDIR}" "${GENTAB_SDIR}" + "${CMAKE_COMMAND}" -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} ${EXPLICIT_HOST_COMPILER_STR} -G "${CMAKE_GENERATOR}" -B "${GENTAB_BDIR}" "${GENTAB_SDIR}" BUILD_COMMAND "${CMAKE_COMMAND}" --build "${GENTAB_BDIR}" INSTALL_COMMAND ${GENTAB_BDIR}/make_tables.exe "${FluidSynth_BINARY_DIR}/" From db86c36bca6a14d661f23adf913abf52708dff73 Mon Sep 17 00:00:00 2001 From: Tom M Date: Tue, 26 Mar 2024 19:01:54 +0100 Subject: [PATCH 12/33] Remove vcpkg CI badge from README --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index aabba6a90..a5ec166a5 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ | **Linux** (Packaging) | [![build result](https://build.opensuse.org/projects/home:derselbst:anmp/packages/fluidsynth/badge.svg?type=default)](https://build.opensuse.org/package/show/home:derselbst:anmp/fluidsynth) | **Alpine** (musl) | [![Fluidsynth Alpine](https://dev.azure.com/tommbrt/tommbrt/_apis/build/status%2FFluidSynth.fluidsynth.alpine?branchName=master)](https://dev.azure.com/tommbrt/tommbrt/_build/latest?definitionId=12&branchName=alpine) | | **FreeBSD** | [![Build Status](https://api.cirrus-ci.com/github/FluidSynth/fluidsynth.svg?branch=master)](https://cirrus-ci.com/github/FluidSynth/fluidsynth) | -| **Windows** (CI) | [![Build Status](https://dev.azure.com/tommbrt/tommbrt/_apis/build/status/FluidSynth.fluidsynth.Win?branchName=master)](https://dev.azure.com/tommbrt/tommbrt/_build/latest?definitionId=3&branchName=master) | -| **Windows** (vcpkg) | [![Build Status](https://dev.azure.com/tommbrt/tommbrt/_apis/build/status/FluidSynth.fluidsynth.vcpkg?branchName=master)](https://dev.azure.com/tommbrt/tommbrt/_build/latest?definitionId=6&branchName=master) | +| **Windows** | [![Build Status](https://dev.azure.com/tommbrt/tommbrt/_apis/build/status/FluidSynth.fluidsynth.Win?branchName=master)](https://dev.azure.com/tommbrt/tommbrt/_build/latest?definitionId=3&branchName=master) | | **MacOSX** | [![Build Status](https://dev.azure.com/tommbrt/tommbrt/_apis/build/status/FluidSynth.fluidsynth.macOS?branchName=master)](https://dev.azure.com/tommbrt/tommbrt/_build/latest?definitionId=5&branchName=master) | | **Android** | [![Build Status](https://dev.azure.com/tommbrt/tommbrt/_apis/build/status/FluidSynth.fluidsynth.Android?branchName=master)](https://dev.azure.com/tommbrt/tommbrt/_build/latest?definitionId=4&branchName=master) | From e104532a0011793d1c7204d3035f2ac189c0ce78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez-Cabanillas?= Date: Sat, 20 Apr 2024 21:38:15 +0200 Subject: [PATCH 13/33] add a new windows workflow based on msys2 (#1316) --- .github/workflows/windows.yml | 75 +++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 000000000..c225a5e86 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,75 @@ +name: Fluidsynth Windows + +on: + pull_request: + push: + paths-ignore: + - '.azure/**' + - '.circleci/**' + - '.github/workflows/sonarcloud.yml' + - '.cirrus.yml' + - 'README.md' + +env: + BUILD_TYPE: RelWithDebInfo + INSTALL_LOCATION: fluidsynth_install + +jobs: + build: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + include: + - { icon: '⬛', sys: mingw32 } + - { icon: '🟦', sys: mingw64 } + - { icon: '🟨', sys: ucrt64 } + - { icon: '🟧', sys: clang64 } + name: 🚧${{ matrix.icon }} ${{ matrix.sys }} + defaults: + run: + shell: msys2 {0} + + steps: + - uses: actions/checkout@v4 + + - name: '${{ matrix.icon }} Setup MSYS2' + uses: msys2/setup-msys2@v2 + with: + release: false + msystem: ${{matrix.sys}} + install: >- + make + libreadline + pacboy: >- + toolchain:p + cmake:p + ninja:p + glib2:p + libsndfile:p + + - name: '${{ matrix.icon }} Configure CMake' + run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_INSTALL_PREFIX=${{env.INSTALL_LOCATION}} + + - name: '${{ matrix.icon }} Build' + run: cmake --build build --config ${{env.BUILD_TYPE}} + + #- name: '${{ matrix.icon }} Test' + # run: cmake --build build --target check + + - name: '${{ matrix.icon }} Demo' + run: cmake --build build --target demo + + - name: '${{ matrix.icon }} Install' + run: cmake --install build && ls -la $INSTALL_LOCATION + + - name: '${{ matrix.icon }} Create Archive' + run: tar cvf ${{env.INSTALL_LOCATION}}.tar ${{env.INSTALL_LOCATION}} + + - name: '${{ matrix.icon }} Upload Artifacts' + uses: actions/upload-artifact@v4 + with: + name: ${{env.INSTALL_LOCATION}}-${{matrix.sys}} + path: ${{env.INSTALL_LOCATION}}.tar + retention-days: 90 + overwrite: true From f78a9db2971c2ce1a1f29514c52325f390dce8c7 Mon Sep 17 00:00:00 2001 From: Tom M Date: Sat, 20 Apr 2024 21:59:58 +0200 Subject: [PATCH 14/33] Minor fixups for MSYS2 CI (#1317) --- .github/workflows/windows.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c225a5e86..84a051237 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -54,8 +54,8 @@ jobs: - name: '${{ matrix.icon }} Build' run: cmake --build build --config ${{env.BUILD_TYPE}} - #- name: '${{ matrix.icon }} Test' - # run: cmake --build build --target check + - name: '${{ matrix.icon }} Test' + run: cmake --build build --target check - name: '${{ matrix.icon }} Demo' run: cmake --build build --target demo @@ -63,13 +63,10 @@ jobs: - name: '${{ matrix.icon }} Install' run: cmake --install build && ls -la $INSTALL_LOCATION - - name: '${{ matrix.icon }} Create Archive' - run: tar cvf ${{env.INSTALL_LOCATION}}.tar ${{env.INSTALL_LOCATION}} - - name: '${{ matrix.icon }} Upload Artifacts' uses: actions/upload-artifact@v4 with: name: ${{env.INSTALL_LOCATION}}-${{matrix.sys}} - path: ${{env.INSTALL_LOCATION}}.tar - retention-days: 90 + path: ${{env.INSTALL_LOCATION}} + retention-days: 14 overwrite: true From abdd0985160673443f1170c04985c5c9f880e995 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 22 Apr 2024 00:30:21 +0200 Subject: [PATCH 15/33] Keep GitHub Actions up to date with GitHub's Dependabot Fixes the 16 software supply chain safety warnings at the bottom right of https://github.com/FluidSynth/fluidsynth/actions/runs/8767406884 * [Keeping your actions up to date with Dependabot](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot) * [Configuration options for the dependabot.yml file - package-ecosystem](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem) --- .github/dependabot.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..be006de9a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# Keep GitHub Actions up to date with GitHub's Dependabot... +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + groups: + github-actions: + patterns: + - "*" # Group all Actions updates into a single larger pull request + schedule: + interval: weekly From 7a4f8c7242e4f2a4cdc3114b1c7c7f26f2832e28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Apr 2024 16:52:49 +0000 Subject: [PATCH 16/33] Bump the github-actions group with 2 updates Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [github/codeql-action](https://github.com/github/codeql-action). Updates `actions/checkout` from 3 to 4 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) Updates `github/codeql-action` from 2 to 3 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions ... Signed-off-by: dependabot[bot] --- .github/workflows/api_doc_build.yml | 2 +- .github/workflows/codeql-analysis.yml | 8 ++++---- .github/workflows/linux.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/api_doc_build.yml b/.github/workflows/api_doc_build.yml index 40aabc6d9..5bafa38f3 100644 --- a/.github/workflows/api_doc_build.yml +++ b/.github/workflows/api_doc_build.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: persist-credentials: false diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4939b2b43..b7566752f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -39,11 +39,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -57,7 +57,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -71,4 +71,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index efd02e33f..0977c7a59 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -53,7 +53,7 @@ jobs: # clang11 is covered by openSUSE Leap 15.3 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Add apt-get repositories run: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index b2ae8868d..e73a02158 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -24,7 +24,7 @@ jobs: sonarcloud: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: # Disabling shallow clone is recommended for improving relevancy of reporting fetch-depth: 0 From 2bb9d83a734f5f742a5dcb82c3ea4aff1502ad07 Mon Sep 17 00:00:00 2001 From: Tom M Date: Tue, 23 Apr 2024 22:59:47 +0200 Subject: [PATCH 17/33] Fix an import library is treated as a static library on OS/2 (#1321) On OS/2, a suffix of an import library is '_dll.a', and a suffix of a static library is '.a'. Because of this, an import library is treated as a static library in get_target_properties_from_pkg_config(). Co-authored-by: KO Myung-Hun --- cmake_admin/PkgConfigHelpers.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake_admin/PkgConfigHelpers.cmake b/cmake_admin/PkgConfigHelpers.cmake index 8c98fe3f0..4a9f87f59 100644 --- a/cmake_admin/PkgConfigHelpers.cmake +++ b/cmake_admin/PkgConfigHelpers.cmake @@ -76,7 +76,8 @@ macro ( unset_pkg_config _prefix ) endmacro ( unset_pkg_config ) function ( get_target_properties_from_pkg_config _library _prefix _out_prefix ) - if ( "${_library}" MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$" ) + if ( NOT "${_library}" MATCHES "${CMAKE_IMPORT_LIBRARY_SUFFIX}$" + AND "${_library}" MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$" ) set ( _cflags ${_prefix}_STATIC_CFLAGS_OTHER ) set ( _link_libraries ${_prefix}_STATIC_LIBRARIES ) set ( _library_dirs ${_prefix}_STATIC_LIBRARY_DIRS ) From cbda2ca58b42c0a8274a20fb77719940f71d0a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez-Cabanillas?= Date: Mon, 29 Apr 2024 13:02:01 +0200 Subject: [PATCH 18/33] Fixed wasapi driver; encode device names as CP_UTF8 Solves #1322 --- src/drivers/fluid_wasapi.c | 8 ++++---- src/fluidsynth.c | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/drivers/fluid_wasapi.c b/src/drivers/fluid_wasapi.c index f94077f9d..e0591b1f5 100644 --- a/src/drivers/fluid_wasapi.c +++ b/src/drivers/fluid_wasapi.c @@ -788,9 +788,9 @@ static void fluid_wasapi_register_callback(IMMDevice *dev, void *data) int nsz; char *name; - nsz = WideCharToMultiByte(CP_ACP, 0, var.pwszVal, -1, 0, 0, 0, 0); + nsz = WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, 0, 0, 0, 0); name = FLUID_ARRAY(char, nsz + 1); - WideCharToMultiByte(CP_ACP, 0, var.pwszVal, -1, name, nsz, 0, 0); + WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, name, nsz, 0, 0); fluid_settings_add_option(settings, "audio.wasapi.device", name); FLUID_FREE(name); } @@ -828,9 +828,9 @@ static void fluid_wasapi_finddev_callback(IMMDevice *dev, void *data) goto cleanup; } - nsz = WideCharToMultiByte(CP_ACP, 0, var.pwszVal, -1, 0, 0, 0, 0); + nsz = WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, 0, 0, 0, 0); name = FLUID_ARRAY(char, nsz + 1); - WideCharToMultiByte(CP_ACP, 0, var.pwszVal, -1, name, nsz, 0, 0); + WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, name, nsz, 0, 0); if(!FLUID_STRCASECMP(name, d->name)) { diff --git a/src/fluidsynth.c b/src/fluidsynth.c index 81de1a8d8..9976451b8 100644 --- a/src/fluidsynth.c +++ b/src/fluidsynth.c @@ -400,6 +400,10 @@ int main(int argc, char **argv) lash_args = fluid_lash_extract_args(&argc, &argv); #endif +#ifdef _WIN32 + SetConsoleOutputCP(CP_UTF8); +#endif + #if SDL2_SUPPORT // Tell SDL that it shouldn't intercept signals, otherwise SIGINT and SIGTERM won't quit fluidsynth SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1"); From 30ea487a6ea1772dca4ee3fc549c7f052ee04a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez-Cabanillas?= Date: Wed, 1 May 2024 20:28:02 +0200 Subject: [PATCH 19/33] drivers: winmidi,waveout and dsound using utf8 options Unicode support enabled in CMake script and CLI utility --- CMakeLists.txt | 1 + src/drivers/fluid_dsound.c | 31 +++++++++++++++++++++++++------ src/drivers/fluid_waveout.c | 16 ++++++++-------- src/drivers/fluid_winmidi.c | 20 ++++++++++++-------- src/fluidsynth.c | 5 ++++- 5 files changed, 50 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 606bf8e57..0bbba73de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -296,6 +296,7 @@ if ( WIN32 OR CYGWIN ) endif() endif () message ( STATUS "Targeting Windows Version ${windows-version}" ) + add_definitions ( -D _UNICODE -D UNICODE ) add_definitions ( -D _WIN32_WINNT=${windows-version} ) add_definitions ( -D WINVER=${windows-version} ) list ( APPEND CMAKE_REQUIRED_DEFINITIONS "-DWINVER=${windows-version}" ) diff --git a/src/drivers/fluid_dsound.c b/src/drivers/fluid_dsound.c index 16fc83277..340de4143 100644 --- a/src/drivers/fluid_dsound.c +++ b/src/drivers/fluid_dsound.c @@ -107,8 +107,18 @@ typedef struct BOOL CALLBACK fluid_dsound_enum_callback(LPGUID guid, LPCTSTR description, LPCTSTR module, LPVOID context) { - fluid_settings_t *settings = (fluid_settings_t *) context; - fluid_settings_add_option(settings, "audio.dsound.device", (const char *)description); + fluid_settings_t *settings = (fluid_settings_t *)context; + char *name; +#if _UNICODE + int nsz = WideCharToMultiByte(CP_UTF8, 0, description, -1, 0, 0, 0, 0); + name = FLUID_ARRAY(char, nsz + 1); + WideCharToMultiByte(CP_UTF8, 0, description, -1, name, nsz, 0, 0); +#else + name = FLUID_STRDUP(description); +#endif + FLUID_LOG(FLUID_DBG, "adding audio.dsound.device=%s", name); + fluid_settings_add_option(settings, "audio.dsound.device", name); + FLUID_FREE(name); return TRUE; } @@ -121,10 +131,18 @@ fluid_dsound_enum_callback(LPGUID guid, LPCTSTR description, LPCTSTR module, LPV BOOL CALLBACK fluid_dsound_enum_callback2(LPGUID guid, LPCTSTR description, LPCTSTR module, LPVOID context) { - fluid_dsound_devsel_t *devsel = (fluid_dsound_devsel_t *) context; - FLUID_LOG(FLUID_DBG, "Testing audio device: %s", description); - - if(FLUID_STRCASECMP(devsel->devname, description) == 0) + fluid_dsound_devsel_t *devsel = (fluid_dsound_devsel_t *)context; + char *name; +#if _UNICODE + int nsz = WideCharToMultiByte(CP_UTF8, 0, description, -1, 0, 0, 0, 0); + name = FLUID_ARRAY(char, nsz + 1); + WideCharToMultiByte(CP_UTF8, 0, description, -1, name, nsz, 0, 0); +#else + name = FLUID_STRDUP(description); +#endif + FLUID_LOG(FLUID_DBG, "Testing audio device: %s", name); + + if (FLUID_STRCASECMP(devsel->devname, name) == 0) { /* The device exists, return a copy of its GUID */ devsel->devGUID = FLUID_NEW(GUID); @@ -137,6 +155,7 @@ fluid_dsound_enum_callback2(LPGUID guid, LPCTSTR description, LPCTSTR module, LP return FALSE; } } + FLUID_FREE(name); return TRUE; } diff --git a/src/drivers/fluid_waveout.c b/src/drivers/fluid_waveout.c index b67ead761..c2e6b1dc3 100644 --- a/src/drivers/fluid_waveout.c +++ b/src/drivers/fluid_waveout.c @@ -201,9 +201,7 @@ static DWORD WINAPI fluid_waveout_synth_thread(void *data) void fluid_waveout_audio_driver_settings(fluid_settings_t *settings) { UINT n, nDevs = waveOutGetNumDevs(); -#ifdef _UNICODE - char dev_name[MAXPNAMELEN]; -#endif + char *dev_name; fluid_settings_register_str(settings, "audio.waveout.device", "default", 0); fluid_settings_add_option(settings, "audio.waveout.device", "default"); @@ -218,13 +216,15 @@ void fluid_waveout_audio_driver_settings(fluid_settings_t *settings) if(res == MMSYSERR_NOERROR) { #ifdef _UNICODE - WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, dev_name, MAXPNAMELEN, 0, 0); - FLUID_LOG(FLUID_DBG, "Testing audio device: %s", dev_name); - fluid_settings_add_option(settings, "audio.waveout.device", dev_name); + int nsz = WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, 0, 0, 0, 0); + dev_name = FLUID_ARRAY(char, nsz + 1); + WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, dev_name, nsz, 0, 0); #else - FLUID_LOG(FLUID_DBG, "Testing audio device: %s", caps.szPname); - fluid_settings_add_option(settings, "audio.waveout.device", caps.szPname); + dev_name = FLUID_STRDUP(caps.szPname); #endif + FLUID_LOG(FLUID_DBG, "Testing audio device: %s", dev_name); + fluid_settings_add_option(settings, "audio.waveout.device", dev_name); + FLUID_FREE(dev_name); } } } diff --git a/src/drivers/fluid_winmidi.c b/src/drivers/fluid_winmidi.c index b42edddc1..1e39d56cf 100644 --- a/src/drivers/fluid_winmidi.c +++ b/src/drivers/fluid_winmidi.c @@ -229,14 +229,24 @@ fluid_winmidi_callback(HMIDIIN hmi, UINT wMsg, DWORD_PTR dwInstance, * @param dev_name, name of the device. * @return the new device name (that must be freed when finish with it) or * NULL if memory allocation error. + * Note: the returned name will be encoded in UTF8 if built with _UNICODE. */ -static char *fluid_winmidi_get_device_name(int dev_idx, char *dev_name) +static char *fluid_winmidi_get_device_name(int dev_idx, TCHAR *input_dev_name) { char *new_dev_name; + char *dev_name; int i = dev_idx; size_t size = 0; /* index size */ +#if _UNICODE + int nsz = WideCharToMultiByte(CP_UTF8, 0, input_dev_name, -1, 0, 0, 0, 0); + dev_name = FLUID_ARRAY(char, nsz + 1); + WideCharToMultiByte(CP_UTF8, 0, input_dev_name, -1, dev_name, nsz, 0, 0); +#else + dev_name = FLUID_STRDUP(input_dev_name); +#endif + do { size++; @@ -256,6 +266,7 @@ static char *fluid_winmidi_get_device_name(int dev_idx, char *dev_name) { FLUID_LOG(FLUID_ERR, "Out of memory"); } + FLUID_FREE(dev_name); return new_dev_name; } @@ -429,14 +440,7 @@ fluid_winmidi_parse_device_name(fluid_winmidi_driver_t *dev, char *dev_name) break; } -#ifdef _UNICODE - WCHAR wDevName[MAXPNAMELEN]; - MultiByteToWideChar(CP_UTF8, 0, dev_name, -1, wDevName, MAXPNAMELEN); - - str_cmp_res = wcsicmp(wDevName, new_dev_name); -#else str_cmp_res = FLUID_STRCASECMP(dev_name, new_dev_name); -#endif FLUID_LOG(FLUID_DBG, "Testing midi device \"%s\"", new_dev_name); FLUID_FREE(new_dev_name); diff --git a/src/fluidsynth.c b/src/fluidsynth.c index 9976451b8..94ee13da8 100644 --- a/src/fluidsynth.c +++ b/src/fluidsynth.c @@ -401,7 +401,10 @@ int main(int argc, char **argv) #endif #ifdef _WIN32 - SetConsoleOutputCP(CP_UTF8); + // console output will be utf-8 + SetConsoleOutputCP(CP_UTF8); + // console input, too + SetConsoleCP(CP_UTF8); #endif #if SDL2_SUPPORT From 699c288f45028fc61de203f3777145193cff2978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez-Cabanillas?= Date: Wed, 1 May 2024 22:49:51 +0200 Subject: [PATCH 20/33] Documentation updated (settings, about utf-8 encoding) C++ example updated --- doc/examples/fluidsynth_enumsettings.cxx | 9 +++++++++ include/fluidsynth/settings.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/doc/examples/fluidsynth_enumsettings.cxx b/doc/examples/fluidsynth_enumsettings.cxx index 8973b9de2..40599c94b 100644 --- a/doc/examples/fluidsynth_enumsettings.cxx +++ b/doc/examples/fluidsynth_enumsettings.cxx @@ -12,6 +12,10 @@ * [Pedro López-Cabanillas ] */ +#ifdef _WIN32 +#include +#endif + #include #include #include @@ -23,6 +27,11 @@ int main(int argc, char**) fluid_settings_t* settings = nullptr; void* context = nullptr; +#ifdef _WIN32 + SetConsoleOutputCP(CP_UTF8); + setvbuf(stdout, nullptr, _IONBF, 0); +#endif + std::cout << "C++ enum settings of FluidSynth v" << fluid_version_str() << std::endl; if (argc > 1) { diff --git a/include/fluidsynth/settings.h b/include/fluidsynth/settings.h index 78db7dc32..45ab07a65 100644 --- a/include/fluidsynth/settings.h +++ b/include/fluidsynth/settings.h @@ -48,6 +48,9 @@ extern "C" { * // ... * } * @endcode + * All string settings are encoded in UTF-8. This includes the names + * of the audio and MIDI devices, exposed as setting options. + * * @sa @ref CreatingSettings * * @{ From 32613c7d6a8ed5e3b9dd205440c922c6c5f571eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez-Cabanillas?= Date: Sun, 5 May 2024 20:49:57 +0200 Subject: [PATCH 21/33] review findings --- doc/fluidsettings.xml | 8 ++++---- src/drivers/fluid_dsound.c | 6 +++--- src/drivers/fluid_wasapi.c | 4 ++-- src/drivers/fluid_waveout.c | 2 +- src/drivers/fluid_winmidi.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/fluidsettings.xml b/doc/fluidsettings.xml index 69ddaf0c3..c26ed39fa 100644 --- a/doc/fluidsettings.xml +++ b/doc/fluidsettings.xml @@ -491,7 +491,7 @@ Developers: str default - Selects the DirectSound (Windows) device to use. + Selects the DirectSound (Windows) device to use. Starting with 2.3.6 all device names are expected to be UTF8 encoded.
@@ -704,7 +704,7 @@ Developers: str default - Device to use for WASAPI driver output. + Device to use for WASAPI driver output. Starting with 2.3.6 all device names are expected to be UTF8 encoded. @@ -720,7 +720,7 @@ Developers: str default - Device to use for WaveOut driver output. + Device to use for WaveOut driver output. Starting with 2.3.6 all device names are expected to be UTF8 encoded. @@ -803,7 +803,7 @@ Developers: winmidi.device str default - The hardware device to use for Windows MIDI driver (not to be confused with the MIDI port). Multiple devices can be specified by a list of devices index separated by a semicolon (e.g "2;0", which is equivalent to one device with 32 MIDI channels). + The hardware device to use for Windows MIDI driver (not to be confused with the MIDI port). Multiple devices can be specified by a list of devices index separated by a semicolon (e.g "2;0", which is equivalent to one device with 32 MIDI channels). Starting with 2.3.6 all device names are expected to be UTF8 encoded.
diff --git a/src/drivers/fluid_dsound.c b/src/drivers/fluid_dsound.c index 340de4143..a99038b55 100644 --- a/src/drivers/fluid_dsound.c +++ b/src/drivers/fluid_dsound.c @@ -111,7 +111,7 @@ fluid_dsound_enum_callback(LPGUID guid, LPCTSTR description, LPCTSTR module, LPV char *name; #if _UNICODE int nsz = WideCharToMultiByte(CP_UTF8, 0, description, -1, 0, 0, 0, 0); - name = FLUID_ARRAY(char, nsz + 1); + name = FLUID_ARRAY(char, nsz); WideCharToMultiByte(CP_UTF8, 0, description, -1, name, nsz, 0, 0); #else name = FLUID_STRDUP(description); @@ -135,7 +135,7 @@ fluid_dsound_enum_callback2(LPGUID guid, LPCTSTR description, LPCTSTR module, LP char *name; #if _UNICODE int nsz = WideCharToMultiByte(CP_UTF8, 0, description, -1, 0, 0, 0, 0); - name = FLUID_ARRAY(char, nsz + 1); + name = FLUID_ARRAY(char, nsz); WideCharToMultiByte(CP_UTF8, 0, description, -1, name, nsz, 0, 0); #else name = FLUID_STRDUP(description); @@ -144,6 +144,7 @@ fluid_dsound_enum_callback2(LPGUID guid, LPCTSTR description, LPCTSTR module, LP if (FLUID_STRCASECMP(devsel->devname, name) == 0) { + FLUID_FREE(name); /* The device exists, return a copy of its GUID */ devsel->devGUID = FLUID_NEW(GUID); @@ -155,7 +156,6 @@ fluid_dsound_enum_callback2(LPGUID guid, LPCTSTR description, LPCTSTR module, LP return FALSE; } } - FLUID_FREE(name); return TRUE; } diff --git a/src/drivers/fluid_wasapi.c b/src/drivers/fluid_wasapi.c index e0591b1f5..1a933fbe0 100644 --- a/src/drivers/fluid_wasapi.c +++ b/src/drivers/fluid_wasapi.c @@ -789,7 +789,7 @@ static void fluid_wasapi_register_callback(IMMDevice *dev, void *data) char *name; nsz = WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, 0, 0, 0, 0); - name = FLUID_ARRAY(char, nsz + 1); + name = FLUID_ARRAY(char, nsz); WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, name, nsz, 0, 0); fluid_settings_add_option(settings, "audio.wasapi.device", name); FLUID_FREE(name); @@ -829,7 +829,7 @@ static void fluid_wasapi_finddev_callback(IMMDevice *dev, void *data) } nsz = WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, 0, 0, 0, 0); - name = FLUID_ARRAY(char, nsz + 1); + name = FLUID_ARRAY(char, nsz); WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, name, nsz, 0, 0); if(!FLUID_STRCASECMP(name, d->name)) diff --git a/src/drivers/fluid_waveout.c b/src/drivers/fluid_waveout.c index c2e6b1dc3..039295f4f 100644 --- a/src/drivers/fluid_waveout.c +++ b/src/drivers/fluid_waveout.c @@ -217,7 +217,7 @@ void fluid_waveout_audio_driver_settings(fluid_settings_t *settings) { #ifdef _UNICODE int nsz = WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, 0, 0, 0, 0); - dev_name = FLUID_ARRAY(char, nsz + 1); + dev_name = FLUID_ARRAY(char, nsz); WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, dev_name, nsz, 0, 0); #else dev_name = FLUID_STRDUP(caps.szPname); diff --git a/src/drivers/fluid_winmidi.c b/src/drivers/fluid_winmidi.c index 1e39d56cf..1157d7f10 100644 --- a/src/drivers/fluid_winmidi.c +++ b/src/drivers/fluid_winmidi.c @@ -241,7 +241,7 @@ static char *fluid_winmidi_get_device_name(int dev_idx, TCHAR *input_dev_name) #if _UNICODE int nsz = WideCharToMultiByte(CP_UTF8, 0, input_dev_name, -1, 0, 0, 0, 0); - dev_name = FLUID_ARRAY(char, nsz + 1); + dev_name = FLUID_ARRAY(char, nsz); WideCharToMultiByte(CP_UTF8, 0, input_dev_name, -1, dev_name, nsz, 0, 0); #else dev_name = FLUID_STRDUP(input_dev_name); From 2abb296f8a81d72d88be2329886f2cb7d0425483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez-Cabanillas?= Date: Sat, 11 May 2024 17:54:10 +0200 Subject: [PATCH 22/33] when processing command line options: -o setting=value, the value is converted to UTF8 --- src/fluidsynth.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/fluidsynth.c b/src/fluidsynth.c index 94ee13da8..ba30df09a 100644 --- a/src/fluidsynth.c +++ b/src/fluidsynth.c @@ -48,6 +48,9 @@ void print_help(fluid_settings_t *settings); void print_welcome(void); void print_configure(void); void fluid_wasapi_device_enumerate(void); +#ifdef _WIN32 +static char* win32_ansi_to_utf8(const char* ansi_null_terminated_string); +#endif /* * the globals @@ -122,16 +125,25 @@ int process_o_cmd_line_option(fluid_settings_t *settings, char *optarg) } break; - - case FLUID_STR_TYPE: - if(fluid_settings_setstr(settings, optarg, val) != FLUID_OK) + + case FLUID_STR_TYPE: { + char *u8_val = val; +#if defined(_WIN32) + u8_val = win32_ansi_to_utf8(val); +#endif + if(fluid_settings_setstr(settings, optarg, u8_val) != FLUID_OK) { fprintf(stderr, "Failed to set string parameter '%s'\n", optarg); +#if defined(_WIN32) + free(u8_val); +#endif return FLUID_FAILED; } - +#if defined(_WIN32) + free(u8_val); +#endif break; - + } default: fprintf(stderr, "Setting parameter '%s' not found\n", optarg); return FLUID_FAILED; From 4e51141e9d5e27c7081238d190b5d2d05227945a Mon Sep 17 00:00:00 2001 From: derselbst Date: Wed, 22 May 2024 14:27:44 +0200 Subject: [PATCH 23/33] Access to synth->bank_select not guarded by mutex --- src/synth/fluid_synth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index e635983ac..e6bac898b 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -2050,8 +2050,8 @@ fluid_synth_sysex(fluid_synth_t *synth, const char *data, int len, || data[3] == MIDI_SYSEX_GM2_ON)) { int result; - synth->bank_select = FLUID_BANK_STYLE_GM; fluid_synth_api_enter(synth); + synth->bank_select = FLUID_BANK_STYLE_GM; result = fluid_synth_system_reset_LOCAL(synth); FLUID_API_RETURN(result); } From 79ef993b6fb26dedaa69f1420e9d50fb93ccc9c9 Mon Sep 17 00:00:00 2001 From: derselbst Date: Wed, 22 May 2024 14:46:00 +0200 Subject: [PATCH 24/33] Update documentation of synth.device-id --- doc/fluidsettings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/fluidsettings.xml b/doc/fluidsettings.xml index c26ed39fa..71af6432f 100644 --- a/doc/fluidsettings.xml +++ b/doc/fluidsettings.xml @@ -111,7 +111,7 @@ Developers: 127 - Device identifier used for SYSEX commands, such as MIDI Tuning Standard commands. Fluidsynth will only process those SYSEX commands destined for this ID (except when this setting is set to 127, which causes fluidsynth to process all SYSEX commands, regardless of the device ID). Broadcast commands (with ID=127) will always be processed. + Device identifier used for SYSEX commands, such as MIDI Tuning Standard commands. Fluidsynth will only process those SYSEX commands destined for this ID (except when this setting is set to 127, which causes fluidsynth to process all SYSEX commands, regardless of the device ID). Broadcast commands (with ID=127) will always be processed. It has been observed that setting this ID to 16 provides best compatibility when playing MIDI files which contain SYSEX commands that you want to have honored.
dynamic-sample-loading From c189075979390d037a134f7eedd1cafb4ef629b7 Mon Sep 17 00:00:00 2001 From: derselbst Date: Sun, 9 Jun 2024 11:39:05 +0200 Subject: [PATCH 25/33] Log NRPNs in verbose mode --- src/synth/fluid_synth.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index e6bac898b..fb868a67d 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -1827,6 +1827,10 @@ fluid_synth_cc_LOCAL(fluid_synth_t *synth, int channum, int num) if(nrpn_select < GEN_LAST) { + if(synth->verbose) + { + FLUID_LOG(FLUID_INFO, "NRPN\t%d\t%d\t%d", channum, nrpn_select, data); + } float val = fluid_gen_scale_nrpn(nrpn_select, data); fluid_synth_set_gen_LOCAL(synth, channum, nrpn_select, val); } From d4aa2f37b9509f16409abee2c54b44c4e71589d1 Mon Sep 17 00:00:00 2001 From: derselbst Date: Fri, 21 Jun 2024 09:34:05 +0200 Subject: [PATCH 26/33] Fix mixed declaration --- src/synth/fluid_synth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index fb868a67d..ccd7836b4 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -1827,11 +1827,11 @@ fluid_synth_cc_LOCAL(fluid_synth_t *synth, int channum, int num) if(nrpn_select < GEN_LAST) { + float val = fluid_gen_scale_nrpn(nrpn_select, data); if(synth->verbose) { - FLUID_LOG(FLUID_INFO, "NRPN\t%d\t%d\t%d", channum, nrpn_select, data); + FLUID_LOG(FLUID_INFO, "NRPN\t%d\t%d\t%d\t%f", channum, nrpn_select, data, val); } - float val = fluid_gen_scale_nrpn(nrpn_select, data); fluid_synth_set_gen_LOCAL(synth, channum, nrpn_select, val); } From 7d464de801ec232f3002bbf71c2712fba259b095 Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 24 Jun 2024 11:11:31 +0200 Subject: [PATCH 27/33] Fix linkage against gobject --- cmake_admin/FindGLib2.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake_admin/FindGLib2.cmake b/cmake_admin/FindGLib2.cmake index f6fa6f183..90379e4a6 100644 --- a/cmake_admin/FindGLib2.cmake +++ b/cmake_admin/FindGLib2.cmake @@ -35,7 +35,7 @@ find_package(PkgConfig QUIET) pkg_check_modules(PC_GLIB2 QUIET glib-2.0) pkg_check_modules(PC_GTHREAD2 QUIET gthread-2.0) pkg_check_modules(PC_GMODULE2 QUIET gmodule-2.0) -pkg_check_modules(PC_GMODULE2 QUIET gobject-2.0) +pkg_check_modules(PC_GOBJECT2 QUIET gobject-2.0) # Find the headers and libraries find_path( @@ -209,7 +209,7 @@ if(GLib2_gobject-2_LIBRARY AND NOT TARGET GLib2::gobject-2) # Handle transitive dependencies if(PC_GOBJECT2_FOUND) get_target_properties_from_pkg_config("${GLib2_gobject-2_LIBRARY}" - "PC_OBJECT2" "_gobject2") + "PC_GOBJECT2" "_gobject2") else() find_package(libffi QUIET) set(_gobject2_link_libraries "libffi" "GLib2::glib-2") From 80cef3fc928fb4074ea1be2b6cc96631b7461d3a Mon Sep 17 00:00:00 2001 From: derselbst Date: Tue, 25 Jun 2024 23:54:07 +0200 Subject: [PATCH 28/33] Fix a few compiler warnings --- src/sfloader/fluid_defsfont.c | 2 +- src/sfloader/fluid_sfont.c | 4 ++-- src/synth/fluid_event.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sfloader/fluid_defsfont.c b/src/sfloader/fluid_defsfont.c index 129867d0f..84eaefce2 100644 --- a/src/sfloader/fluid_defsfont.c +++ b/src/sfloader/fluid_defsfont.c @@ -1746,7 +1746,7 @@ fluid_preset_zone_get_inst(fluid_preset_zone_t *zone) * new_fluid_inst */ fluid_inst_t * -new_fluid_inst() +new_fluid_inst(void) { fluid_inst_t *inst = FLUID_NEW(fluid_inst_t); diff --git a/src/sfloader/fluid_sfont.c b/src/sfloader/fluid_sfont.c index 00423c003..cad6f18da 100644 --- a/src/sfloader/fluid_sfont.c +++ b/src/sfloader/fluid_sfont.c @@ -497,7 +497,7 @@ void delete_fluid_preset(fluid_preset_t *preset) * @return The sample on success, NULL otherwise. */ fluid_sample_t * -new_fluid_sample() +new_fluid_sample(void) { fluid_sample_t *sample = NULL; @@ -544,7 +544,7 @@ delete_fluid_sample(fluid_sample_t *sample) * * @warning Do NOT allocate samples on the stack and assign them to a voice! */ -size_t fluid_sample_sizeof() +size_t fluid_sample_sizeof(void) { return sizeof(fluid_sample_t); } diff --git a/src/synth/fluid_event.c b/src/synth/fluid_event.c index 48b781bd7..88adb77b1 100644 --- a/src/synth/fluid_event.c +++ b/src/synth/fluid_event.c @@ -56,7 +56,7 @@ fluid_event_clear(fluid_event_t *evt) * @return New sequencer event structure or NULL if out of memory */ fluid_event_t * -new_fluid_event() +new_fluid_event(void) { fluid_event_t *evt; From 91b86d8bbdf922eda764c41c6325d8150485a368 Mon Sep 17 00:00:00 2001 From: Tom M Date: Wed, 26 Jun 2024 11:09:03 +0200 Subject: [PATCH 29/33] Update docs about XG bank selection logic --- doc/fluidsettings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/fluidsettings.xml b/doc/fluidsettings.xml index 71af6432f..ef02b55bc 100644 --- a/doc/fluidsettings.xml +++ b/doc/fluidsettings.xml @@ -179,8 +179,8 @@ Developers:
  • gs: (default) CC0 becomes the bank number, CC32 is ignored.
  • gm: ignores CC0 and CC32 messages.
  • -
  • xg: if CC0<120 then channel is set to melodic and CC32 is the bank number. If CC0>=120 then channel is set to drum and the bank number is set to 128 (CC32 is ignored).
  • mma: bank is calculated as CC0*128+CC32.
  • +
  • xg: If CC0 is equal to 120, 126, or 127 then channel is set to drum and the bank number is set to 128 (CC32 is ignored). Otherwise the channel is set to melodic and CC32 is the bank number. Note that you need fluidsynth >=2.3.5 for this to work correctly, previous versions behaved incorrectly.
From 4fc38101f01c5fdc7283054d65c264823b274708 Mon Sep 17 00:00:00 2001 From: Tom M Date: Sat, 29 Jun 2024 17:41:34 +0200 Subject: [PATCH 30/33] Fix chorus when compiling with single precision (#1339) --- src/rvoice/fluid_chorus.c | 40 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/rvoice/fluid_chorus.c b/src/rvoice/fluid_chorus.c index c80dc9e98..a1168a7c6 100644 --- a/src/rvoice/fluid_chorus.c +++ b/src/rvoice/fluid_chorus.c @@ -169,10 +169,11 @@ /* modulator */ typedef struct { - fluid_real_t a1; /* Coefficient: a1 = 2 * cos(w) */ - fluid_real_t buffer1; /* buffer1 */ - fluid_real_t buffer2; /* buffer2 */ - fluid_real_t reset_buffer2;/* reset value of buffer2 */ + // for sufficient precision members MUST be double! See https://github.com/FluidSynth/fluidsynth/issues/1331 + double a1; /* Coefficient: a1 = 2 * cos(w) */ + double buffer1; /* buffer1 */ + double buffer2; /* buffer2 */ + double reset_buffer2;/* reset value of buffer2 */ } sinus_modulator; /*----------------------------------------------------------------------------- @@ -236,6 +237,10 @@ struct _fluid_chorus_t /*----------------------------------------------------------------------------- Sets the frequency of sinus oscillator. + For sufficient precision use double precision in set_sinus_frequency() computation !. + Never use: fluid_real_t , cosf(), sinf(), FLUID_COS(), FLUID_SIN(), FLUID_M_PI. + See https://github.com/FluidSynth/fluidsynth/issues/1331 + @param mod pointer on modulator structure. @param freq frequency of the oscillator in Hz. @param sample_rate sample rate on audio output in Hz. @@ -244,16 +249,17 @@ struct _fluid_chorus_t static void set_sinus_frequency(sinus_modulator *mod, float freq, float sample_rate, float phase) { - fluid_real_t w = 2 * FLUID_M_PI * freq / sample_rate; /* initial angle */ - fluid_real_t a; + double w = (2.0 * M_PI) * freq / sample_rate; /* step phase between each sinus wave sample (in radian) */ + double a; /* initial phase at which the sinus wave must begin (in radian) */ - mod->a1 = 2 * FLUID_COS(w); + // DO NOT use potentially single precision cosf or FLUID_COS here! See https://github.com/FluidSynth/fluidsynth/issues/1331 + mod->a1 = 2 * cos(w); - a = (2 * FLUID_M_PI / 360) * phase; + a = (2.0 * M_PI / 360.0) * phase; - mod->buffer2 = FLUID_SIN(a - w); /* y(n-1) = sin(-initial angle) */ - mod->buffer1 = FLUID_SIN(a); /* y(n) = sin(initial phase) */ - mod->reset_buffer2 = FLUID_SIN(FLUID_M_PI / 2 - w); /* reset value for PI/2 */ + mod->buffer2 = sin(a - w); /* y(n-1) = sin(-initial angle) */ + mod->buffer1 = sin(a); /* y(n) = sin(initial phase) */ + mod->reset_buffer2 = sin((M_PI / 2.0) - w); /* reset value for PI/2 */ } /*----------------------------------------------------------------------------- @@ -264,21 +270,21 @@ static void set_sinus_frequency(sinus_modulator *mod, @param mod pointer on modulator structure. @return current value of the modulator sine wave. -----------------------------------------------------------------------------*/ -static FLUID_INLINE fluid_real_t get_mod_sinus(sinus_modulator *mod) +static FLUID_INLINE double get_mod_sinus(sinus_modulator *mod) { - fluid_real_t out; + double out; out = mod->a1 * mod->buffer1 - mod->buffer2; mod->buffer2 = mod->buffer1; - if(out >= 1.0f) /* reset in case of instability near PI/2 */ + if(out >= 1.0) /* reset in case of instability near PI/2 */ { - out = 1.0f; /* forces output to the right value */ + out = 1.0; /* forces output to the right value */ mod->buffer2 = mod->reset_buffer2; } - if(out <= -1.0f) /* reset in case of instability near -PI/2 */ + if(out <= -1.0) /* reset in case of instability near -PI/2 */ { - out = -1.0f; /* forces output to the right value */ + out = -1.0; /* forces output to the right value */ mod->buffer2 = - mod->reset_buffer2; } From 186a4af987d123cd59ca3c3abf1c1f0a6174427a Mon Sep 17 00:00:00 2001 From: "Tom M." Date: Sat, 27 Jul 2024 20:30:39 +0200 Subject: [PATCH 31/33] Fix behavior of volume envelope delay phase --- src/rvoice/fluid_rvoice.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/rvoice/fluid_rvoice.c b/src/rvoice/fluid_rvoice.c index 403a55587..bec9243bf 100644 --- a/src/rvoice/fluid_rvoice.c +++ b/src/rvoice/fluid_rvoice.c @@ -355,10 +355,6 @@ fluid_rvoice_write(fluid_rvoice_t *voice, fluid_real_t *dsp_buf) count = fluid_rvoice_calc_amp(voice); - if(count <= 0) - { - return count; /* return -1 if voice is quiet, 0 if voice has finished */ - } /******************* phase **********************/ @@ -431,6 +427,19 @@ fluid_rvoice_write(fluid_rvoice_t *voice, fluid_real_t *dsp_buf) * Depending on the position in the loop and the loop size, this * may require several runs. */ + if(count <= 0) + { + // The voice is quite, i.e. either in delay phase or zero volume. + // We need to update the rvoice's dsp phase, as the delay phase shall not "postpone" the sound, rather + // it should be played silently, see https://github.com/FluidSynth/fluidsynth/issues/1312 + // + // Currently, this does access the sample buffers, which is redundant and could be optimized away. + // On the other hand, entering this if-clause is not supposed to happen often. + // + // Also note, that we're returning directly without running the IIR filter below. + return fluid_rvoice_dsp_interpolate_none(&voice->dsp, dsp_buf, is_looping); + } + switch(voice->dsp.interp_method) { case FLUID_INTERP_NONE: @@ -455,6 +464,7 @@ fluid_rvoice_write(fluid_rvoice_t *voice, fluid_real_t *dsp_buf) if(count == 0) { + // voice has finished return count; } From ecb014166eafd24df8447dc8bfc28a047652fe8b Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Tue, 21 May 2024 21:32:13 +0900 Subject: [PATCH 32/33] Add OS/2 KAI audio driver --- CMakeLists.txt | 12 +++ FluidSynthConfig.cmake.in | 1 + cmake_admin/report.cmake | 6 ++ src/CMakeLists.txt | 10 +++ src/config.cmake | 3 + src/drivers/fluid_adriver.c | 10 +++ src/drivers/fluid_adriver.h | 7 ++ src/drivers/fluid_kai.c | 164 ++++++++++++++++++++++++++++++++++++ 8 files changed, 213 insertions(+) create mode 100644 src/drivers/fluid_kai.c diff --git a/CMakeLists.txt b/CMakeLists.txt index c2a8da7cd..1372d56d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,6 +117,7 @@ endif ( CMAKE_SYSTEM MATCHES "Darwin" ) if ( CMAKE_SYSTEM MATCHES "OS2" ) option ( enable-dart "compile DART support (if it is available)" on ) + option ( enable-kai "compile KAI support (if it is available)" on ) set ( enable-ipv6 off ) endif ( CMAKE_SYSTEM MATCHES "OS2" ) @@ -367,6 +368,9 @@ set ( LIBFLUID_LIBS ${MATH_LIBRARY} Threads::Threads ) unset ( DART_SUPPORT CACHE ) unset ( DART_LIBS CACHE ) unset ( DART_INCLUDE_DIRS CACHE ) +unset ( KAI_SUPPORT CACHE ) +unset ( KAI_LIBS CACHE ) +unset ( KAI_INCLUDE_DIRS CACHE ) if ( CMAKE_SYSTEM MATCHES "OS2" ) set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Zbin-files" ) set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Zbin-files" ) @@ -375,6 +379,14 @@ if ( CMAKE_SYSTEM MATCHES "OS2" ) set ( DART_SUPPORT ${HAVE_DART_H} ) unset ( DART_INCLUDE_DIRS CACHE ) endif ( enable-dart ) + if ( enable-kai ) + check_include_files ( "kai.h" HAVE_KAI_H ) + if ( HAVE_KAI_H ) + set ( KAI_SUPPORT ${HAVE_KAI_H} ) + set ( KAI_LIBS "-lkai" ) + endif ( HAVE_KAI_H ) + unset ( KAI_INCLUDE_DIRS CACHE ) + endif ( enable-kai ) endif ( CMAKE_SYSTEM MATCHES "OS2" ) # Solaris / SunOS diff --git a/FluidSynthConfig.cmake.in b/FluidSynthConfig.cmake.in index 0d251d957..83b1ae2ee 100644 --- a/FluidSynthConfig.cmake.in +++ b/FluidSynthConfig.cmake.in @@ -5,6 +5,7 @@ set(FLUIDSYNTH_SUPPORT_COREMIDI @COREMIDI_SUPPORT@) set(FLUIDSYNTH_SUPPORT_DART @DART_SUPPORT@) set(FLUIDSYNTH_SUPPORT_DSOUND @DSOUND_SUPPORT@) set(FLUIDSYNTH_SUPPORT_JACK @JACK_SUPPORT@) +set(FLUIDSYNTH_SUPPORT_KAI @KAI_SUPPORT@) set(FLUIDSYNTH_SUPPORT_MIDISHARE @MIDISHARE_SUPPORT@) set(FLUIDSYNTH_SUPPORT_OBOE @OBOE_SUPPORT@) set(FLUIDSYNTH_SUPPORT_OPENSLES @OPENSLES_SUPPORT@) diff --git a/cmake_admin/report.cmake b/cmake_admin/report.cmake index 85b375454..437333d75 100644 --- a/cmake_admin/report.cmake +++ b/cmake_admin/report.cmake @@ -55,6 +55,12 @@ else ( DART_SUPPORT ) set ( AUDIO_MIDI_REPORT "${AUDIO_MIDI_REPORT} OS/2 DART: no\n" ) endif ( DART_SUPPORT ) +if ( KAI_SUPPORT ) + set ( AUDIO_MIDI_REPORT "${AUDIO_MIDI_REPORT} OS/2 KAI: yes\n" ) +else ( KAI_SUPPORT ) + set ( AUDIO_MIDI_REPORT "${AUDIO_MIDI_REPORT} OS/2 KAI: no\n" ) +endif ( KAI_SUPPORT ) + if ( OSS_SUPPORT ) set ( AUDIO_MIDI_REPORT "${AUDIO_MIDI_REPORT} OSS: yes\n" ) else ( OSS_SUPPORT ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 398ff000f..f641d047c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,6 +81,10 @@ if ( DART_SUPPORT ) set ( fluid_dart_SOURCES drivers/fluid_dart.c ) endif ( DART_SUPPORT ) +if ( KAI_SUPPORT ) + set ( fluid_kai_SOURCES drivers/fluid_kai.c ) +endif ( KAI_SUPPORT ) + if ( MIDISHARE_SUPPORT ) set ( fluid_midishare_SOURCES drivers/fluid_midishare.c ) endif ( MIDISHARE_SUPPORT ) @@ -232,6 +236,7 @@ add_library ( libfluidsynth-OBJ OBJECT ${fluid_dart_SOURCES} ${fluid_dbus_SOURCES} ${fluid_jack_SOURCES} + ${fluid_kai_SOURCES} ${fluid_pipewire_SOURCES} ${fluid_midishare_SOURCES} ${fluid_opensles_SOURCES} @@ -347,6 +352,7 @@ endif ( MACOSX_FRAMEWORK ) # but since they do not have a link step nothing is done with their object files. target_link_libraries ( libfluidsynth-OBJ PUBLIC ${DART_LIBS} + ${KAI_LIBS} ${COREAUDIO_LIBS} ${COREMIDI_LIBS} ${WINDOWS_LIBS} @@ -414,6 +420,10 @@ if ( DART_SUPPORT ) target_include_directories ( libfluidsynth-OBJ PUBLIC ${DART_INCLUDE_DIRS} ) endif ( DART_SUPPORT ) +if ( KAI_SUPPORT ) + target_include_directories ( libfluidsynth-OBJ PUBLIC ${KAI_INCLUDE_DIRS} ) +endif ( KAI_SUPPORT ) + if ( MIDISHARE_SUPPORT ) target_link_libraries ( libfluidsynth-OBJ PUBLIC MidiShare::MidiShare ) endif ( MIDISHARE_SUPPORT ) diff --git a/src/config.cmake b/src/config.cmake index 94324e815..16347188e 100644 --- a/src/config.cmake +++ b/src/config.cmake @@ -127,6 +127,9 @@ /* Define to enable JACK driver */ #cmakedefine JACK_SUPPORT @JACK_SUPPORT@ +/* Define to enable KAI driver */ +#cmakedefine KAI_SUPPORT @KAI_SUPPORT@ + /* Define to enable PipeWire driver */ #cmakedefine PIPEWIRE_SUPPORT @PIPEWIRE_SUPPORT@ diff --git a/src/drivers/fluid_adriver.c b/src/drivers/fluid_adriver.c index e642ca596..f56d636b0 100644 --- a/src/drivers/fluid_adriver.c +++ b/src/drivers/fluid_adriver.c @@ -170,6 +170,16 @@ static const fluid_audriver_definition_t fluid_audio_drivers[] = }, #endif +#if KAI_SUPPORT + { + "kai", + new_fluid_kai_audio_driver, + NULL, + delete_fluid_kai_audio_driver, + fluid_kai_audio_driver_settings + }, +#endif + #if DART_SUPPORT { "dart", diff --git a/src/drivers/fluid_adriver.h b/src/drivers/fluid_adriver.h index 8517f3371..a36519050 100644 --- a/src/drivers/fluid_adriver.h +++ b/src/drivers/fluid_adriver.h @@ -159,6 +159,13 @@ fluid_audio_driver_t *new_fluid_sndmgr_audio_driver2(fluid_settings_t *settings, void delete_fluid_sndmgr_audio_driver(fluid_audio_driver_t *p); #endif +#if KAI_SUPPORT +fluid_audio_driver_t *new_fluid_kai_audio_driver(fluid_settings_t *settings, + fluid_synth_t *synth); +void delete_fluid_kai_audio_driver(fluid_audio_driver_t *p); +void fluid_kai_audio_driver_settings(fluid_settings_t *settings); +#endif + #if DART_SUPPORT fluid_audio_driver_t *new_fluid_dart_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth); diff --git a/src/drivers/fluid_kai.c b/src/drivers/fluid_kai.c new file mode 100644 index 000000000..5c4e310fc --- /dev/null +++ b/src/drivers/fluid_kai.c @@ -0,0 +1,164 @@ +/* FluidSynth - A Software Synthesizer + * + * Copyright (C) 2003 Peter Hanappe and others. + * Copyright (C) 2024 KO Myung-Hun + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA + */ + +/* fluid_kai.c + * + * Driver for OS/2 KAI + * + */ + +#include "fluid_adriver.h" +#include "fluid_settings.h" +#include "fluid_sys.h" + +#if KAI_SUPPORT + +#define INCL_DOS +#include + +#include + +#define NUM_MIX_BUFS 2 + +/** fluid_kai_audio_driver_t + * + * This structure should not be accessed directly. Use audio port + * functions instead. + */ +typedef struct { + fluid_audio_driver_t driver; + fluid_synth_t *synth; + int frame_size; + HKAI hkai; /* KAI handle */ +} fluid_kai_audio_driver_t; + +static APIRET APIENTRY +fluid_kai_callback(PVOID pCBData, PVOID pBuffer, ULONG ulSize); + +/************************************************************** + * + * KAI audio driver + * + */ + +void fluid_kai_audio_driver_settings(fluid_settings_t *settings) +{ + fluid_settings_register_str(settings, "audio.kai.device", "default", 0); +} + +fluid_audio_driver_t * +new_fluid_kai_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth) +{ + fluid_kai_audio_driver_t *dev; + KAISPEC wanted, obtained; + double sample_rate; + int periods, period_size; + ULONG rc; + + dev = FLUID_NEW(fluid_kai_audio_driver_t); + if (dev == NULL) { + FLUID_LOG(FLUID_ERR, "Out of memory"); + return NULL; + } + + FLUID_MEMSET(dev, 0, sizeof(fluid_kai_audio_driver_t)); + + fluid_settings_getnum(settings, "synth.sample-rate", &sample_rate); + fluid_settings_getint(settings, "audio.periods", &periods); + fluid_settings_getint(settings, "audio.period-size", &period_size); + + /* check the format */ + if (!fluid_settings_str_equal(settings, "audio.sample-format", "16bits")) { + FLUID_LOG(FLUID_ERR, "Unhandled sample format"); + goto error_recovery; + } + + dev->synth = synth; + dev->frame_size = 2/* channels */ * sizeof(short)/* 16bits sample */; + + /* Initialize KAI */ + rc = kaiInit(KAIM_AUTO); + if (rc != KAIE_NO_ERROR) { + FLUID_LOG(FLUID_ERR, "Cannot initialize KAI, rc = %lu", rc); + goto error_recovery; + } + + /* Open KAI */ + wanted.usDeviceIndex = 0; /* default device */ + wanted.ulType = KAIT_PLAY; + wanted.ulBitsPerSample = BPS_16; /* only 16bits audio */ + wanted.ulSamplingRate = sample_rate; + wanted.ulDataFormat = MCI_WAVE_FORMAT_PCM; + wanted.ulChannels = 2; /* only 2 channels */ + wanted.ulNumBuffers = NUM_MIX_BUFS; + wanted.ulBufferSize = periods * period_size * dev->frame_size; + wanted.fShareable = TRUE; + wanted.pfnCallBack = fluid_kai_callback; + wanted.pCallBackData = dev; + + rc = kaiOpen(&wanted, &obtained, &dev->hkai); + if (rc != KAIE_NO_ERROR) { + FLUID_LOG(FLUID_ERR, "Cannot open KAI, rc = %lu", rc); + goto error_recovery; + } + + /* Start to play */ + kaiPlay(dev->hkai); + + return (fluid_audio_driver_t *) dev; + +error_recovery: + + delete_fluid_kai_audio_driver((fluid_audio_driver_t *) dev); + return NULL; +} + +void delete_fluid_kai_audio_driver(fluid_audio_driver_t *p) +{ + fluid_kai_audio_driver_t *dev = (fluid_kai_audio_driver_t *) p; + + fluid_return_if_fail(dev != NULL); + + /* Stop playing */ + kaiStop(dev->hkai); + + /* Close KAI */ + kaiClose(dev->hkai); + + /* Terminate KAI */ + kaiDone(); + + FLUID_FREE(dev); +} + +static APIRET APIENTRY +fluid_kai_callback(PVOID pCBData, PVOID pBuffer, ULONG ulSize) +{ + fluid_kai_audio_driver_t *dev = (fluid_kai_audio_driver_t *) pCBData; + + FLUID_MEMSET(pBuffer, 0, ulSize); + fluid_synth_write_s16(dev->synth, ulSize / dev->frame_size, + pBuffer, 0, 2, pBuffer, 1, 2 ); + + return ulSize; +} + +#endif /* #if KAI_SUPPORT */ From 31fa6ea9c050e77fb3a3c53989cb78286c092ee8 Mon Sep 17 00:00:00 2001 From: "Tom M." Date: Sat, 27 Jul 2024 20:44:54 +0200 Subject: [PATCH 33/33] Remove interpolation of IIR filter coefficients (#1345) --- src/rvoice/fluid_iir_filter.c | 106 +++++----------------------------- src/rvoice/fluid_iir_filter.h | 6 -- 2 files changed, 16 insertions(+), 96 deletions(-) diff --git a/src/rvoice/fluid_iir_filter.c b/src/rvoice/fluid_iir_filter.c index 0535cbf27..b7fb31ef1 100644 --- a/src/rvoice/fluid_iir_filter.c +++ b/src/rvoice/fluid_iir_filter.c @@ -65,7 +65,6 @@ fluid_iir_filter_apply(fluid_iir_filter_t *iir_filter, fluid_real_t dsp_a2 = iir_filter->a2; fluid_real_t dsp_b02 = iir_filter->b02; fluid_real_t dsp_b1 = iir_filter->b1; - int dsp_filter_coeff_incr_count = iir_filter->filter_coeff_incr_count; fluid_real_t dsp_centernode; int dsp_i; @@ -83,51 +82,18 @@ fluid_iir_filter_apply(fluid_iir_filter_t *iir_filter, * doesn't change. */ - if(dsp_filter_coeff_incr_count > 0) + for(dsp_i = 0; dsp_i < count; dsp_i++) { - fluid_real_t dsp_a1_incr = iir_filter->a1_incr; - fluid_real_t dsp_a2_incr = iir_filter->a2_incr; - fluid_real_t dsp_b02_incr = iir_filter->b02_incr; - fluid_real_t dsp_b1_incr = iir_filter->b1_incr; - - - /* Increment is added to each filter coefficient filter_coeff_incr_count times. */ - for(dsp_i = 0; dsp_i < count; dsp_i++) - { - /* The filter is implemented in Direct-II form. */ - dsp_centernode = dsp_buf[dsp_i] - dsp_a1 * dsp_hist1 - dsp_a2 * dsp_hist2; - dsp_buf[dsp_i] = dsp_b02 * (dsp_centernode + dsp_hist2) + dsp_b1 * dsp_hist1; - dsp_hist2 = dsp_hist1; - dsp_hist1 = dsp_centernode; - - if(dsp_filter_coeff_incr_count-- > 0) - { - fluid_real_t old_b02 = dsp_b02; - dsp_a1 += dsp_a1_incr; - dsp_a2 += dsp_a2_incr; - dsp_b02 += dsp_b02_incr; - dsp_b1 += dsp_b1_incr; - - /* Compensate history to avoid the filter going havoc with large frequency changes */ - if(iir_filter->compensate_incr && FLUID_FABS(dsp_b02) > 0.001f) - { - fluid_real_t compensate = old_b02 / dsp_b02; - dsp_hist1 *= compensate; - dsp_hist2 *= compensate; - } - } - } /* for dsp_i */ - } - else /* The filter parameters are constant. This is duplicated to save time. */ - { - for(dsp_i = 0; dsp_i < count; dsp_i++) - { - /* The filter is implemented in Direct-II form. */ - dsp_centernode = dsp_buf[dsp_i] - dsp_a1 * dsp_hist1 - dsp_a2 * dsp_hist2; - dsp_buf[dsp_i] = dsp_b02 * (dsp_centernode + dsp_hist2) + dsp_b1 * dsp_hist1; - dsp_hist2 = dsp_hist1; - dsp_hist1 = dsp_centernode; - } + /* The filter is implemented in Direct-II form. */ + dsp_centernode = dsp_buf[dsp_i] - dsp_a1 * dsp_hist1 - dsp_a2 * dsp_hist2; + dsp_buf[dsp_i] = dsp_b02 * (dsp_centernode + dsp_hist2) + dsp_b1 * dsp_hist1; + dsp_hist2 = dsp_hist1; + dsp_hist1 = dsp_centernode; + /* Alternatively, it could be implemented in Transposed Direct Form II */ + // fluid_real_t dsp_input = dsp_buf[dsp_i]; + // dsp_buf[dsp_i] = dsp_b02 * dsp_input + dsp_hist1; + // dsp_hist1 = dsp_b1 * dsp_input - dsp_a1 * dsp_buf[dsp_i] + dsp_hist2; + // dsp_hist2 = dsp_b02 * dsp_input - dsp_a2 * dsp_buf[dsp_i]; } iir_filter->hist1 = dsp_hist1; @@ -136,7 +102,6 @@ fluid_iir_filter_apply(fluid_iir_filter_t *iir_filter, iir_filter->a2 = dsp_a2; iir_filter->b02 = dsp_b02; iir_filter->b1 = dsp_b1; - iir_filter->filter_coeff_incr_count = dsp_filter_coeff_incr_count; fluid_check_fpe("voice_filter"); } @@ -320,47 +285,11 @@ fluid_iir_filter_calculate_coefficients(fluid_iir_filter_t *iir_filter, return; } - iir_filter->compensate_incr = 0; - - if(iir_filter->filter_startup || (transition_samples == 0)) - { - /* The filter is calculated, because the voice was started up. - * In this case set the filter coefficients without delay. - */ - iir_filter->a1 = a1_temp; - iir_filter->a2 = a2_temp; - iir_filter->b02 = b02_temp; - iir_filter->b1 = b1_temp; - iir_filter->filter_coeff_incr_count = 0; - iir_filter->filter_startup = 0; -// printf("Setting initial filter coefficients.\n"); - } - else - { - - /* The filter frequency is changed. Calculate an increment - * factor, so that the new setting is reached after one buffer - * length. x_incr is added to the current value FLUID_BUFSIZE - * times. The length is arbitrarily chosen. Longer than one - * buffer will sacrifice some performance, though. Note: If - * the filter is still too 'grainy', then increase this number - * at will. - */ - - iir_filter->a1_incr = (a1_temp - iir_filter->a1) / transition_samples; - iir_filter->a2_incr = (a2_temp - iir_filter->a2) / transition_samples; - iir_filter->b02_incr = (b02_temp - iir_filter->b02) / transition_samples; - iir_filter->b1_incr = (b1_temp - iir_filter->b1) / transition_samples; - - if(FLUID_FABS(iir_filter->b02) > 0.0001f) - { - fluid_real_t quota = b02_temp / iir_filter->b02; - iir_filter->compensate_incr = quota < 0.5f || quota > 2.f; - } - - /* Have to add the increments filter_coeff_incr_count times. */ - iir_filter->filter_coeff_incr_count = transition_samples; - } + iir_filter->a1 = a1_temp; + iir_filter->a2 = a2_temp; + iir_filter->b02 = b02_temp; + iir_filter->b1 = b1_temp; + iir_filter->filter_startup = 0; fluid_check_fpe("voice_write filter calculation"); } @@ -376,9 +305,6 @@ void fluid_iir_filter_calc(fluid_iir_filter_t *iir_filter, /* calculate the frequency of the resonant filter in Hz */ fres = fluid_ct2hz(iir_filter->fres + fres_mod); - /* FIXME - Still potential for a click during turn on, can we interpolate - between 20khz cutoff and 0 Q? */ - /* I removed the optimization of turning the filter off when the * resonance frequency is above the maximum frequency. Instead, the * filter frequency is set to a maximum of 0.45 times the sampling diff --git a/src/rvoice/fluid_iir_filter.h b/src/rvoice/fluid_iir_filter.h index 355d197f1..09e11f0b3 100644 --- a/src/rvoice/fluid_iir_filter.h +++ b/src/rvoice/fluid_iir_filter.h @@ -53,12 +53,6 @@ struct _fluid_iir_filter_t fluid_real_t a1; /* a0 / a0 */ fluid_real_t a2; /* a1 / a0 */ - fluid_real_t b02_incr; - fluid_real_t b1_incr; - fluid_real_t a1_incr; - fluid_real_t a2_incr; - int filter_coeff_incr_count; - int compensate_incr; /* Flag: If set, must compensate history */ fluid_real_t hist1, hist2; /* Sample history for the IIR filter */ int filter_startup; /* Flag: If set, the filter will be set directly. Else it changes smoothly. */