diff --git a/CMakeLists.txt b/CMakeLists.txt index efbe97732..40fde184b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # FluidSynth - A Software Synthesizer # -# Copyright (C) 2003-2023 Peter Hanappe and others. +# Copyright (C) 2003-2024 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 @@ -47,7 +47,7 @@ set ( PACKAGE "fluidsynth" ) # FluidSynth package version set ( FLUIDSYNTH_VERSION_MAJOR 2 ) set ( FLUIDSYNTH_VERSION_MINOR 4 ) -set ( FLUIDSYNTH_VERSION_MICRO 1 ) +set ( FLUIDSYNTH_VERSION_MICRO 2 ) set ( VERSION "${FLUIDSYNTH_VERSION_MAJOR}.${FLUIDSYNTH_VERSION_MINOR}.${FLUIDSYNTH_VERSION_MICRO}" ) set ( FLUIDSYNTH_VERSION ${VERSION} ) @@ -62,7 +62,7 @@ set ( FLUIDSYNTH_VERSION ${VERSION} ) # This is not exactly the same algorithm as the libtool one, but the results are the same. set ( LIB_VERSION_CURRENT 3 ) set ( LIB_VERSION_AGE 3 ) -set ( LIB_VERSION_REVISION 1 ) +set ( LIB_VERSION_REVISION 2 ) set ( LIB_VERSION_INFO "${LIB_VERSION_CURRENT}.${LIB_VERSION_AGE}.${LIB_VERSION_REVISION}" ) @@ -521,7 +521,7 @@ set ( ALSA_MINIMUM_VERSION 0.9.1 ) set ( DBUS_MINIMUM_VERSION 1.11.12 ) set ( GLIB2_MINUMUM_VERSION 2.6.5 ) set ( LIBINSTPATCH_MINIMUM_VERSION 1.1.0 ) -set ( LIBSNDFILE_MINIMUM_VERSION 1.2.1 ) +set ( LIBSNDFILE_MINIMUM_VERSION 1.0.0 ) set ( PIPEWIRE_MINIMUM_VERSION 0.3 ) set ( PORTAUDIO_MINIMUM_VERSION 2.19 ) set ( PULSEAUDIO_MINIMUM_VERSION 2.0 ) @@ -547,6 +547,11 @@ unset ( LIBSNDFILE_HASVORBIS CACHE ) if ( enable-libsndfile ) #set(CMAKE_FIND_DEBUG_MODE ON) find_package ( SndFile ${LIBSNDFILE_MINIMUM_VERSION} QUIET ) + if ( NOT SndFile_FOUND ) + # Not all distros have switched to libsndfile's cmake based build system, see #1445. + # Therefore, discover sndfile via the legacy pkg-config magic. + find_package ( SndFileLegacy ) + endif () set ( LIBSNDFILE_SUPPORT ${SndFile_FOUND} ) if ( LIBSNDFILE_SUPPORT ) message ( STATUS "Found libSndFile: ${SndFile_VERSION}" ) diff --git a/FluidSynthConfig.cmake.in b/FluidSynthConfig.cmake.in index 83b1ae2ee..d2e0c5e9d 100644 --- a/FluidSynthConfig.cmake.in +++ b/FluidSynthConfig.cmake.in @@ -22,6 +22,7 @@ set(FLUIDSYNTH_SUPPORT_WINMIDI @WINMIDI_SUPPORT@) set(FLUIDSYNTH_SUPPORT_DLS @LIBINSTPATCH_SUPPORT@) set(FLUIDSYNTH_SUPPORT_LIBINSTPATCH @LIBINSTPATCH_SUPPORT@) set(FLUIDSYNTH_SUPPORT_LIBSNDFILE @LIBSNDFILE_SUPPORT@) +set(FLUIDSYNTH_SUPPORT_LIBSNDFILE_LEGACY @SndFileLegacy_FOUND@) set(FLUIDSYNTH_SUPPORT_SF3 @LIBSNDFILE_HASVORBIS@) # Miscrellaneous support @@ -96,7 +97,9 @@ if(NOT FLUIDSYNTH_IS_SHARED) find_dependency(InstPatch @LIBINSTPATCH_MINIMUM_VERSION@) endif() - if(FLUIDSYNTH_SUPPORT_LIBSNDFILE AND NOT TARGET SndFile::sndfile) + if(FLUIDSYNTH_SUPPORT_LIBSNDFILE_LEGACY AND NOT TARGET SndFile::sndfile) + find_dependency(SndFileLegacy @LIBSNDFILE_MINIMUM_VERSION@) + elseif(FLUIDSYNTH_SUPPORT_LIBSNDFILE AND NOT TARGET SndFile::sndfile) find_dependency(SndFile @LIBSNDFILE_MINIMUM_VERSION@) endif() diff --git a/cmake_admin/FindFLAC.cmake b/cmake_admin/FindFLAC.cmake new file mode 100644 index 000000000..2de2f41a8 --- /dev/null +++ b/cmake_admin/FindFLAC.cmake @@ -0,0 +1,106 @@ +#[=======================================================================[.rst: +FindFLAC +------- + +Finds the FLAC library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``FLAC::FLAC`` + The FLAC C library. +``FLAC::FLAC++`` + The FLAC C++ library. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``FLAC_FOUND`` + True if both libraries were found. +``FLAC_FLAC_FOUND`` + True if the C library was found. +``FLAC_FLAC++_FOUND`` + True if the C++ library was found.. + +#]=======================================================================] + +# Use pkg-config if available +find_package(PkgConfig QUIET) +pkg_check_modules(PC_FLAC QUIET flac) +pkg_check_modules(PC_FLAC++ QUIET flac++) + +# Find the headers and libraries +find_path( + FLAC_INCLUDE_DIR + NAMES "FLAC/all.h" + HINTS "PC_FLAC_INCLUDEDIR") + +find_path( + FLAC++_INCLUDE_DIR + NAMES "FLAC++/all.h" + HINTS "PC_FLAC++_INCLUDEDIR") + +find_library( + FLAC_LIBRARY + NAMES "FLAC" + HINTS "${PC_FLAC_LIBDIR}") + +find_library( + FLAC++_LIBRARY + NAMES "FLAC++" + HINTS "${PC_FLAC++_LIBDIR}") + +# Handle transitive dependencies +if(PC_FLAC_FOUND) + get_target_properties_from_pkg_config("${FLAC_LIBRARY}" "PC_FLAC" "_flac") +else() + if(NOT TARGET "Ogg::ogg") + find_package(Ogg QUIET) + endif() + set(_flac_link_libraries "Ogg::ogg" ${MATH_LIBRARY}) +endif() + +if(PC_FLAC++_FOUND) + get_target_properties_from_pkg_config("${FLAC++_LIBRARY}" "PC_FLAC++" + "_flac++") +else() + set(_flac++_link_libraries "FLAC::FLAC") +endif() + +# Forward the result to CMake +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + FLAC REQUIRED_VARS "FLAC_LIBRARY" "FLAC_INCLUDE_DIR" "FLAC++_LIBRARY" + "FLAC++_INCLUDE_DIR") + +# Create the target +if(FLAC_FOUND AND NOT TARGET FLAC::FLAC) + add_library(FLAC::FLAC UNKNOWN IMPORTED) + set_target_properties( + FLAC::FLAC + PROPERTIES IMPORTED_LOCATION "${FLAC_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${_flac_compile_options}" + INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${_flac_link_libraries}" + INTERFACE_LINK_DIRECTORIES "${_flac_link_directories}") + set(FLAC_FLAC_FOUND TRUE) +endif() + +if(FLAC_FOUND AND NOT TARGET FLAC::FLAC++) + add_library(FLAC::FLAC++ UNKNOWN IMPORTED) + set_target_properties( + FLAC::FLAC++ + PROPERTIES IMPORTED_LOCATION "${FLAC++_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${_flac++_compile_options}" + INTERFACE_INCLUDE_DIRECTORIES "${FLAC++_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${_flac++_link_libraries}" + INTERFACE_LINK_DIRECTORIES "${_flac++_link_directories}") + set(FLAC_FLAC++_FOUND TRUE) +endif() + +mark_as_advanced(FLAC_LIBRARY FLAC_INCLUDE_DIR FLAC++_LIBRARY + FLAC++_INCLUDE_DIR) diff --git a/cmake_admin/FindOgg.cmake b/cmake_admin/FindOgg.cmake new file mode 100644 index 000000000..8044c9414 --- /dev/null +++ b/cmake_admin/FindOgg.cmake @@ -0,0 +1,84 @@ +#[=======================================================================[.rst: +FindOgg +------- + +Finds the Ogg library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``Ogg::ogg`` + The Ogg library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``Ogg_FOUND`` + True if the system has the Ogg library. + +For compatibility with upstream, the following variables are also set: + +``Ogg_INCLUDE_DIR`` +``Ogg_INCLUDE_DIRS`` +``Ogg_LIBRARY`` +``Ogg_LIBRARIES`` +``OGG_INCLUDE_DIR`` +``OGG_INCLUDE_DIRS`` +``OGG_LIBRARY`` +``OGG_LIBRARIES`` +``OGG_FOUND`` + +#]=======================================================================] + +# Use pkg-config if available +find_package(PkgConfig QUIET) +pkg_check_modules(PC_OGG QUIET ogg) + +# Find the headers and library +find_path( + Ogg_INCLUDE_DIR + NAMES "ogg/ogg.h" + HINTS "${PC_OGG_INCLUDEDIR}") + +find_library( + _ogg_library + NAMES "ogg" + HINTS "${PC_OGG_LIBDIR}") + +# Extract additional flags if pkg-config is available +if(PC_OGG_FOUND) + get_target_properties_from_pkg_config("${_ogg_library}" "PC_OGG" "_ogg") +endif() + +# Forward the result to CMake +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Ogg REQUIRED_VARS "_ogg_library" + "Ogg_INCLUDE_DIR") + +# Create the target +if(Ogg_FOUND AND NOT TARGET Ogg::ogg) + add_library(Ogg::ogg UNKNOWN IMPORTED) + set_target_properties( + Ogg::ogg + PROPERTIES IMPORTED_LOCATION "${_ogg_library}" + INTERFACE_COMPILE_OPTIONS "${_ogg_compile_options}" + INTERFACE_INCLUDE_DIRECTORIES "${Ogg_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${_ogg_link_libraries}" + INTERFACE_LINK_DIRECTORIES "${_ogg_link_directories}") + + # Set additional variables for compatibility with upstream config + set(Ogg_INCLUDE_DIRS "${Ogg_INCLUDE_DIR}") + set(Ogg_LIBRARY Ogg::ogg) + set(Ogg_LIBRARIES Ogg::ogg) + set(OGG_INCLUDE_DIR "${${Ogg_INCLUDE_DIR}}") + set(OGG_INCLUDE_DIRS "${${Ogg_INCLUDE_DIR}}") + set(OGG_LIBRARY Ogg::ogg) + set(OGG_LIBRARIES Ogg::ogg) + set(OGG_FOUND TRUE) +endif() + +mark_as_advanced(_ogg_library) diff --git a/cmake_admin/FindSndFileLegacy.cmake b/cmake_admin/FindSndFileLegacy.cmake new file mode 100644 index 000000000..4565110b0 --- /dev/null +++ b/cmake_admin/FindSndFileLegacy.cmake @@ -0,0 +1,182 @@ +#[=======================================================================[.rst: +FindSndFile +------- + +Finds the SndFile library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``SndFile::sndfile`` + The SndFile library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``SndFile_FOUND`` + True if the system has the SndFile library. +``SndFile_VERSION`` + The version of the SndFile library which was found. +``SndFile_WITH_EXTERNAL_LIBS`` + True if the library was built with Xiph codecs. + +For compatibility with upstream, the following variables are also set: + +``SndFile_WITH_MPEG`` +``SndFile_VERSION_MAJOR`` +``SndFile_VERSION_MINOR`` +``SndFile_VERSION_PATCH`` +``SndFile_LIBRARY`` +``SndFile_LIBRARIES`` +``SNDFILE_LIBRARY`` +``SNDFILE_LIBRARIES`` +``SNDFILE_INCLUDE_DIR`` + +#]=======================================================================] + +# Use pkg-config if available +find_package(PkgConfig QUIET) +pkg_check_modules(PC_SNDFILE QUIET sndfile) + +# Find the headers and libraries +find_path( + SndFile_INCLUDE_DIR + NAMES "sndfile.h" + HINTS "${PC_SNDFILE_INCLUDEDIR}") + +find_library( + _sndfile_library + NAMES "sndfile" "sndfile-1" + HINTS "${PC_SNDFILE_LIBDIR}") + +# Get version from pkg-config or read the config header +if(PC_SNDFILE_VERSION) + set(SndFile_VERSION "${PC_SNDFILE_VERSION}") + string(REPLACE "." ";" _sndfile_version_list "${SndFile_VERSION}") + list(GET _sndfile_version_list 0 SndFile_VERSION_MAJOR) + list(GET _sndfile_version_list 1 SndFile_VERSION_MINOR) + list(GET _sndfile_version_list 2 SndFile_VERSION_PATCH) +elseif(SndFile_INCLUDE_DIR) + file(READ "${SndFile_INCLUDE_DIR}/sndfile.h" _sndfile_h) + if("#define SNDFILE_1" MATCHES _snfile_h) + set(SndFile_VERSION "1") + set(SndFile_VERSION_MAJOR "1") + endif() +endif() + +# Check the features SndFile was built with +# 2024-01-02: Recent versions of libsndfile don't seem to provide a pkgconfig file and older version who did are lacking private libraries like OGG. +if(FALSE) #PC_SNDFILE_FOUND + if("vorbis" IN_LIST PC_SNDFILE_STATIC_LIBRARIES) + set(SndFile_WITH_EXTERNAL_LIBS TRUE) + endif() + if("mpg123" IN_LIST PC_SNDFILE_STATIC_LIBRARIES) + set(SndFile_WITH_MPEG TRUE) + endif() +elseif(_sndfile_library) + # sndfile may need any of these libraries + find_package(Ogg 1.3 QUIET) + find_package(Vorbis QUIET) + find_package(FLAC QUIET) + find_package(Opus QUIET) + find_package(mp3lame QUIET) + find_package(mpg123 QUIET) + + if(NOT CMAKE_CROSSCOMPILING) + include(CheckSourceRuns) + set(_backup_includes ${CMAKE_REQUIRED_INCLUDES}) + set(_backup_libraries ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES "${SndFile_INCLUDE_DIR}") + set(CMAKE_REQUIRED_LIBRARIES "${_sndfile_library}") + + set(_optional_libs "MPG123::libmpg123" "mp3lame::mp3lame" "FLAC::FLAC" + "Opus::opus" "Vorbis::vorbisenc" "Ogg::ogg") + foreach(_target ${_optional_libs}) + if(TARGET "${_target}") + list(APPEND CMAKE_REQUIRED_LIBRARIES "${_target}") + endif() + endforeach() + + check_source_runs( + C + "#include +#include +int main() { + SF_FORMAT_INFO info = {SF_FORMAT_VORBIS}; + sf_command(NULL, SFC_GET_FORMAT_INFO, &info, sizeof info); + return info.name != NULL ? EXIT_SUCCESS : EXIT_FAILURE; +}" + SNDFILE_SUPPORTS_VORBIS) + + check_source_runs( + C + "#include +#include +int main() { + SF_FORMAT_INFO info = {SF_FORMAT_MPEG_LAYER_III}; + sf_command(NULL, SFC_GET_FORMAT_INFO, &info, sizeof info); + return info.name != NULL ? EXIT_SUCCESS : EXIT_FAILURE; +}" + SNDFILE_SUPPORTS_MPEG) + + set(SndFile_WITH_EXTERNAL_LIBS ${SNDFILE_SUPPORTS_VORBIS}) + set(SndFile_WITH_MPEG ${SNDFILE_SUPPORTS_MPEG}) + set(CMAKE_REQUIRED_INCLUDES ${_backup_includes}) + set(CMAKE_REQUIRED_LIBRARIES ${_backup_libraries}) + else() + message( + STATUS + "Cross-compiling without pkg-config - cannot check for external libraries." + "If you have the upstream CMake config set CMAKE_FIND_PACKAGE_PREFER_CONFIG to true for accurate results." + ) + set(SndFile_WITH_EXTERNAL_LIBS FALSE) + set(SndFile_WITH_MPEG FALSE) + endif() +endif() + +# Handle transitive dependencies +if(PC_SNDFILE_FOUND) + get_target_properties_from_pkg_config("${_sndfile_library}" "PC_SNDFILE" + "_sndfile") +else() + if(SndFile_WITH_EXTERNAL_LIBS) + list(APPEND _sndfile_link_libraries "FLAC::FLAC" "Opus::opus" + "Vorbis::vorbisenc" "Ogg::ogg") + endif() + if(SndFile_WITH_MPEG) + list(APPEND _sndfile_link_libraries "MPG123::libmpg123" "mp3lame::mp3lame") + endif() +endif() + +# Forward the result to CMake +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + SndFileLegacy + REQUIRED_VARS "_sndfile_library" "SndFile_INCLUDE_DIR" + VERSION_VAR "SndFile_VERSION") + +if(SndFileLegacy_FOUND AND NOT TARGET SndFile::sndfile) + add_library(SndFile::sndfile UNKNOWN IMPORTED) + set_target_properties( + SndFile::sndfile + PROPERTIES IMPORTED_LOCATION "${_sndfile_library}" + INTERFACE_COMPILE_OPTIONS "${_sndfile_compile_options}" + INTERFACE_INCLUDE_DIRECTORIES "${SndFile_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${_sndfile_link_libraries}" + INTERFACE_LINK_DIRECTORIES "${_sndfile_link_directories}") + + # Set additional variables for compatibility with upstream config + set(SNDFILE_FOUND TRUE) + set(SndFile_FOUND TRUE) + set(SndFile_LIBRARY SndFile::sndfile) + set(SndFile_LIBRARIES SndFile::sndfile) + set(SNDFILE_LIBRARY SndFile::sndfile) + set(SNDFILE_LIBRARIES SndFile::sndfile) + set(SNDFILE_INCLUDE_DIR "${SndFile_INCLUDE_DIR}") +endif() + +mark_as_advanced(_sndfile_library) diff --git a/cmake_admin/FindVorbis.cmake b/cmake_admin/FindVorbis.cmake new file mode 100644 index 000000000..0865c3ea2 --- /dev/null +++ b/cmake_admin/FindVorbis.cmake @@ -0,0 +1,127 @@ +#[=======================================================================[.rst: +FindVorbis +------- + +Finds the Vorbis library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``Vorbis::vorbisc`` + The Vorbis core library +``Vorbis::vorbisenc`` + The Vorbis encoder library +``Vorbis::vorbisfile`` + The Vorbis file library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``Vorbis_FOUND`` + True if all vorbis libraries were found. +``Vorbis_Vorbis_FOUND`` + True if the base vorbis library was found. +``Vorbis_Enc_FOUND`` + True if the encoder library was found. +``Vorbis_File_FOUND`` + True if the file library was found. + +#]=======================================================================] + +# Use pkg-config if available +find_package(PkgConfig QUIET) +pkg_check_modules(PC_VORBIS QUIET vorbis) +pkg_check_modules(PC_VORBISENC QUIET vorbisenc) +pkg_check_modules(PC_VORBISFILE QUIET vorbisfile) + +# Find the headers and libraries +find_path( + Vorbis_INCLUDE_DIR + NAMES "vorbis/codec.h" + HINTS "${PC_VORBIS_INCLUDEDIR}") + +find_library( + Vorbis_LIBRARY + NAMES "vorbis" + HINTS "${PC_VORBIS_LIBDIR}") + +find_library( + Vorbis_Enc_LIBRARY + NAMES "vorbisenc" + HINTS "${PC_VORBISENC_LIBDIR}") + +find_library( + Vorbis_File_LIBRARY + NAMES "vorbisfile" + HINTS "${PC_VORBISFILE_LIBDIR}") + +# Handle transitive dependencies +if(PC_VORBIS_FOUND) + get_target_properties_from_pkg_config("${Vorbis_LIBRARY}" "PC_VORBIS" + "_vorbis") +else() + if(NOT TARGET Ogg::ogg) + find_package(Ogg QUIET) + endif() + set(_vorbis_link_libraries "Ogg::ogg" ${MATH_LIBRARY}) +endif() + +# Extract additional flags if pkg-config is available +if(PC_VORBISENC_FOUND) + get_target_properties_from_pkg_config("${Vorbis_Enc_LIBRARY}" "PC_VORBISENC" + "_vorbis_enc") +endif() + +if(PC_VORBISFILE_FOUND) + get_target_properties_from_pkg_config("${Vorbis_File_LIBRARY}" + "PC_VORBISFILE" "_vorbis_file") +endif() + +# Forward the result to CMake +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + Vorbis REQUIRED_VARS "Vorbis_LIBRARY" "Vorbis_Enc_LIBRARY" + "Vorbis_File_LIBRARY" "Vorbis_INCLUDE_DIR") + +# Create the targets +if(Vorbis_FOUND AND NOT TARGET Vorbis::vorbis) + add_library(Vorbis::vorbis UNKNOWN IMPORTED) + set_target_properties( + Vorbis::vorbis + PROPERTIES IMPORTED_LOCATION "${Vorbis_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${_vorbis_compile_options}" + INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${_vorbis_link_libraries}" + INTERFACE_LINK_DIRECTORIES "${_vorbis_link_directories}") + set(Vorbis_Vorbis_FOUND TRUE) +endif() + +if(Vorbis_FOUND AND NOT TARGET Vorbis::vorbisenc) + add_library(Vorbis::vorbisenc UNKNOWN IMPORTED) + set_target_properties( + Vorbis::vorbisenc + PROPERTIES IMPORTED_LOCATION "${Vorbis_Enc_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${_vorbis_enc_compile_options}" + INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "Vorbis::vorbis" + INTERFACE_LINK_DIRECTORIES "${_vorbis_enc_link_directories}") + set(Vorbis_Enc_FOUND TRUE) +endif() + +if(Vorbis_FOUND AND NOT TARGET Vorbis::vorbisfile) + add_library(Vorbis::vorbisfile UNKNOWN IMPORTED) + set_target_properties( + Vorbis::vorbisfile + PROPERTIES IMPORTED_LOCATION "${Vorbis_File_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${_vorbis_file_compile_options}" + INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "Vorbis::vorbis" + INTERFACE_LINK_DIRECTORIES "${_vorbis_file_link_directories}") + set(Vorbis_File_FOUND TRUE) +endif() + +mark_as_advanced(Vorbis_LIBRARY Vorbis_Enc_LIBRARY Vorbis_File_LIBRARY) diff --git a/cmake_admin/Findmp3lame.cmake b/cmake_admin/Findmp3lame.cmake new file mode 100644 index 000000000..cd8b4c8a1 --- /dev/null +++ b/cmake_admin/Findmp3lame.cmake @@ -0,0 +1,63 @@ +#[=======================================================================[.rst: +Findmp3lame +------- + +Finds the mp3lame library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``mp3lame::mp3lame`` + The mp3lame library. +``mp3lame::mpghip`` + The mpghip library. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``mp3lame_FOUND`` + True if the mp3lame library was found. +``mp3lame_mpghip_FOUND`` + True if the mpghip library was found. + +#]=======================================================================] + +# Find the headers and libraries +find_path(mp3lame_INCLUDE_DIR NAMES "lame/lame.h") + +find_library(mp3lame_mp3lame_LIBRARY NAMES "mp3lame" "libmp3lame" + "libmp3lame-static") +find_library(mp3lame_mpghip_LIBRARY NAMES "mpghip" "libmpghip" + "libmpghip-static") + +# Forward the result to CMake +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + mp3lame REQUIRED_VARS "mp3lame_mp3lame_LIBRARY" + "mp3lame_INCLUDE_DIR") + +# Create the targets +if(mp3lame_FOUND AND NOT TARGET mp3lame::mp3lame) + add_library(mp3lame::mp3lame UNKNOWN IMPORTED) + set_target_properties( + mp3lame::mp3lame + PROPERTIES IMPORTED_LOCATION "${mp3lame_mp3lame_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${mp3lame_INCLUDE_DIR}") + set(mp3lame_mp3lame_FOUND TRUE) +endif() + +if(mp3lame_mpghip_LIBRARY AND NOT TARGET mp3lame::mpghip) + add_library(mp3lame::mpghip UNKNOWN IMPORTED) + set_target_properties( + mp3lame::mpghip + PROPERTIES IMPORTED_LOCATION "${mp3lame_mpghip_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${mp3lame_INCLUDE_DIR}") + set(mp3lame_mpghip_FOUND) +endif() + +mark_as_advanced(mp3lame_INCLUDE_DIR mp3lame_mp3lame_LIBRARY + mp3lame_mpghip_LIBRARY) diff --git a/cmake_admin/Findmpg123.cmake b/cmake_admin/Findmpg123.cmake new file mode 100644 index 000000000..3cb351679 --- /dev/null +++ b/cmake_admin/Findmpg123.cmake @@ -0,0 +1,108 @@ +#[=======================================================================[.rst: +Findmpg123 +------- + +Finds the mpg123 library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``MPG123::libmpg123`` + The mpg123 decoder library +``MPG123::libout123`` + The mpg123 output library +``MPG123::libsyn123`` + The mpg123 signal synthesis library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``mpg123_FOUND`` + True if the package was found. +``mpg123_libmpg123_FOUND`` + True if the decoder library was found. +``mpg123_libout123_FOUND`` + True if the output library was found. +``mpg123_libsyn123_FOUND`` + True if the signal synthesis library was found. + +#]=======================================================================] + +# Use pkg-config if available +find_package(PkgConfig QUIET) +pkg_check_modules(PC_MPG123 QUIET libmpg123) +pkg_check_modules(PC_OUT123 QUIET libout123) +pkg_check_modules(PC_SYN123 QUIET libsyn123) + +# Find the headers and libraries +find_path( + mpg123_INCLUDE_DIR + NAMES "mpg123.h" + HINTS "${PC_MPG123_INCLUDEDIR}") + +find_library( + mpg123_libmpg123_LIBRARY + NAMES "mpg123" + HINTS "${PC_MPG123_LIBDIR}") + +find_library( + mpg123_libout123_LIBRARY + NAMES "out123" + HINTS "${PC_OUT123_LIBDIR}") + +find_library( + mpg123_libsyn123_LIBRARY + NAMES "syn123" + HINTS "${PC_SYN123_LIBDIR}") + +# Extract additional flags if pkg-config is available +if(PC_MPG123_FOUND) + get_target_properties_from_pkg_config("${mpg123_libmpg123_LIBRARY}" + "PC_MPG123" "_libmpg123") +endif() +if(PC_OUT123_FOUND) + get_target_properties_from_pkg_config("${mpg123_libout123_LIBRARY}" + "PC_OUT123" "_libout123") +endif() +if(PC_SYN123_FOUND) + get_target_properties_from_pkg_config("${mpg123_libsyn123_LIBRARY}" + "PC_SYN123" "_libsyn123") +endif() + +# Mark which component were found +foreach(_component libmpg123 libout123 libsyn123) + if(mpg123_${_component}_LIBRARY) + set(mpg123_${_component}_FOUND TRUE) + else() + set(mpg123_${_component}_FOUND FALSE) + endif() +endforeach() + +# Forward the result to CMake +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + mpg123 + REQUIRED_VARS "mpg123_libmpg123_LIBRARY" "mpg123_INCLUDE_DIR" + HANDLE_COMPONENTS) + +# Create the targets +foreach(_component libmpg123 libout123 libsyn123) + if(mpg123_${_component}_FOUND AND NOT TARGET MPG123::${_component}) + add_library(MPG123::${_component} UNKNOWN IMPORTED) + set_target_properties( + MPG123::${_component} + PROPERTIES IMPORTED_LOCATION "${mpg123_${_component}_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${mpg123_INCLUDE_DIR}" + INTERFACE_COMPILE_OPTIONS "${_${_component}_compile_options}" + INTERFACE_LINK_LIBRARIES "${_${_component}_link_libraries}" + INTERFACE_LINK_DIRECTORIES + "${_${_component}_link_directories}") + endif() +endforeach() + +mark_as_advanced(mpg123_libmpg123_LIBRARY mpg123_libout123_LIBRARY + mpg123_libsyn123_LIBRARY mpg123_INCLUDE_DIR) diff --git a/cmake_admin/VersionInfo.in b/cmake_admin/VersionInfo.in deleted file mode 100644 index a6228b454..000000000 --- a/cmake_admin/VersionInfo.in +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once - -#ifndef PRODUCT_VERSION_MAJOR -#define PRODUCT_VERSION_MAJOR @PRODUCT_VERSION_MAJOR@ -#endif - -#ifndef PRODUCT_VERSION_MINOR -#define PRODUCT_VERSION_MINOR @PRODUCT_VERSION_MINOR@ -#endif - -#ifndef PRODUCT_VERSION_PATCH -#define PRODUCT_VERSION_PATCH @PRODUCT_VERSION_PATCH@ -#endif - -#ifndef PRODUCT_VERSION_BUILD -#define PRODUCT_VERSION_BUILD @PRODUCT_VERSION_REVISION@ -#endif - -#ifndef FILE_VERSION_MAJOR -#define FILE_VERSION_MAJOR @PRODUCT_VERSION_MAJOR@ -#endif - -#ifndef FILE_VERSION_MINOR -#define FILE_VERSION_MINOR @PRODUCT_VERSION_MINOR@ -#endif - -#ifndef FILE_VERSION_PATCH -#define FILE_VERSION_PATCH @PRODUCT_VERSION_PATCH@ -#endif - -#ifndef FILE_VERSION_BUILD -#define FILE_VERSION_BUILD @PRODUCT_VERSION_REVISION@ -#endif - -#ifndef __TO_STRING -#define __TO_STRING_IMPL(x) #x -#define __TO_STRING(x) __TO_STRING_IMPL(x) -#endif - -#define PRODUCT_VERSION_MAJOR_MINOR_STR __TO_STRING(PRODUCT_VERSION_MAJOR) "." __TO_STRING(PRODUCT_VERSION_MINOR) -#define PRODUCT_VERSION_MAJOR_MINOR_PATCH_STR PRODUCT_VERSION_MAJOR_MINOR_STR "." __TO_STRING(PRODUCT_VERSION_PATCH) -#define PRODUCT_VERSION_FULL_STR PRODUCT_VERSION_MAJOR_MINOR_PATCH_STR "." __TO_STRING(PRODUCT_VERSION_BUILD) -#define PRODUCT_VERSION_RESOURCE PRODUCT_VERSION_MAJOR,PRODUCT_VERSION_MINOR,PRODUCT_VERSION_PATCH,PRODUCT_VERSION_BUILD -#define PRODUCT_VERSION_RESOURCE_STR PRODUCT_VERSION_FULL_STR "\0" - -#define FILE_VERSION_MAJOR_MINOR_STR __TO_STRING(FILE_VERSION_MAJOR) "." __TO_STRING(FILE_VERSION_MINOR) -#define FILE_VERSION_MAJOR_MINOR_PATCH_STR FILE_VERSION_MAJOR_MINOR_STR "." __TO_STRING(FILE_VERSION_PATCH) -#define FILE_VERSION_FULL_STR FILE_VERSION_MAJOR_MINOR_PATCH_STR "." __TO_STRING(FILE_VERSION_BUILD) -#define FILE_VERSION_RESOURCE FILE_VERSION_MAJOR,FILE_VERSION_MINOR,FILE_VERSION_PATCH,FILE_VERSION_BUILD -#define FILE_VERSION_RESOURCE_STR FILE_VERSION_FULL_STR "\0" - -#ifndef PRODUCT_COMMENTS -#define PRODUCT_COMMENTS "@PRODUCT_COMMENTS@\0" -#endif - -#ifndef PRODUCT_COMPANY_NAME -#define PRODUCT_COMPANY_NAME "@PRODUCT_COMPANY_NAME@\0" -#endif - -#ifndef PRODUCT_COMPANY_COPYRIGHT -#define PRODUCT_COMPANY_COPYRIGHT "@PRODUCT_COMPANY_COPYRIGHT@\0" -#endif - -#ifndef PRODUCT_FILE_DESCRIPTION -#define PRODUCT_FILE_DESCRIPTION "@PRODUCT_FILE_DESCRIPTION@\0" -#endif - -#ifndef PRODUCT_INTERNAL_NAME -#define PRODUCT_INTERNAL_NAME "@PRODUCT_NAME@\0" -#endif - -#ifndef PRODUCT_ORIGINAL_FILENAME -#define PRODUCT_ORIGINAL_FILENAME "@PRODUCT_ORIGINAL_FILENAME@\0" -#endif - -#ifndef PRODUCT_BUNDLE -#define PRODUCT_BUNDLE "@PRODUCT_BUNDLE@\0" -#endif - diff --git a/cmake_admin/VersionResource.rc b/cmake_admin/VersionResource.rc deleted file mode 100644 index 27bc7b309..000000000 --- a/cmake_admin/VersionResource.rc +++ /dev/null @@ -1,37 +0,0 @@ -#include "VersionInfo.h" -#include "winver.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION FILE_VERSION_RESOURCE - PRODUCTVERSION PRODUCT_VERSION_RESOURCE - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - BEGIN - VALUE "Comments", PRODUCT_COMMENTS - VALUE "CompanyName", PRODUCT_COMPANY_NAME - VALUE "FileDescription", PRODUCT_FILE_DESCRIPTION - VALUE "FileVersion", FILE_VERSION_RESOURCE_STR - VALUE "InternalName", PRODUCT_INTERNAL_NAME - VALUE "LegalCopyright", PRODUCT_COMPANY_COPYRIGHT - VALUE "OriginalFilename", PRODUCT_ORIGINAL_FILENAME - VALUE "ProductName", PRODUCT_BUNDLE - VALUE "ProductVersion", PRODUCT_VERSION_RESOURCE_STR - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - diff --git a/cmake_admin/VersionResource.rc.in b/cmake_admin/VersionResource.rc.in new file mode 100644 index 000000000..2c941c336 --- /dev/null +++ b/cmake_admin/VersionResource.rc.in @@ -0,0 +1,35 @@ +#include "winver.h" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION @FLUIDSYNTH_VERSION_MAJOR@, @FLUIDSYNTH_VERSION_MINOR@, @FLUIDSYNTH_VERSION_MICRO@ +PRODUCTVERSION @FLUIDSYNTH_VERSION_MAJOR@, @FLUIDSYNTH_VERSION_MINOR@, @FLUIDSYNTH_VERSION_MICRO@, 0 +#ifdef DEBUG +FILEFLAGS VS_FF_DEBUG +#else +FILEFLAGS 0x0L +#endif +FILEOS VOS__WINDOWS32 +FILETYPE @TARGET_TYPE@ +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "FluidSynth" + VALUE "FileDescription", "FluidSynth - A Software Synthesizer" + VALUE "FileVersion", "@FLUIDSYNTH_VERSION_MAJOR@.@FLUIDSYNTH_VERSION_MINOR@.@FLUIDSYNTH_VERSION_MICRO@" + VALUE "Full Version", "@FLUIDSYNTH_VERSION_MAJOR@.@FLUIDSYNTH_VERSION_MINOR@.@FLUIDSYNTH_VERSION_MICRO@.0" + VALUE "InternalName", "FluidSynth" + VALUE "ProductName", "@PRODUCT_NAME@" + VALUE "LegalCopyright", "Copyright (C) 2003-2024 Peter Hanappe and others. Licensed under the terms of the LGPL v2.1" + VALUE "OriginalFilename", "@TARGET_FILENAME@" + VALUE "ProductVersion", "@FLUIDSYNTH_VERSION_MAJOR@.@FLUIDSYNTH_VERSION_MINOR@.@FLUIDSYNTH_VERSION_MICRO@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + diff --git a/cmake_admin/generate_product_version.cmake b/cmake_admin/generate_product_version.cmake deleted file mode 100644 index b91fab29f..000000000 --- a/cmake_admin/generate_product_version.cmake +++ /dev/null @@ -1,107 +0,0 @@ -include (CMakeParseArguments) - -set (GenerateProductVersionCurrentDir ${CMAKE_CURRENT_LIST_DIR}) - -# generate_product_version() function -# -# This function uses VersionInfo.in template file and VersionResource.rc file -# to generate WIN32 resource with version information and general resource strings. -# -# Usage: -# generate_product_version( -# SomeOutputResourceVariable -# NAME MyGreatProject -# ICON ${PATH_TO_APP_ICON} -# VERSION_MAJOR 2 -# VERSION_MINOR 3 -# VERSION_PATH ${BUILD_COUNTER} -# VERSION_REVISION ${BUILD_REVISION} -# ) -# where BUILD_COUNTER and BUILD_REVISION could be values from your CI server. -# -# You can use generated resource for your executable targets: -# add_executable(target-name ${target-files} ${SomeOutputResourceVariable}) -# -# You can specify resource strings in arguments: -# NAME - name of executable (no defaults, ex: Microsoft Word) -# BUNDLE - bundle (${NAME} is default, ex: Microsoft Office) -# ICON - path to application icon (${CMAKE_SOURCE_DIR}/product.ico by default) -# VERSION_MAJOR - 1 is default -# VERSION_MINOR - 0 is default -# VERSION_PATCH - 0 is default -# VERSION_REVISION - 0 is default -# COMPANY_NAME - your company name (no defaults) -# COMPANY_COPYRIGHT - ${COMPANY_NAME} (C) Copyright ${CURRENT_YEAR} is default -# COMMENTS - ${NAME} v${VERSION_MAJOR}.${VERSION_MINOR} is default -# ORIGINAL_FILENAME - ${NAME} is default -# INTERNAL_NAME - ${NAME} is default -# FILE_DESCRIPTION - ${NAME} is default -function(generate_product_version outfiles) - set (options) - set (oneValueArgs - NAME - BUNDLE - VERSION_MAJOR - VERSION_MINOR - VERSION_PATCH - VERSION_REVISION - COMPANY_NAME - COMPANY_COPYRIGHT - COMMENTS - ORIGINAL_FILENAME - INTERNAL_NAME - FILE_DESCRIPTION) - set (multiValueArgs) - cmake_parse_arguments(PRODUCT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (NOT PRODUCT_BUNDLE OR "${PRODUCT_BUNDLE}" STREQUAL "") - set(PRODUCT_BUNDLE "${PRODUCT_NAME}") - endif() -# if (NOT PRODUCT_ICON OR "${PRODUCT_ICON}" STREQUAL "") -# set(PRODUCT_ICON "${CMAKE_SOURCE_DIR}/product.ico") -# endif() - - if (NOT PRODUCT_VERSION_MAJOR OR "${PRODUCT_VERSION_MAJOR}" STREQUAL "") - set(PRODUCT_VERSION_MAJOR 1) - endif() - if (NOT PRODUCT_VERSION_MINOR OR "${PRODUCT_VERSION_MINOR}" STREQUAL "") - set(PRODUCT_VERSION_MINOR 0) - endif() - if (NOT PRODUCT_VERSION_PATCH OR "${PRODUCT_VERSION_PATCH}" STREQUAL "") - set(PRODUCT_VERSION_PATCH 0) - endif() - if (NOT PRODUCT_VERSION_REVISION OR "${PRODUCT_VERSION_REVISION}" STREQUAL "") - set(PRODUCT_VERSION_REVISION 0) - endif() - - if (NOT PRODUCT_COMPANY_COPYRIGHT OR "${PRODUCT_COMPANY_COPYRIGHT}" STREQUAL "") - string(TIMESTAMP PRODUCT_CURRENT_YEAR "%Y") - set(PRODUCT_COMPANY_COPYRIGHT "${PRODUCT_COMPANY_NAME} (C) Copyright ${PRODUCT_CURRENT_YEAR}") - endif() - if (NOT PRODUCT_COMMENTS OR "${PRODUCT_COMMENTS}" STREQUAL "") - set(PRODUCT_COMMENTS "${PRODUCT_NAME} v${PRODUCT_VERSION_MAJOR}.${PRODUCT_VERSION_MINOR}") - endif() - if (NOT PRODUCT_ORIGINAL_FILENAME OR "${PRODUCT_ORIGINAL_FILENAME}" STREQUAL "") - set(PRODUCT_ORIGINAL_FILENAME "${PRODUCT_NAME}") - endif() - if (NOT PRODUCT_INTERNAL_NAME OR "${PRODUCT_INTERNAL_NAME}" STREQUAL "") - set(PRODUCT_INTERNAL_NAME "${PRODUCT_NAME}") - endif() - if (NOT PRODUCT_FILE_DESCRIPTION OR "${PRODUCT_FILE_DESCRIPTION}" STREQUAL "") - set(PRODUCT_FILE_DESCRIPTION "${PRODUCT_NAME}") - endif() - - set (_VersionInfoFile ${CMAKE_CURRENT_BINARY_DIR}/VersionInfo.h) - set (_VersionResourceFile ${CMAKE_CURRENT_BINARY_DIR}/VersionResource.rc) - configure_file( - ${GenerateProductVersionCurrentDir}/VersionInfo.in - ${_VersionInfoFile} - @ONLY) - configure_file( - ${GenerateProductVersionCurrentDir}/VersionResource.rc - ${_VersionResourceFile} - COPYONLY) - list(APPEND ${outfiles} ${_VersionInfoFile} ${_VersionResourceFile}) - set (${outfiles} ${${outfiles}} PARENT_SCOPE) -endfunction() - diff --git a/doc/fluidsettings.xml b/doc/fluidsettings.xml index 84365fcea..d5a9572c0 100644 --- a/doc/fluidsettings.xml +++ b/doc/fluidsettings.xml @@ -348,7 +348,7 @@ Developers: 100.0 - Sets the stereo spread of the reverb signal. + Sets the stereo spread of the reverb signal. A value of 0 indicates no stereo-separation causing the reverb to sound like a monophonic signal. A value of 1 indicates maximum separation between the uncorrelated left and right channels (note that reverb is still a monophonic effect). This subrange [0;1] is recommended for general usage. Values bigger than 1 increase (or exaggerate) the perception of the uncorrelated left and right signals. Otherwise, this setting should be considered as dimensionless quantity, with its maximum value existing for historical reasons. Please note that under some circumstances, values bigger than 1 may induce a feedback into the signal which can be perceived as unpleasant. sample-rate diff --git a/doc/fluidsynth-v20-devdoc.txt b/doc/fluidsynth-v20-devdoc.txt index edf704875..3d794ee78 100644 --- a/doc/fluidsynth-v20-devdoc.txt +++ b/doc/fluidsynth-v20-devdoc.txt @@ -8,8 +8,8 @@ \author David Henningsson \author Tom Moebert \author Copyright © 2003-2024 Peter Hanappe, Conrad Berhörster, Antoine Schmitt, Pedro López-Cabanillas, Josh Green, David Henningsson, Tom Moebert -\version Revision 2.4.1 -\date 2024-12-01 +\version Revision 2.4.2 +\date 2024-12-30 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 https://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 https://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. diff --git a/include/fluidsynth/types.h b/include/fluidsynth/types.h index 9c2aaadac..09a850969 100644 --- a/include/fluidsynth/types.h +++ b/include/fluidsynth/types.h @@ -55,8 +55,6 @@ typedef struct _fluid_shell_t fluid_shell_t; /**< Command she typedef struct _fluid_server_t fluid_server_t; /**< TCP/IP shell server instance */ typedef struct _fluid_event_t fluid_event_t; /**< Sequencer event */ typedef struct _fluid_sequencer_t fluid_sequencer_t; /**< Sequencer instance */ -typedef struct _fluid_ramsfont_t fluid_ramsfont_t; /**< RAM SoundFont */ -typedef struct _fluid_rampreset_t fluid_rampreset_t; /**< RAM SoundFont preset */ typedef struct _fluid_cmd_handler_t fluid_cmd_handler_t; /**< Shell Command Handler */ typedef struct _fluid_ladspa_fx_t fluid_ladspa_fx_t; /**< LADSPA effects instance */ typedef struct _fluid_file_callbacks_t fluid_file_callbacks_t; /**< Callback struct to perform custom file loading of soundfonts */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 24bd2bac5..63d7282d2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ # FluidSynth - A Software Synthesizer # -# Copyright (C) 2003-2010 Peter Hanappe and others. +# Copyright (C) 2003-2024 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 @@ -211,20 +211,11 @@ configure_file ( ${FluidSynth_SOURCE_DIR}/include/fluidsynth.cmake ${public_main_HEADER} ) if ( WIN32 ) -include(generate_product_version) -generate_product_version( - VersionFilesOutputVariable - NAME "Fluidsynth" - BUNDLE "Fluidsynth" - VERSION_MAJOR ${FLUIDSYNTH_VERSION_MAJOR} - VERSION_MINOR ${FLUIDSYNTH_VERSION_MINOR} - VERSION_PATCH ${FLUIDSYNTH_VERSION_MICRO} - VERSION_REVISION 0 - COMMENTS "Fluidsynth" - COMPANY_NAME "Fluidsynth LGPL" - ORIGINAL_FILENAME "libfluidsynth.dll" - FILE_DESCRIPTION "Fluidsynth" -) + set(TARGET_TYPE "VFT_DLL") + set(TARGET_FILENAME "libfluidsynth-${LIB_VERSION_CURRENT}.dll") + set(PRODUCT_NAME "FluidSynth Library") + set(VersionFilesOutputVariable "${FluidSynth_BINARY_DIR}/src/VersionInfoLib.rc") + configure_file(${FluidSynth_SOURCE_DIR}/cmake_admin/VersionResource.rc.in ${VersionFilesOutputVariable} @ONLY) endif ( WIN32 ) add_library ( libfluidsynth-OBJ OBJECT @@ -447,8 +438,17 @@ if ( WASAPI_SUPPORT ) set ( fluidsynth_SOURCES ${fluidsynth_SOURCES} fluid_wasapi_device_enumerate.c ) endif ( WASAPI_SUPPORT ) +if ( WIN32 ) + set(TARGET_TYPE "VFT_APP") + set(TARGET_FILENAME "fluidsynth.exe") + set(PRODUCT_NAME "FluidSynth CLI") + set(VersionFilesOutputVariable "${FluidSynth_BINARY_DIR}/src/VersionInfo.rc") + configure_file(${FluidSynth_SOURCE_DIR}/cmake_admin/VersionResource.rc.in ${VersionFilesOutputVariable} @ONLY) +endif ( WIN32 ) + add_executable ( fluidsynth ${fluidsynth_SOURCES} + ${VersionFilesOutputVariable} ) set_target_properties ( fluidsynth diff --git a/src/drivers/fluid_winmidi.c b/src/drivers/fluid_winmidi.c index 2f5eefebe..077993346 100644 --- a/src/drivers/fluid_winmidi.c +++ b/src/drivers/fluid_winmidi.c @@ -498,8 +498,6 @@ static void fluid_winmidi_autoconnect_build_name(char *name) strncat(new_name, x, j); } - name[n - 1] = 0; - FLUID_MEMSET(name, 0, MAXPNAMELEN); FLUID_STRCPY(name, new_name); } diff --git a/src/rvoice/fluid_rev.c b/src/rvoice/fluid_rev.c index 11bc76083..727567a84 100644 --- a/src/rvoice/fluid_rev.c +++ b/src/rvoice/fluid_rev.c @@ -66,7 +66,8 @@ * - width (0 to 100): controls the left/right output separation. * When 0, there are no separation and the signal on left and right. * output is the same. This sounds like a monophonic signal. - * When 100, the separation between left and right is maximum. + * When 1, the separation between left and right is maximum. + * When 100 the perception of this separation is further "exaggerated". * * - level (0 to 1), controls the output level reverberation. * diff --git a/src/sfloader/fluid_sffile.c b/src/sfloader/fluid_sffile.c index 83594246d..21535c91c 100644 --- a/src/sfloader/fluid_sffile.c +++ b/src/sfloader/fluid_sffile.c @@ -669,6 +669,7 @@ static int process_info(SFData *sf, int size) sf->version.major = ver; READW(sf, ver); sf->version.minor = ver; + FLUID_LOG(FLUID_DBG, "SF Version: %hu.%hu", sf->version.major, sf->version.minor); if(sf->version.major < 2) { @@ -710,6 +711,7 @@ static int process_info(SFData *sf, int size) sf->romver.major = ver; READW(sf, ver); sf->romver.minor = ver; + FLUID_LOG(FLUID_DBG, "ROM Version: %hu.%hu", sf->version.major, sf->version.minor); } else if(chunkid(chunk.id) != UNKN_ID) { @@ -2219,21 +2221,23 @@ static int fluid_sffile_read_wav(SFData *sf, unsigned int start, unsigned int en goto error_exit; } + fluid_rec_mutex_lock(sf->mtx); + /* Load 16-bit sample data */ if(sf->fcbs->fseek(sf->sffd, sf->samplepos + (start * sizeof(short)), SEEK_SET) == FLUID_FAILED) { FLUID_LOG(FLUID_ERR, "Failed to seek to sample position"); - goto error_exit; + goto error_exit_unlock; } loaded_data = FLUID_ARRAY(short, num_samples); - if(loaded_data == NULL) { FLUID_LOG(FLUID_ERR, "Out of memory"); - goto error_exit; + goto error_exit_unlock; } + FLUID_LOG(FLUID_DBG, "ftell(): %llu, fread(): %ld bytes", sf->fcbs->ftell(sf->sffd), num_samples*sizeof(short)); if(sf->fcbs->fread(loaded_data, num_samples * sizeof(short), sf->sffd) == FLUID_FAILED) { #if FLUID_VERSION_CHECK(FLUIDSYNTH_VERSION_MAJOR, FLUIDSYNTH_VERSION_MINOR, FLUIDSYNTH_VERSION_MICRO) < FLUID_VERSION_CHECK(2,2,0) @@ -2245,9 +2249,11 @@ static int fluid_sffile_read_wav(SFData *sf, unsigned int start, unsigned int en } #endif FLUID_LOG(FLUID_ERR, "Failed to read sample data"); - goto error_exit; + goto error_exit_unlock; } + fluid_rec_mutex_unlock(sf->mtx); + /* If this machine is big endian, byte swap the 16 bit samples */ if(FLUID_IS_BIG_ENDIAN) { @@ -2272,37 +2278,44 @@ static int fluid_sffile_read_wav(SFData *sf, unsigned int start, unsigned int en goto error24_exit; } - if(sf->fcbs->fseek(sf->sffd, sf->sample24pos + start, SEEK_SET) == FLUID_FAILED) + loaded_data24 = FLUID_ARRAY(char, num_samples); + if(loaded_data24 == NULL) { - FLUID_LOG(FLUID_ERR, "Failed to seek position for 24-bit sample data in data file"); + FLUID_LOG(FLUID_ERR, "Out of memory reading 24-bit sample data"); goto error24_exit; } - loaded_data24 = FLUID_ARRAY(char, num_samples); + fluid_rec_mutex_lock(sf->mtx); - if(loaded_data24 == NULL) + if(sf->fcbs->fseek(sf->sffd, sf->sample24pos + start, SEEK_SET) == FLUID_FAILED) { - FLUID_LOG(FLUID_ERR, "Out of memory reading 24-bit sample data"); - goto error24_exit; + FLUID_LOG(FLUID_ERR, "Failed to seek position for 24-bit sample data in data file"); + goto error24_exit_unlock; } if(sf->fcbs->fread(loaded_data24, num_samples, sf->sffd) == FLUID_FAILED) { FLUID_LOG(FLUID_ERR, "Failed to read 24-bit sample data"); - goto error24_exit; + goto error24_exit_unlock; } + + fluid_rec_mutex_unlock(sf->mtx); } *data24 = loaded_data24; return num_samples; +error24_exit_unlock: + fluid_rec_mutex_unlock(sf->mtx); error24_exit: FLUID_LOG(FLUID_WARN, "Ignoring 24-bit sample data, sound quality might suffer"); FLUID_FREE(loaded_data24); *data24 = NULL; return num_samples; +error_exit_unlock: + fluid_rec_mutex_unlock(sf->mtx); error_exit: FLUID_FREE(loaded_data); FLUID_FREE(loaded_data24); diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index e356982ee..a342fad8f 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -5211,7 +5211,7 @@ fluid_synth_alloc_voice_LOCAL(fluid_synth_t *synth, fluid_sample_t *sample, int FLUID_LOG(FLUID_INFO, "noteon\t%d\t%d\t%d\t%05d\t%.3f\t%.3f\t%.3f\t%d", chan, key, vel, synth->storeid, - (float) ticks / 44100.0f, + (float) ticks / synth->sample_rate, (fluid_curtime() - synth->start) / 1000.0f, 0.0f, k); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4048aa076..0e2467ff0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -54,6 +54,9 @@ else() set(IIR_FILTER_RENDER_DIR "${CMAKE_CURRENT_BINARY_DIR}/manual/iir_filter") set(AWE32_NRPN_RENDER_DIR "${CMAKE_CURRENT_BINARY_DIR}/manual/awe32_nrpn") set(SFSPEC_RENDER_DIR "${CMAKE_CURRENT_BINARY_DIR}/manual/SoundFont-Spec-Test") + set(PORTAMENTO_RENDER_DIR "${CMAKE_CURRENT_BINARY_DIR}/manual/portamento") + set(REVERB_RENDER_DIR "${CMAKE_CURRENT_BINARY_DIR}/manual/reverb") + set(EXCL_RENDER_DIR "${CMAKE_CURRENT_BINARY_DIR}/manual/exclusive_class") if(LIBSNDFILE_SUPPORT) set(FEXT "wav") @@ -65,7 +68,7 @@ else() add_custom_target(check_manual) add_custom_target(create_iir_dir - COMMAND ${CMAKE_COMMAND} -E make_directory ${IIR_FILTER_RENDER_DIR} ${AWE32_NRPN_RENDER_DIR} ${SFSPEC_RENDER_DIR} + COMMAND ${CMAKE_COMMAND} -E make_directory ${IIR_FILTER_RENDER_DIR} ${AWE32_NRPN_RENDER_DIR} ${SFSPEC_RENDER_DIR} ${PORTAMENTO_RENDER_DIR} ${REVERB_RENDER_DIR} ${EXCL_RENDER_DIR} VERBATIM) add_custom_target(render1415 @@ -127,6 +130,23 @@ else() VERBATIM ) + add_custom_target(render1TOWOW + COMMAND fluidsynth -R 0 -C 0 -g 0.5 -F "${PORTAMENTO_RENDER_DIR}/1TOWOW_reduced_to_A3_C4.${FEXT}" "1TOWOW_reduced_to_A3_C4.mid" ${GENERAL_USER_GS2} + COMMAND fluidsynth -R 0 -C 0 -g 0.5 -F "${PORTAMENTO_RENDER_DIR}/1TOWOW.${FEXT}" "1TOWOW.MID" ${GENERAL_USER_GS2} + COMMENT "Rendering Portamento tests" + DEPENDS fluidsynth create_iir_dir + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/manual/portamento/ + VERBATIM + ) + + add_custom_target(renderDescent8 + COMMAND fluidsynth -R 1 -C 1 -g 0.5 -F ${PORTAMENTO_RENDER_DIR}/Game08.${FEXT} Game08.mid ${GENERAL_USER_GS2} + COMMENT "Rendering Descent Game 8" + DEPENDS fluidsynth create_iir_dir + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/manual/portamento/ + VERBATIM + ) + add_custom_target(renderSfSpecTest COMMAND fluidsynth -R 1 -C 1 -g 0.5 -F ${SFSPEC_RENDER_DIR}/sf_spec_test.${FEXT} sf_spec_test.mid sf_spec_test.sf2 COMMENT "Rendering Christian Collins' SF2 spec test" @@ -135,6 +155,43 @@ else() VERBATIM ) + add_custom_target(render1455 + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=0.0 -F ${REVERB_RENDER_DIR}/mrbumpys_rev_width_test_000.0.${FEXT} mrbumpys_rev_width_test.mid ${GENERAL_USER_GS2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=0.5 -F ${REVERB_RENDER_DIR}/mrbumpys_rev_width_test_000.5.${FEXT} mrbumpys_rev_width_test.mid ${GENERAL_USER_GS2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=1.0 -F ${REVERB_RENDER_DIR}/mrbumpys_rev_width_test_001.0.${FEXT} mrbumpys_rev_width_test.mid ${GENERAL_USER_GS2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=5.0 -F ${REVERB_RENDER_DIR}/mrbumpys_rev_width_test_005.0.${FEXT} mrbumpys_rev_width_test.mid ${GENERAL_USER_GS2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=10 -F ${REVERB_RENDER_DIR}/mrbumpys_rev_width_test_010.0.${FEXT} mrbumpys_rev_width_test.mid ${GENERAL_USER_GS2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=50 -F ${REVERB_RENDER_DIR}/mrbumpys_rev_width_test_050.0.${FEXT} mrbumpys_rev_width_test.mid ${GENERAL_USER_GS2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=100 -F ${REVERB_RENDER_DIR}/mrbumpys_rev_width_test_100.0.${FEXT} mrbumpys_rev_width_test.mid ${GENERAL_USER_GS2} + COMMENT "Rendering Christian Collins' reverb test issue 1455" + DEPENDS fluidsynth create_iir_dir + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/manual/reverb/ + VERBATIM + ) + + set(DK64SF2 "../sf2/ANMP-data/soundfonts/N64/DK64.sf2") + add_custom_target(renderDK64JJU + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=0.0 -F ${REVERB_RENDER_DIR}/DK64_sparse04_000.0.${FEXT} DK64_sparse04.mid ${DK64SF2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=0.5 -F ${REVERB_RENDER_DIR}/DK64_sparse04_000.5.${FEXT} DK64_sparse04.mid ${DK64SF2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=1.0 -F ${REVERB_RENDER_DIR}/DK64_sparse04_001.0.${FEXT} DK64_sparse04.mid ${DK64SF2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=5.0 -F ${REVERB_RENDER_DIR}/DK64_sparse04_005.0.${FEXT} DK64_sparse04.mid ${DK64SF2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=10 -F ${REVERB_RENDER_DIR}/DK64_sparse04_010.0.${FEXT} DK64_sparse04.mid ${DK64SF2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=50 -F ${REVERB_RENDER_DIR}/DK64_sparse04_050.0.${FEXT} DK64_sparse04.mid ${DK64SF2} + COMMAND fluidsynth -R 1 -C 0 -g 0.5 -o synth.reverb.width=100 -F ${REVERB_RENDER_DIR}/DK64_sparse04_100.0.${FEXT} DK64_sparse04.mid ${DK64SF2} + COMMENT "Praise Grant Kirkhope!" + DEPENDS fluidsynth create_iir_dir + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/manual/reverb/ + VERBATIM + ) + + add_custom_target(renderExcl + COMMAND fluidsynth -R 0 -C 0 -g 1.4 -F "${EXCL_RENDER_DIR}/exclusive class cutoff speed.${FEXT}" "exclusive class cutoff speed.mid" "exclusive class cutoff speed.sf2" + COMMENT "Rendering Christian Collins' exclusive class cutoff test" + DEPENDS fluidsynth create_iir_dir + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/manual/exclusive_class/ + VERBATIM + ) + # Add a dependency so that rendering targets depends on check_manual add_dependencies(check_manual render1415) add_dependencies(check_manual render1417) @@ -143,6 +200,11 @@ else() add_dependencies(check_manual renderAltitude) add_dependencies(check_manual renderFilter) add_dependencies(check_manual renderUplift) + add_dependencies(check_manual render1TOWOW) + add_dependencies(check_manual renderDescent8) add_dependencies(check_manual renderSfSpecTest) + add_dependencies(check_manual render1455) + add_dependencies(check_manual renderDK64JJU) + add_dependencies(check_manual renderExcl) endif() diff --git a/test/manual b/test/manual index bd8878c12..96459a15a 160000 --- a/test/manual +++ b/test/manual @@ -1 +1 @@ -Subproject commit bd8878c120beb6beb46726cdd83d258afe92cfe8 +Subproject commit 96459a15a26315810e80d7fd6e70bf18707d214b