Skip to content

Commit

Permalink
Enable LADSPA plugins on MSVC (#6973)
Browse files Browse the repository at this point in the history
Co-authored-by: Tres Finocchiaro <tres.finocchiaro@gmail.com>
Co-authored-by: Dominic Clark <mrdomclark@gmail.com>
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
  • Loading branch information
4 people authored May 13, 2024
1 parent 95e5f97 commit 36786dd
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 25 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
ENDIF()
ELSEIF(MSVC)
# Remove any existing /W flags
string(REGEX REPLACE "/W[0-4]" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
STRING(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
SET(WERROR_FLAGS "/W2")
IF(${USE_WERROR})
Expand Down
9 changes: 0 additions & 9 deletions cmake/modules/PluginList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,3 @@ IF(LIST_PLUGINS)
UNSET(LIST_PLUGINS CACHE)
LIST_ALL_PLUGINS()
ENDIF()

IF(MSVC)
SET(MSVC_INCOMPATIBLE_PLUGINS
LadspaEffect
)
message(WARNING "Compiling with MSVC. The following plugins are not available: ${MSVC_INCOMPATIBLE_PLUGINS}")
LIST(REMOVE_ITEM PLUGIN_LIST ${MSVC_INCOMPATIBLE_PLUGINS})
ENDIF()

11 changes: 10 additions & 1 deletion plugins/LadspaEffect/calf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET(INLINE_FLAGS -finline-functions-called-once -finline-limit=80)
SET(OTHER_FLAGS -Wno-format-overflow)
ENDIF()
target_compile_options(veal PRIVATE -fexceptions -O2 -finline-functions ${INLINE_FLAGS} ${OTHER_FLAGS})

if(MSVC)
target_compile_options(veal PRIVATE /wd4099 /wd4244 /wd4305)
else()
target_compile_options(veal PRIVATE -fexceptions -O2 -finline-functions ${INLINE_FLAGS} ${OTHER_FLAGS})
endif()

if(MSVC)
target_link_options(veal PRIVATE "/EXPORT:ladspa_descriptor")
endif()

if(LMMS_BUILD_WIN32)
add_custom_command(
Expand Down
12 changes: 11 additions & 1 deletion plugins/LadspaEffect/caps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ IF(LMMS_BUILD_WIN64)
ADD_DEFINITIONS(-DLMMS_BUILD_WIN64)
ENDIF(LMMS_BUILD_WIN64)
SET_TARGET_PROPERTIES(caps PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(caps PROPERTIES COMPILE_FLAGS "-O2 -funroll-loops -Wno-write-strings")

if(MSVC)
target_compile_options(caps PRIVATE /wd4244 /wd4305)
else()
target_compile_options(caps PRIVATE -O2 -funroll-loops -Wno-write-strings)
endif()

if(MSVC)
target_link_options(caps PRIVATE "/EXPORT:ladspa_descriptor")
endif()

IF(LMMS_BUILD_WIN32)
add_custom_command(
Expand All @@ -18,6 +27,7 @@ IF(LMMS_BUILD_WIN32)
COMMAND_EXPAND_LISTS
)
ENDIF(LMMS_BUILD_WIN32)

IF(NOT LMMS_BUILD_APPLE AND NOT LMMS_BUILD_OPENBSD)
SET_TARGET_PROPERTIES(caps PROPERTIES LINK_FLAGS "${LINK_FLAGS} -shared -Wl,-no-undefined")
ENDIF(NOT LMMS_BUILD_APPLE AND NOT LMMS_BUILD_OPENBSD)
Expand Down
5 changes: 4 additions & 1 deletion plugins/LadspaEffect/caps/basics.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#include <stdlib.h>
#include <string.h>

#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <math.h>

#include <assert.h>
Expand Down Expand Up @@ -76,7 +79,7 @@

#define MIN_GAIN .000001 /* -120 dB */

/* smallest non-denormal 32 bit IEEE float is 1.18×10-38 */
/* smallest non-denormal 32 bit IEEE float is 1.18×10^-38 */
#define NOISE_FLOOR .00000000000005 /* -266 dB */

typedef int8_t int8;
Expand Down
6 changes: 3 additions & 3 deletions plugins/LadspaEffect/caps/dsp/Eq.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ class Eq
{
public:
/* recursion coefficients, 3 per band */
eq_sample __attribute__ ((aligned)) a[Bands], b[Bands], c[Bands];
eq_sample a[Bands], b[Bands], c[Bands];
/* past outputs, 2 per band */
eq_sample __attribute__ ((aligned)) y[2][Bands];
eq_sample y[2][Bands];
/* current gain and recursion factor, each 1 per band = 2 */
eq_sample __attribute__ ((aligned)) gain[Bands], gf[Bands];
eq_sample gain[Bands], gf[Bands];
/* input history */
eq_sample x[2];
/* history index */
Expand Down
11 changes: 8 additions & 3 deletions plugins/LadspaEffect/caps/interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
(2541 - 2580 donated to artemio@kdemail.net)
*/

#include <sys/time.h>
// #include <sys/time.h>

#include "basics.h"

Expand Down Expand Up @@ -69,7 +69,6 @@ seed()

extern "C" {

__attribute__ ((constructor))
void caps_so_init()
{
DescriptorStub ** d = descriptors;
Expand Down Expand Up @@ -125,7 +124,6 @@ void caps_so_init()
//seed();
}

__attribute__ ((destructor))
void caps_so_fini()
{
for (ulong i = 0; i < N; ++i)
Expand All @@ -142,4 +140,11 @@ ladspa_descriptor (unsigned long i)
return 0;
}

struct CapsSoInit
{
CapsSoInit() { caps_so_init(); }
~CapsSoInit() { caps_so_fini(); }
};
static CapsSoInit capsSoInit;

}; /* extern "C" */
11 changes: 10 additions & 1 deletion plugins/LadspaEffect/cmt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ ADD_LIBRARY(cmt MODULE ${SOURCES})
INSTALL(TARGETS cmt LIBRARY DESTINATION "${PLUGIN_DIR}/ladspa")

SET_TARGET_PROPERTIES(cmt PROPERTIES PREFIX "")
target_compile_options(cmt PRIVATE -Wall -O3 -fno-strict-aliasing)

if(MSVC)
target_compile_options(cmt PRIVATE /wd4244 /wd4305)
else()
target_compile_options(cmt PRIVATE -Wall -O3 -fno-strict-aliasing)
endif()

if(LMMS_BUILD_WIN32)
add_custom_command(
Expand All @@ -17,6 +22,10 @@ if(LMMS_BUILD_WIN32)
)
endif()

if(MSVC)
target_link_options(cmt PRIVATE "/EXPORT:ladspa_descriptor")
endif()

if(NOT LMMS_BUILD_WIN32)
target_compile_options(cmt PRIVATE -fPIC)
endif()
Expand Down
2 changes: 1 addition & 1 deletion plugins/LadspaEffect/cmt/cmt
Submodule cmt updated 3 files
+1 −4 src/cmt.h
+1 −1 src/delay.cpp
+0 −4 src/init.cpp
14 changes: 11 additions & 3 deletions plugins/LadspaEffect/swh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ ELSE()
ENDIF()

# Additional compile flags
SET(COMPILE_FLAGS "${COMPILE_FLAGS} -O3 -Wall")
SET(COMPILE_FLAGS "${COMPILE_FLAGS} -fomit-frame-pointer -funroll-loops -ffast-math -c -fno-strict-aliasing")
SET(COMPILE_FLAGS "${COMPILE_FLAGS} ${PIC_FLAGS}")
if(MSVC)
set(COMPILE_FLAGS "${COMPILE_FLAGS} /wd4244 /wd4273 /wd4305")
else()
set(COMPILE_FLAGS "${COMPILE_FLAGS} -O3 -Wall")
set(COMPILE_FLAGS "${COMPILE_FLAGS} -fomit-frame-pointer -funroll-loops -ffast-math -c -fno-strict-aliasing")
set(COMPILE_FLAGS "${COMPILE_FLAGS} ${PIC_FLAGS}")
endif()

# Loop over every XML file
FILE(GLOB XML_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/ladspa/*.xml")
Expand All @@ -34,6 +38,10 @@ FOREACH(_item ${XML_SOURCES})
# Add a library target for this C file, which depends on success of makestup.pl
ADD_LIBRARY("${_plugin}" MODULE "${_out_file}")

if(MSVC)
target_link_options("${_plugin}" PRIVATE "/EXPORT:ladspa_descriptor")
endif()

# Vocoder does not use fftw
IF(NOT ("${_plugin}" STREQUAL "vocoder_1337"))
TARGET_LINK_LIBRARIES("${_plugin}" ${FFTW3F_LIBRARIES})
Expand Down
10 changes: 8 additions & 2 deletions plugins/LadspaEffect/tap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include")
FILE(GLOB PLUGIN_SOURCES tap-plugins/*.c)
LIST(SORT PLUGIN_SOURCES)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wno-write-strings -fomit-frame-pointer -fno-strict-aliasing -funroll-loops -ffast-math")
if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /fp:fast")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wno-write-strings -fomit-frame-pointer -fno-strict-aliasing -funroll-loops -ffast-math")
endif()
FOREACH(_item ${PLUGIN_SOURCES})
GET_FILENAME_COMPONENT(_plugin "${_item}" NAME_WE)
ADD_LIBRARY("${_plugin}" MODULE "${_item}")
if(MSVC)
target_link_options("${_plugin}" PRIVATE "/EXPORT:ladspa_descriptor")
endif()
# TAP pinknoise will re-init srand(); use existing seed instead
IF("${_plugin}" MATCHES "tap_pinknoise")
TARGET_COMPILE_DEFINITIONS("${_plugin}" PRIVATE TAP_DISABLE_SRAND=1)
Expand All @@ -24,4 +31,3 @@ FOREACH(_item ${PLUGIN_SOURCES})
TARGET_LINK_LIBRARIES("${_plugin}" m)
ENDIF()
ENDFOREACH()

0 comments on commit 36786dd

Please sign in to comment.