diff --git a/.travis/linux..before_install.sh b/.travis/linux..before_install.sh index 2603e72c0..adc892216 100755 --- a/.travis/linux..before_install.sh +++ b/.travis/linux..before_install.sh @@ -2,6 +2,7 @@ set -e +sudo add-apt-repository ppa:beineri/opt-qt58-trusty -y sudo add-apt-repository ppa:andrewrk/libgroove -y sudo sed -e "s/trusty/precise/" -i \ /etc/apt/sources.list.d/andrewrk-libgroove-trusty.list diff --git a/.travis/linux..install.sh b/.travis/linux..install.sh index 8abf83c24..a5fc3e4d5 100755 --- a/.travis/linux..install.sh +++ b/.travis/linux..install.sh @@ -3,7 +3,7 @@ set -e PACKAGES="cmake libsndfile-dev fftw3-dev libvorbis-dev libogg-dev libmp3lame-dev - libasound2-dev libjack-dev libsdl-dev libsamplerate0-dev libstk0-dev + libasound2-dev libjack-dev libsdl-dev libsamplerate0-dev libstk0-dev stk libfluidsynth-dev portaudio19-dev wine-dev g++-multilib libfltk1.3-dev libgig-dev libsoundio-dev" @@ -11,7 +11,7 @@ PACKAGES="cmake libsndfile-dev fftw3-dev libvorbis-dev libogg-dev libmp3lame-dev PACKAGES="$PACKAGES libjack0" if [ "$QT5" ]; then - PACKAGES="$PACKAGES qtbase5-dev qttools5-dev-tools qttools5-dev" + PACKAGES="$PACKAGES qt58base qt58translations qt58tools" else PACKAGES="$PACKAGES libqt4-dev" fi diff --git a/.travis/linux..script.sh b/.travis/linux..script.sh index d7059fe5f..f22991337 100755 --- a/.travis/linux..script.sh +++ b/.travis/linux..script.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash +if [ $QT5 ]; then + unset QTDIR QT_PLUGIN_PATH LD_LIBRARY_PATH + source /opt/qt58/bin/qt58-env.sh +fi set -e diff --git a/CMakeLists.txt b/CMakeLists.txt index 7969fd9b0..ee47d120e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ INCLUDE(FindPkgConfig) STRING(TOUPPER "${CMAKE_PROJECT_NAME}" PROJECT_NAME_UCASE) # Updated by maintenance tasks -SET(PROJECT_YEAR 2015) +SET(PROJECT_YEAR 2017) SET(PROJECT_AUTHOR "LMMS Developers") SET(PROJECT_URL "https://lmms.io") @@ -51,6 +51,7 @@ OPTION(WANT_CAPS "Include C* Audio Plugin Suite (LADSPA plugins)" ON) OPTION(WANT_CARLA "Include Carla plugin" ON) OPTION(WANT_CMT "Include Computer Music Toolkit LADSPA plugins" ON) OPTION(WANT_JACK "Include JACK (Jack Audio Connection Kit) support" ON) +OPTION(WANT_WEAKJACK "Loosely link JACK libraries" ON) OPTION(WANT_MP3LAME "Include MP3/Lame support" ON) OPTION(WANT_OGGVORBIS "Include OGG/Vorbis support" ON) OPTION(WANT_PULSEAUDIO "Include PulseAudio support" ON) @@ -85,12 +86,14 @@ IF(LMMS_BUILD_WIN32) SET(WANT_ALSA OFF) SET(WANT_JACK OFF) SET(WANT_PULSEAUDIO OFF) + SET(WANT_PORTAUDIO OFF) SET(WANT_SOUNDIO OFF) SET(WANT_WINMM ON) SET(LMMS_HAVE_WINMM TRUE) SET(STATUS_ALSA "") SET(STATUS_JACK "") SET(STATUS_PULSEAUDIO "") + SET(STATUS_PORTAUDIO "") SET(STATUS_SOUNDIO "") SET(STATUS_WINMM "OK") SET(STATUS_APPLEMIDI "") @@ -153,6 +156,9 @@ IF(WANT_QT5) Qt5::Xml ) + # Resolve Qt5::qmake to full path for use in packaging scripts + GET_TARGET_PROPERTY(QT_QMAKE_EXECUTABLE "${Qt5Core_QMAKE_EXECUTABLE}" IMPORTED_LOCATION) + FIND_PACKAGE(Qt5Test) SET(QT_QTTEST_LIBRARY Qt5::Test) ELSE() @@ -385,8 +391,16 @@ ENDIF(NOT LMMS_HAVE_ALSA) IF(WANT_JACK) PKG_CHECK_MODULES(JACK jack>=0.77) IF(JACK_FOUND) + IF(WANT_WEAKJACK) + SET(LMMS_HAVE_WEAKJACK TRUE) + SET(STATUS_JACK "OK (weak linking enabled)") + SET(JACK_INCLUDE_DIRS "") + # use dlsym instead + SET(JACK_LIBRARIES "dl") + ELSE() + SET(STATUS_JACK "OK") + ENDIF() SET(LMMS_HAVE_JACK TRUE) - SET(STATUS_JACK "OK") ELSE(JACK_FOUND) SET(STATUS_JACK "not found, please install libjack0.100.0-dev (or similar) " "if you require JACK support") @@ -445,7 +459,11 @@ IF(WANT_VST) FIND_PACKAGE(Wine) IF(WINE_FOUND) SET(LMMS_SUPPORT_VST TRUE) - SET(STATUS_VST "OK") + IF(WINE_LIBRARY_FIX) + SET(STATUS_VST "OK, with workaround linking ${WINE_LIBRARY_FIX}") + ELSE() + SET(STATUS_VST "OK") + ENDIF() ELSEIF(WANT_VST_NOWINE) SET(LMMS_SUPPORT_VST TRUE) SET(STATUS_VST "OK") diff --git a/cmake/linux/CMakeLists.txt b/cmake/linux/CMakeLists.txt index 78a7c541a..87f419405 100644 --- a/cmake/linux/CMakeLists.txt +++ b/cmake/linux/CMakeLists.txt @@ -1,4 +1,19 @@ -INSTALL(FILES lmms.png DESTINATION "${DATA_DIR}/pixmaps") -INSTALL(FILES lmms DESTINATION "${DATA_DIR}/menu") +INSTALL(FILES lmms.svg DESTINATION "${DATA_DIR}/icons/hicolor/scalable/apps") +INSTALL(FILES project.svg DESTINATION "${DATA_DIR}/icons/hicolor/scalable/mimetypes/" RENAME "application-x-lmms-project.svg") INSTALL(FILES lmms.desktop DESTINATION "${DATA_DIR}/applications") INSTALL(FILES lmms.xml DESTINATION "${DATA_DIR}/mime/packages") + +# AppImage creation target +SET(APPIMAGE_FILE "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}-linux-${CMAKE_SYSTEM_PROCESSOR}.AppImage") + +CONFIGURE_FILE("package_linux.sh.in" "${CMAKE_BINARY_DIR}/package_linux.sh" @ONLY) + +FILE(REMOVE "${APPIMAGE_FILE}") +ADD_CUSTOM_TARGET(removeappimage + COMMAND rm -f "${APPIMAGE_FILE}" + COMMENT "Removing old AppImage") +ADD_CUSTOM_TARGET(appimage + COMMAND chmod +x "${CMAKE_BINARY_DIR}/package_linux.sh" + COMMAND "${CMAKE_BINARY_DIR}/package_linux.sh" + COMMENT "Generating AppImage") +ADD_DEPENDENCIES(appimage removeappimage) diff --git a/cmake/linux/lmms b/cmake/linux/lmms index 274886185..884f0fed4 100644 --- a/cmake/linux/lmms +++ b/cmake/linux/lmms @@ -1,4 +1,4 @@ ?package(lmms):needs="X11" section="Apps/Sound" \ title="LMMS" hints="Audio" command="/usr/bin/lmms" \ longtitle="LMMS" \ - icon="/usr/share/pixmaps/lmms.png" + icon="/usr/share/icons/hicolor/scalable/apps/lmms.svg" diff --git a/cmake/linux/lmms.desktop b/cmake/linux/lmms.desktop index 6962ad403..0fb706a62 100644 --- a/cmake/linux/lmms.desktop +++ b/cmake/linux/lmms.desktop @@ -1,11 +1,11 @@ [Desktop Entry] Name=LMMS -GenericName=music production suite +GenericName=Music production suite GenericName[ca]=Programari de producció musical GenericName[de]=Software zur Musik-Produktion GenericName[fr]=Ensemble pour la production musicale GenericName[pl]=Narzędzia do produkcji muzyki -Comment=easy music production for everyone! +Comment=Music sequencer and synthesizer Comment[ca]=Producció fàcil de música per a tothom! Comment[fr]=Production facile de musique pour tout le monde ! Comment[pl]=Prosta produkcja muzyki dla każdego! diff --git a/cmake/linux/lmms.svg b/cmake/linux/lmms.svg new file mode 100644 index 000000000..ffe6976ce --- /dev/null +++ b/cmake/linux/lmms.svg @@ -0,0 +1,1540 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cmake/linux/lmms.xml b/cmake/linux/lmms.xml index 016751560..579c3f12f 100644 --- a/cmake/linux/lmms.xml +++ b/cmake/linux/lmms.xml @@ -4,11 +4,7 @@ LMMS project Projecte LMMS - - - - - + diff --git a/cmake/linux/package_linux.sh.in b/cmake/linux/package_linux.sh.in new file mode 100644 index 000000000..275baba35 --- /dev/null +++ b/cmake/linux/package_linux.sh.in @@ -0,0 +1,170 @@ +#!/usr/bin/env bash +# Creates Linux ".AppImage" for @PROJECT_NAME_UCASE@ +# +# Depends: linuxdeployqt +# +# Notes: Will attempt to fetch linuxdeployqt automatically (x86_64 only) +# See Also: https://github.com/probonopd/linuxdeployqt/blob/master/BUILDING.md + +set -e + +USERBIN="$HOME/bin" +LINUXDEPLOYQT="$USERBIN/linuxdeployqt" +APPIMAGETOOL="$USERBIN/appimagetool" +VERBOSITY=2 # 3=debug +LOGFILE="@CMAKE_BINARY_DIR@/appimage.log" +APPDIR="@CMAKE_BINARY_DIR@/@PROJECT_NAME_UCASE@.AppDir/" +DESKTOPFILE="${APPDIR}usr/share/applications/lmms.desktop" +STRIP="" + +# Don't strip for Debug|RelWithDebInfo builds +if [[ "@CMAKE_BUILD_TYPE@" == *"Deb"* ]]; then + STRIP="-no-strip" +fi + +# Console colors +RED="\\x1B[1;31m" +GREEN="\\x1B[1;32m" +YELLOW="\\x1B[1;33m" +PLAIN="\\x1B[0m" + +function error { + echo -e " ${PLAIN}[${RED}error${PLAIN}] ${1}" + return 1 +} + +function success { + echo -e " ${PLAIN}[${GREEN}success${PLAIN}] ${1}" +} + +function skipped { + echo -e " ${PLAIN}[${YELLOW}skipped${PLAIN}] ${1}" +} + + +# Check for problematic install locations +INSTALL=$(echo "@CMAKE_INSTALL_PREFIX@" | sed 's/\/*$//g') +if [ "$INSTALL" == "/usr/local" ] || [ "$INSTALL" == "/usr" ] ; then + error "Incompatible CMAKE_INSTALL_PREFIX for creating AppImage: @CMAKE_INSTALL_PREFIX@" +fi + +echo -e "\nWriting verbose output to \"${LOGFILE}\"" + +# Ensure linuxdeployqt uses the same qmake version as cmake +export PATH="$(dirname "@QT_QMAKE_EXECUTABLE@")":$PATH + +# Fetch portable linuxdeployqt if cache is older than $DAYSOLD +echo -e "\nDownloading linuxdeployqt to ${LINUXDEPLOYQT}..." +mkdir -p "$HOME/bin" +DAYSOLD=2 +if env -i which linuxdeployqt > /dev/null 2>&1; then + skipped "System already provides this utility" +elif ! find "$LINUXDEPLOYQT" -mtime -$DAYSOLD 2>/dev/null|grep -q "." > /dev/null 2>&1; then + url="https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-$(uname -p).AppImage" + echo " [.......] Couldn't find linuxdeployqt newer than $DAYSOLD days old" + echo " [.......] Downloading ($(uname -p)): ${url}" + wget "$url" -O "$LINUXDEPLOYQT" -q || (rm "$LINUXDEPLOYQT" && false) + chmod +x "$LINUXDEPLOYQT" + touch "$LINUXDEPLOYQT" + success "Downloaded $LINUXDEPLOYQT" + "$LINUXDEPLOYQT" --appimage-extract > /dev/null 2>&1 + mv "squashfs-root/usr/bin/appimagetool" "$APPIMAGETOOL" + success "Extracted $APPIMAGETOOL" + mv "squashfs-root/usr/bin/mksquashfs" "$USERBIN/mksquashfs" + success "Extracted $USERBIN/mksquashfs" + rm -rf "squashfs-root/" + +else + skipped "$LINUXDEPLOYQT is less than $DAYSOLD days old" +fi + +# Make skeleton AppDir +echo -e "\nCreating ${APPDIR}..." +rm -rf "${APPDIR}" +mkdir -p "${APPDIR}usr" +success "Created ${APPDIR}" + +# Clone install to AppDir +echo -e "\nCopying @CMAKE_INSTALL_PREFIX@ to ${APPDIR}..." +cp -R "@CMAKE_INSTALL_PREFIX@/." "${APPDIR}usr" +rm -rf "${APPDIR}usr/include" +success "${APPDIR}" + +# Copy rawwaves directory for stk/mallets +mkdir -p "${APPDIR}usr/share/stk/" +cp -R /usr/share/stk/rawwaves/ "${APPDIR}usr/share/stk/" + +# Create a wrapper script which calls the lmms executable +mv "${APPDIR}usr/bin/lmms" "${APPDIR}usr/bin/lmms.real" +# shellcheck disable=SC1083 +cat >"${APPDIR}usr/bin/lmms" < /dev/null 2>&1; then + echo "VirtualBox detected. Forcing libgl software rendering." + export LIBGL_ALWAYS_SOFTWARE=1; +fi +QT_X11_NO_NATIVE_MENUBAR=1 QT_AUTO_SCREEN_SCALE_FACTOR=1 \$DIR/usr/bin/lmms.real "\$@" +EOL + +chmod +x "${APPDIR}usr/bin/lmms" + +# Per https://github.com/probonopd/linuxdeployqt/issues/129 +unset LD_LIBRARY_PATH + +# Ensure linuxdeployqt can find shared objects +export LD_LIBRARY_PATH="${APPDIR}usr/lib/lmms/":$LD_LIBRARY_PATH + +# Handle wine linking +if [ -d "@WINE_LIBRARY_FIX@" ]; then + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:@WINE_LIBRARY_FIX@:@WINE_LIBRARY_FIX@wine/ +fi + +# Move executables so linuxdeployqt can find them +ZYNLIB="${APPDIR}usr/lib/lmms/RemoteZynAddSubFx" +VSTLIB="${APPDIR}usr/lib/lmms/RemoteVstPlugin.exe.so" + +ZYNBIN="${APPDIR}usr/bin/RemoteZynAddSubFx" +VSTBIN="${APPDIR}usr/bin/RemoteVstPlugin.exe.so" + +mv "$ZYNLIB" "$ZYNBIN" +mv "$VSTLIB" "$VSTBIN" + +# Patch the desktop file +sed -i 's/.*Exec=.*/Exec=lmms.real/' "$DESKTOPFILE" + +# Fix linking for soft-linked plugins +for file in "${APPDIR}usr/lib/lmms/"*.so; do + thisfile="${APPDIR}usr/lib/lmms/${file##*/}" + executables="${executables} -executable=$thisfile" +done +executables="${executables} -executable=${ZYNBIN}" +executables="${executables} -executable=${VSTBIN}" +executables="${executables} -executable=${APPDIR}usr/lib/lmms/ladspa/imp_1199.so" +executables="${executables} -executable=${APPDIR}usr/lib/lmms/ladspa/imbeq_1197.so" +executables="${executables} -executable=${APPDIR}usr/lib/lmms/ladspa/pitch_scale_1193.so" +executables="${executables} -executable=${APPDIR}usr/lib/lmms/ladspa/pitch_scale_1194.so" + +# Bundle both qt and non-qt dependencies into appimage format +echo -e "\nBundling and relinking system dependencies..." +echo -e ">>>>> linuxdeployqt" > "$LOGFILE" +# shellcheck disable=SC2086 +"$LINUXDEPLOYQT" "$DESKTOPFILE" $executables -bundle-non-qt-libs -verbose=$VERBOSITY $STRIP >> "$LOGFILE" 2>&1 +success "Bundled and relinked dependencies" + +# Link to original location so lmms can find them +ln -sr "$ZYNBIN" "$ZYNLIB" +ln -sr "$VSTBIN" "$VSTLIB" + +# Remove wine library conflict +rm -f "${APPDIR}/usr/lib/libwine.so.1" + +# Create AppImage +echo -e "\nFinishing the AppImage..." +echo -e "\n\n>>>>> appimagetool" >> "$LOGFILE" +"$APPIMAGETOOL" "${APPDIR}" "@APPIMAGE_FILE@" >> "$LOGFILE" 2>&1 +success "Created @APPIMAGE_FILE@" + +echo -e "\nFinished" diff --git a/data/application-x-lmms-project.svg b/cmake/linux/project.svg similarity index 100% rename from data/application-x-lmms-project.svg rename to cmake/linux/project.svg diff --git a/cmake/modules/FindWine.cmake b/cmake/modules/FindWine.cmake index 8dae6f2eb..1ac4087fb 100644 --- a/cmake/modules/FindWine.cmake +++ b/cmake/modules/FindWine.cmake @@ -16,6 +16,26 @@ FIND_PROGRAM(WINE_CXX NAMES wineg++ winegcc winegcc64 winegcc32) SET(WINE_INCLUDE_DIRS ${WINE_INCLUDE_DIR} ) SET(WINE_LIBRARIES ${WINE_LIBRARY} ) +# Handle wine linking problems +EXEC_PROGRAM(${WINE_CXX} ARGS "-v -m32 /dev/zero" OUTPUT_VARIABLE WINEBUILD_OUTPUT) + +# Debian systems +IF("${WINEBUILD_OUTPUT}" MATCHES ".*x86_64-linux-gnu/wine/libwinecrt0.a.*") + SET(WINE_LIBRARY_FIX "/usr/lib/i386-linux-gnu/" ) +# Fedora systems +ELSEIF("${WINEBUILD_OUTPUT}" MATCHES "/usr/lib/lib64/wine/libwinecrt0.a.*") + SET(WINE_LIBRARY_FIX "/usr/lib/i386/") +# Wine stable +ELSEIF("${WINEBUILD_OUTPUT}" MATCHES "/opt/wine-stable/lib64/wine/libwinecrt0.a.*") + SET(WINE_LIBRARY_FIX "/opt/wine-stable/lib/") +# Wine development +ELSEIF("${WINEBUILD_OUTPUT}" MATCHES "/opt/wine-devel/lib64/wine/libwinecrt0.a.*") + SET(WINE_LIBRARY_FIX "/opt/wine-devel/lib/") +# Wine staging +ELSEIF("${WINEBUILD_OUTPUT}" MATCHES "/opt/wine-staging/lib64/wine/libwinecrt0.a.*") + SET(WINE_LIBRARY_FIX "/opt/wine-staging/lib/") +ENDIF() + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Wine DEFAULT_MSG WINE_LIBRARIES WINE_INCLUDE_DIRS) diff --git a/data/themes/default/lcd_19green.png b/data/themes/default/lcd_19green.png index 437ac8baf..708987c34 100644 Binary files a/data/themes/default/lcd_19green.png and b/data/themes/default/lcd_19green.png differ diff --git a/data/themes/default/lcd_19red.png b/data/themes/default/lcd_19red.png index 0bd8817de..e4c4a1f72 100644 Binary files a/data/themes/default/lcd_19red.png and b/data/themes/default/lcd_19red.png differ diff --git a/data/themes/default/lcd_21pink.png b/data/themes/default/lcd_21pink.png index 64ec75e33..c2009eeda 100644 Binary files a/data/themes/default/lcd_21pink.png and b/data/themes/default/lcd_21pink.png differ diff --git a/include/AudioJack.h b/include/AudioJack.h index 7069a0691..9bbb3bd48 100644 --- a/include/AudioJack.h +++ b/include/AudioJack.h @@ -28,7 +28,11 @@ #include "lmmsconfig.h" #ifdef LMMS_HAVE_JACK +#ifndef LMMS_HAVE_WEAKJACK #include +#else +#include "AudioWeakJack.h" +#endif #include #include diff --git a/include/AudioWeakJack.def b/include/AudioWeakJack.def new file mode 100644 index 000000000..1684a56b0 --- /dev/null +++ b/include/AudioWeakJack.def @@ -0,0 +1,159 @@ +/* macro-absraction of the JACK API + * + * see weak_libjack.c for details, in general arguments are: + * + * [required], [return type], [name], [arguments], [code or return value] + * + * This file is included multiple times with different macro definitions + * do not add header guards. + * see https://en.wikibooks.org/wiki/C_Programming/Preprocessor#X-Macros + */ + +#ifdef USE_WEAK_JACK + +/* */ +JCFUN(1, int, client_close, 0) +JCFUN(1, char*, get_client_name, NULL) +JVFUN(0, on_shutdown, (jack_client_t *c, JackShutdownCallback s, void *a), (c,s,a),) +JVFUN(0, on_info_shutdown, (jack_client_t *c, JackInfoShutdownCallback s, void *a), (c,s,a),) + +JPFUN(1, int, set_process_callback, (jack_client_t *c, JackProcessCallback p, void *a), (c,p,a), -1) +JPFUN(1, int, set_freewheel_callback, (jack_client_t *c, JackFreewheelCallback p, void *a), (c,p,a), -1) +JPFUN(1, int, set_buffer_size_callback, (jack_client_t *c, JackBufferSizeCallback p, void *a), (c,p,a), -1) +JPFUN(1, int, set_sample_rate_callback, (jack_client_t *c, JackSampleRateCallback p, void *a), (c,p,a), -1) +JPFUN(1, int, set_port_registration_callback, (jack_client_t *c, JackPortRegistrationCallback p, void *a), (c,p,a), -1) +JPFUN(1, int, set_port_connect_callback, (jack_client_t *c, JackPortConnectCallback p, void *a), (c,p,a), -1) +JPFUN(1, int, set_graph_order_callback, (jack_client_t *c, JackGraphOrderCallback g, void *a), (c,g,a), -1) +JPFUN(1, int, set_xrun_callback, (jack_client_t *c, JackXRunCallback g, void *a), (c,g,a), -1) +JPFUN(1, int, set_latency_callback, (jack_client_t *c, JackLatencyCallback g, void *a), (c,g,a), -1) +JVFUN(1, set_error_function, (void (*f)(const char *)), (f),) +JVFUN(1, set_info_function, (void (*f)(const char *)), (f),) + +JCFUN(1, int, activate, -1) +JCFUN(1, int, deactivate, -1) + +JPFUN(1, int, client_name_size, (), (), 32) + +JCFUN(1, jack_nframes_t, get_sample_rate, 0) +JCFUN(1, jack_nframes_t, get_buffer_size, 0) +JPFUN(1, jack_nframes_t, frames_since_cycle_start, (const jack_client_t *c), (c), 0) +JPFUN(1, jack_nframes_t, frame_time, (const jack_client_t *c), (c), 0) +JPFUN(1, jack_nframes_t, last_frame_time, (const jack_client_t *c), (c), 0) +JPFUN(1, jack_time_t, get_time, (void), (), 0) +JCFUN(1, float, cpu_load, 0) +JCFUN(1, int, is_realtime, 0) + +JPFUN(1, int, set_freewheel, (jack_client_t *c, int o), (c,o), 0) +JPFUN(1, int, set_buffer_size, (jack_client_t *c, jack_nframes_t b), (c,b), 0) + +JCFUN(0, int, recompute_total_latencies, 0) +JPFUN(0, jack_nframes_t, port_get_total_latency, (jack_client_t *c, jack_port_t *p), (c,p), 0) +JVFUN(0, port_get_latency_range, (jack_port_t *p, jack_latency_callback_mode_t m, jack_latency_range_t *r), (p,m,r), if (r) {r->min = r->max = 0;}) +JVFUN(0, port_set_latency_range, (jack_port_t *p, jack_latency_callback_mode_t m, jack_latency_range_t *r), (p,m,r),) + +JPFUN(1, void*, port_get_buffer, (jack_port_t *p, jack_nframes_t n), (p,n), NULL) +JPFUN(1, int, port_request_monitor, (jack_port_t *p, int o), (p,o), 0) +JPFUN(1, int, port_ensure_monitor, (jack_port_t *p, int o), (p,o), 0) +JPFUN(1, int, port_monitoring_input, (jack_port_t *p), (p), 0) + +JPFUN(1, const char*, port_name, (const jack_port_t *p), (p), NULL) +JPFUN(1, const char*, port_short_name, (const jack_port_t *p), (p), NULL) +JPFUN(1, int, port_flags, (const jack_port_t *p), (p), 0) +JPFUN(1, const char**, get_ports,(jack_client_t *c, const char *p, const char *t, unsigned long f), (c,p,t,f), NULL) +JPFUN(1, int, port_name_size, (void), (), 0) +JPFUN(1, int, port_type_size, (void), (), 0) +JPFUN(1, size_t, port_type_get_buffer_size, (jack_client_t *c, const char *t), (c,t), 0) +JPFUN(1, jack_port_t*, port_by_name, (jack_client_t *c, const char *n), (c,n), NULL) +JPFUN(1, jack_port_t*, port_by_id, (jack_client_t *c, jack_port_id_t i), (c,i), NULL) +JPFUN(1, jack_port_t*, port_register, (jack_client_t *c, const char *n, const char *t, unsigned long f, unsigned long b), (c,n,t,f,b), NULL) +JPFUN(1, int, port_unregister, (jack_client_t *c, jack_port_t *p), (c,p), 0) +JPFUN(1, const char *, port_type, (const jack_port_t *p), (p), 0) +JPFUN(1, const char **, port_get_connections, (const jack_port_t *p), (p), 0) +JPFUN(1, const char **, port_get_all_connections, (const jack_client_t *c, const jack_port_t *p), (c,p), 0) +JPFUN(1, int, port_set_name, (jack_port_t *p, const char *n), (p,n), -1) +JXFUN(0, int, port_rename, (jack_client_t *c, jack_port_t *p, const char *n), (c,p,n), return jack_port_set_name (p,n);) +JPFUN(1, int, port_get_aliases, (const jack_port_t *port, char* const aliases[2]), (port,aliases), 0) +JPFUN(1, int, port_disconnect, (jack_client_t *c, jack_port_t *p), (c,p), 0) +JPFUN(1, int, connect, (jack_client_t *c, const char *s, const char *d), (c,s,d), -1) +JPFUN(1, int, disconnect, (jack_client_t *c, const char *s, const char *d), (c,s,d), -1) +JVFUN(0, free, (void *p), (p), free(p);) + +JCFUN(1, jack_nframes_t, cycle_wait, 0) +JVFUN(1, cycle_signal, (jack_client_t *c, int s), (c,s),) +JPFUN(1, int, set_process_thread, (jack_client_t *c, JackThreadCallback p, void *a), (c,p,a), -1) +JPFUN(1, int, set_thread_init_callback, (jack_client_t *c, JackThreadInitCallback p, void *a), (c,p,a), -1) + +JPFUN(1, int, transport_locate, (jack_client_t *c, jack_nframes_t f), (c,f), 0) +JVFUN(1, transport_start, (jack_client_t *c), (c),) +JVFUN(1, transport_stop, (jack_client_t *c), (c),) +JPFUN(1, jack_nframes_t, get_current_transport_frame, (const jack_client_t *c), (c), 0) +JXFUN(1, jack_transport_state_t, transport_query, (const jack_client_t *c, jack_position_t *p), (c,p), memset(p, 0, sizeof(jack_position_t)); return JackTransportStopped;) +JPFUN(1, int, set_sync_callback, (jack_client_t *c, JackSyncCallback p, void *a), (c,p,a), -1) +JPFUN(1, int, set_timebase_callback, (jack_client_t *c, int l, JackTimebaseCallback p, void *a), (c,l,p,a), -1) +JCFUN(1, int, release_timebase, 0) + +/* */ +JPFUN(1, uint32_t, midi_get_event_count, (void* p), (p), 0) +JPFUN(1, int, midi_event_get, (jack_midi_event_t *e, void *p, uint32_t i), (e,p,i), -1) +JPFUN(1, int, midi_event_write, (void *b, jack_nframes_t t, const jack_midi_data_t *d, size_t s), (b,t,d,s), -1) +JVFUN(1, midi_clear_buffer, (void *b), (b),) + +/* */ +JPFUN(0, int, set_session_callback, (jack_client_t *c, JackSessionCallback s, void *a), (c,s,a), -1) +JPFUN(0, int, session_reply, (jack_client_t *c, jack_session_event_t *e), (c,e), -1) +JVFUN(0, session_event_free, (jack_session_event_t *e), (e), ) + +/* */ +JPFUN(1, jack_ringbuffer_t *, ringbuffer_create, (size_t s), (s), NULL) +JVFUN(1, ringbuffer_free, (jack_ringbuffer_t *rb), (rb), ) +JVFUN(1, ringbuffer_reset, (jack_ringbuffer_t *rb), (rb), ) +JVFUN(1, ringbuffer_read_advance, (jack_ringbuffer_t *rb, size_t c), (rb,c), ) +JVFUN(1, ringbuffer_write_advance, (jack_ringbuffer_t *rb, size_t c), (rb,c), ) +JPFUN(1, size_t, ringbuffer_read_space, (const jack_ringbuffer_t *rb), (rb), 0) +JPFUN(1, size_t, ringbuffer_write_space, (const jack_ringbuffer_t *rb), (rb), 0) +JPFUN(1, size_t, ringbuffer_read, (jack_ringbuffer_t *rb, char *d, size_t c), (rb,d,c), 0) +JPFUN(1, size_t, ringbuffer_write, (jack_ringbuffer_t *rb, const char *s, size_t c), (rb,s,c), 0) +JPFUN(0, int, ringbuffer_mlock, (jack_ringbuffer_t *rb), (rb), 0) +JVFUN(0, ringbuffer_get_read_vector, (const jack_ringbuffer_t *rb, jack_ringbuffer_data_t *v), (rb,v), if (v) {v->buf=NULL; v->len=0;} ) +JVFUN(0, ringbuffer_get_write_vector, (const jack_ringbuffer_t *rb, jack_ringbuffer_data_t *v), (rb,v), if (v) {v->buf=NULL; v->len=0;} ) +JPFUN(0, size_t, ringbuffer_peek, (jack_ringbuffer_t *rb, char *d, size_t c), (rb,d,c), 0) + +/* */ +JCFUN(0, int, client_real_time_priority, 0) +JCFUN(0, int, client_max_real_time_priority, 0) +JPFUN(0, int, acquire_real_time_scheduling, (jack_native_thread_t t, int p), (t,p), 0) +JPFUN(0, int, drop_real_time_scheduling, (jack_native_thread_t t), (t), 0) +JPFUN(0, int, client_stop_thread, (jack_client_t* c, jack_native_thread_t t), (c,t), 0) +JPFUN(0, int, client_kill_thread, (jack_client_t* c, jack_native_thread_t t), (c,t), 0) +#ifndef _WIN32 +JVFUN(0, set_thread_creator, (jack_thread_creator_t c), (c),) +#endif +JPFUN(1, int, client_create_thread, \ + (jack_client_t* c, jack_native_thread_t *t, int p, int r, void *(*f)(void*), void *a), (c,t,p,r,f,a), 0) + +#ifndef NO_JACK_METADATA +/* - TODO*/ + +/* */ +JPFUN(0, char *, get_uuid_for_client_name, (jack_client_t* c, const char* n), (c,n), NULL) +JPFUN(0, char *, get_client_name_by_uuid, (jack_client_t* c, const char* u), (c,u), NULL) +JPFUN(0, jack_uuid_t, port_uuid, (const jack_port_t *p), (p), 0) + +/* */ +JPFUN(0, int, set_property, (jack_client_t* c, jack_uuid_t s, const char* k, const char* v, const char* t), (c,s,k,v,t), -1) +JXFUN(0, int, get_property, (jack_uuid_t s, const char* k, char** v, char** t), (s,k,v,t), if (v) *v=NULL; if (t) *t=NULL; return -1;) +JVFUN(0, free_description, (jack_description_t* d, int f), (d,f),) +JXFUN(0, int, get_properties, (jack_uuid_t s, jack_description_t* d), (s,d), if (d) {d->properties = NULL; d->property_cnt = 0;} return -1;) +JXFUN(0, int, get_all_properties, (jack_description_t** d), (d), if (d) *d=NULL; return -1;) +JPFUN(0, int, remove_property, (jack_client_t* c, jack_uuid_t s, const char* k), (c,s,k), -1) +JPFUN(0, int, remove_properties, (jack_client_t* c, jack_uuid_t s), (c,s), -1) +JPFUN(0, int, remove_all_properties, (jack_client_t* c), (c), -1) +JPFUN(0, int, set_property_change_callback, (jack_client_t *c, JackPropertyChangeCallback s, void *a), (c,s,a), -1) +#endif + +/* */ +JCFUN(1, float, get_max_delayed_usecs, 0.0) +JCFUN(1, float, get_xrun_delayed_usecs, 0.0) +JVFUN(0, reset_max_delayed_usecs, (jack_client_t *c), (c),) + +#endif // end USE_WEAK_JACK diff --git a/include/AudioWeakJack.h b/include/AudioWeakJack.h new file mode 100644 index 000000000..e53fced8e --- /dev/null +++ b/include/AudioWeakJack.h @@ -0,0 +1,237 @@ +/* runtime/weak dynamic JACK linking + * + * (C) 2014 Robin Gareus + * + * The wrapped jack API itself is + * (C) 2001 Paul Davis + * (C) 2004 Jack O'Quin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef _WEAK_JACK_H +#define _WEAK_JACK_H + +// LMMS uses LMMS_HAVE_WEAKJACK instead +#ifndef USE_WEAK_JACK +#define USE_WEAK_JACK +#endif + +// LMMS doesn't use metadata.h +#ifndef NO_JACK_METADATA +#define NO_JACK_METADATA +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** check if libjack is available + * + * return 0 if libjack is dynamically linked of was + * successfully dl-opened. Otherwise: + * + * -1: library was not initialized + * -2: libjack was not found + * > 0 bitwise flags: + * 1: a required function was not found in libjack + * 2: jack_client_open was not found in libjack + */ +int have_libjack(void); + +#ifdef __cplusplus +} +#endif + +#ifdef USE_WEAK_JACK + +/* */ +#define jack_client_close WJACK_client_close +#define jack_get_client_name WJACK_get_client_name +#define jack_get_sample_rate WJACK_get_sample_rate +#define jack_get_buffer_size WJACK_get_buffer_size +#define jack_frames_since_cycle_start WJACK_frames_since_cycle_start +#define jack_frame_time WJACK_frame_time +#define jack_last_frame_time WJACK_last_frame_time +#define jack_get_time WJACK_get_time +#define jack_cpu_load WJACK_cpu_load +#define jack_is_realtime WJACK_is_realtime + +#define jack_client_name_size WJACK_client_name_size + +#define jack_set_freewheel WJACK_set_freewheel +#define jack_set_buffer_size WJACK_set_buffer_size + +#define jack_on_shutdown WJACK_on_shutdown +#define jack_on_info_shutdown WJACK_on_info_shutdown +#define jack_set_process_callback WJACK_set_process_callback +#define jack_set_freewheel_callback WJACK_set_freewheel_callback +#define jack_set_buffer_size_callback WJACK_set_buffer_size_callback +#define jack_set_sample_rate_callback WJACK_set_sample_rate_callback +#define jack_set_port_registration_callback WJACK_set_port_registration_callback +#define jack_set_port_connect_callback WJACK_set_port_connect_callback +#define jack_set_graph_order_callback WJACK_set_graph_order_callback +#define jack_set_xrun_callback WJACK_set_xrun_callback +#define jack_set_latency_callback WJACK_set_latency_callback +#define jack_set_error_function WJACK_set_error_function +#define jack_set_info_function WJACK_set_info_function + +#define jack_activate WJACK_activate +#define jack_deactivate WJACK_deactivate + +#define jack_recompute_total_latencies WJACK_recompute_total_latencies +#define jack_port_get_total_latency WJACK_port_get_total_latency +#define jack_port_get_latency_range WJACK_port_get_latency_range +#define jack_port_set_latency_range WJACK_port_set_latency_range +#define jack_port_get_buffer WJACK_port_get_buffer +#define jack_port_request_monitor WJACK_port_request_monitor +#define jack_port_ensure_monitor WJACK_port_ensure_monitor +#define jack_port_monitoring_input WJACK_port_monitoring_input + +#define jack_port_name WJACK_port_name +#define jack_port_short_name WJACK_port_short_name +#define jack_port_flags WJACK_port_flags +#define jack_get_ports WJACK_get_ports +#define jack_port_name_size WJACK_port_name_size +#define jack_port_type_size WJACK_port_type_size +#define jack_port_type_get_buffer_size WJACK_port_type_get_buffer_size +#define jack_port_by_name WJACK_port_by_name +#define jack_port_by_id WJACK_port_by_id +#define jack_port_set_name WJACK_port_set_name +#define jack_port_get_aliases WJACK_port_get_aliases +#define jack_port_rename WJACK_port_rename +#define jack_port_disconnect WJACK_port_disconnect +#define jack_port_register WJACK_port_register +#define jack_port_unregister WJACK_port_unregister +#define jack_port_type WJACK_port_type +#define jack_port_get_connections WJACK_port_get_connections +#define jack_port_get_all_connections WJACK_port_get_all_connections +#define jack_connect WJACK_connect +#define jack_disconnect WJACK_disconnect +#define jack_free WJACK_free + +#define jack_cycle_wait WJACK_cycle_wait +#define jack_cycle_signal WJACK_cycle_signal +#define jack_set_process_thread WJACK_set_process_thread +#define jack_set_thread_init_callback WJACK_set_thread_init_callback + +/* */ +#define jack_get_current_transport_frame WJACK_get_current_transport_frame +#define jack_transport_locate WJACK_transport_locate +#define jack_transport_start WJACK_transport_start +#define jack_transport_stop WJACK_transport_stop +#define jack_transport_query WJACK_transport_query +#define jack_set_sync_callback WJACK_set_sync_callback +#define jack_set_timebase_callback WJACK_set_timebase_callback +#define jack_release_timebase WJACK_release_timebase + +/* */ +#define jack_midi_get_event_count WJACK_midi_get_event_count +#define jack_midi_event_get WJACK_midi_event_get +#define jack_midi_event_write WJACK_midi_event_write +#define jack_midi_clear_buffer WJACK_midi_clear_buffer + +/* */ +#define jack_set_session_callback WJACK_set_session_callback +#define jack_session_reply WJACK_session_reply +#define jack_session_event_free WJACK_session_event_free + +/* */ +#define jack_ringbuffer_create WJACK_ringbuffer_create +#define jack_ringbuffer_free WJACK_ringbuffer_free +#define jack_ringbuffer_reset WJACK_ringbuffer_reset +#define jack_ringbuffer_read_advance WJACK_ringbuffer_read_advance +#define jack_ringbuffer_write_advance WJACK_ringbuffer_write_advance +#define jack_ringbuffer_read_space WJACK_ringbuffer_read_space +#define jack_ringbuffer_write_space WJACK_ringbuffer_write_space +#define jack_ringbuffer_read WJACK_ringbuffer_read +#define jack_ringbuffer_write WJACK_ringbuffer_write +#define jack_ringbuffer_mlock WJACK_ringbuffer_mlock +#define jack_ringbuffer_get_read_vector WJACK_ringbuffer_get_read_vector +#define jack_ringbuffer_get_write_vector WJACK_ringbuffer_get_write_vector +#define jack_ringbuffer_peek WJACK_ringbuffer_peek + +/* */ +#define jack_client_real_time_priority WJACK_client_real_time_priority +#define jack_client_max_real_time_priority WJACK_client_max_real_time_priority +#define jack_acquire_real_time_scheduling WJACK_acquire_real_time_scheduling +#define jack_client_create_thread WJACK_client_create_thread +#define jack_drop_real_time_scheduling WJACK_drop_real_time_scheduling +#define jack_client_stop_thread WJACK_client_stop_thread +#define jack_client_kill_thread WJACK_client_kill_thread +#define jack_set_thread_creator WJACK_set_thread_creator + +#define jack_client_open WJACK_client_client_openXXX + +#ifndef NO_JACK_METADATA +/* */ +#define jack_get_uuid_for_client_name WJACK_get_uuid_for_client_name +#define jack_get_client_name_by_uuid WJACK_get_client_name_by_uuid +#define jack_port_uuid WJACK_port_uuid + +#define jack_set_property WJACK_set_property +#define jack_get_property WJACK_get_property +#define jack_free_description WJACK_free_description +#define jack_get_properties WJACK_get_properties +#define jack_get_all_properties WJACK_get_all_properties +#define jack_remove_property WJACK_remove_property +#define jack_remove_properties WJACK_remove_properties +#define jack_remove_all_properties WJACK_remove_all_properties +#define jack_set_property_change_callback WJACK_set_property_change_callback +#endif + +/* */ +#define jack_get_max_delayed_usecs WJACK_get_max_delayed_usecs +#define jack_get_xrun_delayed_usecs WJACK_get_xrun_delayed_usecs +#define jack_reset_max_delayed_usecs WJACK_reset_max_delayed_usecs + +#endif // end USE_WEAK_JACK + +#include +#include +#include +#include +#include +#include + +#ifndef NO_JACK_METADATA +#include +#endif + +#ifdef USE_WEAK_JACK + +#undef jack_client_open + +/* var-args hack */ + +#ifdef __cplusplus +extern "C" { +#endif +void (* WJACK_get_client_open (void)) (void); +jack_client_t * WJACK_no_client_open (const char *client_name, jack_options_t options, jack_status_t *status, ...); +#ifdef __cplusplus +} +#endif + +#define jack_client_open(...) \ +( \ + (WJACK_get_client_open() != NULL) \ + ? ((jack_client_t* (*)(const char *, jack_options_t, jack_status_t *, ...))(WJACK_get_client_open()))(__VA_ARGS__) \ + : WJACK_no_client_open(__VA_ARGS__) \ +) + +#endif // end USE_WEAK_JACK + +#endif // _WEAK_JACK_H diff --git a/include/MidiJack.h b/include/MidiJack.h index 9929b57c2..b3634bc34 100644 --- a/include/MidiJack.h +++ b/include/MidiJack.h @@ -28,8 +28,12 @@ #include "lmmsconfig.h" #ifdef LMMS_HAVE_JACK +#ifndef LMMS_HAVE_WEAKJACK #include #include +#else +#include "AudioWeakJack.h" +#endif #include #include diff --git a/include/NotePlayHandle.h b/include/NotePlayHandle.h index 344980eb6..768a74aa2 100644 --- a/include/NotePlayHandle.h +++ b/include/NotePlayHandle.h @@ -66,8 +66,7 @@ public: NotePlayHandle* parent = NULL, int midiEventChannel = -1, Origin origin = OriginPattern ); - virtual ~NotePlayHandle() {} - void done(); + virtual ~NotePlayHandle(); void * operator new ( size_t size, void * p ) { diff --git a/plugins/LadspaEffect/CMakeLists.txt b/plugins/LadspaEffect/CMakeLists.txt index e82761140..533d668f3 100644 --- a/plugins/LadspaEffect/CMakeLists.txt +++ b/plugins/LadspaEffect/CMakeLists.txt @@ -2,6 +2,10 @@ INCLUDE(BuildPlugin) # Disable C++11 REMOVE_DEFINITIONS(-std=c++0x) +# Enable C++11 for CXXFLAGS only and not for Windows +IF(NOT LMMS_BUILD_WIN32) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +ENDIF() BUILD_PLUGIN(ladspaeffect LadspaEffect.cpp LadspaControls.cpp LadspaControlDialog.cpp LadspaSubPluginFeatures.cpp LadspaEffect.h LadspaControls.h LadspaControlDialog.h LadspaSubPluginFeatures.h MOCFILES LadspaEffect.h LadspaControls.h LadspaControlDialog.h EMBEDDED_RESOURCES logo.png) diff --git a/plugins/LadspaEffect/swh/hermes_filter_1200.c b/plugins/LadspaEffect/swh/hermes_filter_1200.c index 5cac646ba..2f4386488 100644 --- a/plugins/LadspaEffect/swh/hermes_filter_1200.c +++ b/plugins/LadspaEffect/swh/hermes_filter_1200.c @@ -73,7 +73,7 @@ typedef struct { float *op; // pointer to output value } sv_filter; -inline float soft_clip(float sc_in) { +float soft_clip(float sc_in) { if ((sc_in < CLIP) && (sc_in > -CLIP)) { return sc_in; } else if (sc_in > 0.0f) { @@ -86,7 +86,7 @@ inline float soft_clip(float sc_in) { /* Store data in SVF struct, takes the sampling frequency, cutoff frequency and Q, and fills in the structure passed */ -inline void setup_svf(sv_filter *sv, float fs, float fc, float q, int t) { +void setup_svf(sv_filter *sv, float fs, float fc, float q, int t) { sv->f = 2.0f * sinf(M_PI * fc / (float)(fs * F_R)); sv->q = 2.0f * cosf(powf(q, 0.1f) * M_PI * 0.5f); sv->qnrm = sqrtf(sv->q*0.5f + 0.01f); @@ -111,7 +111,7 @@ inline void setup_svf(sv_filter *sv, float fs, float fc, float q, int t) { /* Change the frequency of a running SVF */ -inline void setup_f_svf(sv_filter *sv, const float fs, const float fc) { +void setup_f_svf(sv_filter *sv, const float fs, const float fc) { sv->f = 2.0f * sin(M_PI * fc / ((float)(fs * F_R))); } diff --git a/plugins/LadspaEffect/swh/sifter_1210.c b/plugins/LadspaEffect/swh/sifter_1210.c index 0e401e887..f7d8b557b 100644 --- a/plugins/LadspaEffect/swh/sifter_1210.c +++ b/plugins/LadspaEffect/swh/sifter_1210.c @@ -31,7 +31,7 @@ static void __attribute__((constructor)) swh_init(); // forward declaration #define MAX_BSIZE 1000 -inline int partition(LADSPA_Data array[], int left, int right); +int partition(LADSPA_Data array[], int left, int right); void q_sort(LADSPA_Data array[], int left, int right) { float pivot = partition(array, left, right); @@ -44,7 +44,7 @@ void q_sort(LADSPA_Data array[], int left, int right) { } } -inline int partition(LADSPA_Data array[], int left, int right) { +int partition(LADSPA_Data array[], int left, int right) { float pivot = array[left]; while (left < right) { diff --git a/plugins/LadspaEffect/swh/util/waveguide_nl.h b/plugins/LadspaEffect/swh/util/waveguide_nl.h index 398518eb0..e882e7771 100644 --- a/plugins/LadspaEffect/swh/util/waveguide_nl.h +++ b/plugins/LadspaEffect/swh/util/waveguide_nl.h @@ -35,7 +35,7 @@ waveguide_nl *waveguide_nl_new(int size, float fc, float da, float db) return wg; } -inline void waveguide_nl_reset(waveguide_nl *wg) +void waveguide_nl_reset(waveguide_nl *wg) { memset(wg->buffer[0], 0, wg->size * sizeof(float)); memset(wg->buffer[1], 0, wg->size * sizeof(float)); @@ -45,7 +45,7 @@ inline void waveguide_nl_reset(waveguide_nl *wg) wg->zm1[1] = 0.0f; } -inline void waveguide_nl_free(waveguide_nl *wg) +void waveguide_nl_free(waveguide_nl *wg) { if (!wg) { return; @@ -55,7 +55,7 @@ inline void waveguide_nl_free(waveguide_nl *wg) free(wg); } -inline void waveguide_nl_set_delay(waveguide_nl *wg, int delay) +void waveguide_nl_set_delay(waveguide_nl *wg, int delay) { if (delay > wg->size) { wg->delay = wg->size; @@ -66,18 +66,18 @@ inline void waveguide_nl_set_delay(waveguide_nl *wg, int delay) } } -inline void waveguide_nl_set_fc(waveguide_nl *wg, float fc) +void waveguide_nl_set_fc(waveguide_nl *wg, float fc) { wg->fc = fc; } -inline void waveguide_nl_set_ap(waveguide_nl *wg, float da, float db) +void waveguide_nl_set_ap(waveguide_nl *wg, float da, float db) { wg->a1a = (1.0f - da) / (1.0f + da); wg->a1b = (1.0f - db) / (1.0f + db); } -inline void waveguide_nl_process_lin(waveguide_nl *wg, float in0, float in1, float *out0, float *out1) +void waveguide_nl_process_lin(waveguide_nl *wg, float in0, float in1, float *out0, float *out1) { float tmp; @@ -103,7 +103,7 @@ inline void waveguide_nl_process_lin(waveguide_nl *wg, float in0, float in1, flo } } -inline void waveguide_nl_process(waveguide_nl *wg, float in0, float in1, float *out0, float *out1) +void waveguide_nl_process(waveguide_nl *wg, float in0, float in1, float *out0, float *out1) { float tmp; float a1; diff --git a/plugins/LadspaEffect/swh/vocoder_1337.c b/plugins/LadspaEffect/swh/vocoder_1337.c index d28975fe7..957a2f381 100644 --- a/plugins/LadspaEffect/swh/vocoder_1337.c +++ b/plugins/LadspaEffect/swh/vocoder_1337.c @@ -47,7 +47,7 @@ struct bandpasses LADSPA_Data y[MAX_BANDS]; }; -void inline doBandpasses(struct bandpasses *bands, LADSPA_Data sample, int num_bands); +void doBandpasses(struct bandpasses *bands, LADSPA_Data sample, int num_bands); struct bands_out{ LADSPA_Data decay[MAX_BANDS]; @@ -65,7 +65,7 @@ const LADSPA_Data decay_table[] = 1/250.0, 1/250.0, 1/250.0 }; -void inline doBandpasses(struct bandpasses *bands, LADSPA_Data sample, int num_bands) +void doBandpasses(struct bandpasses *bands, LADSPA_Data sample, int num_bands) { int i; for (i=0; i < num_bands; i++) diff --git a/plugins/papu/CMakeLists.txt b/plugins/papu/CMakeLists.txt index b45fcf614..20d9bbd20 100644 --- a/plugins/papu/CMakeLists.txt +++ b/plugins/papu/CMakeLists.txt @@ -1,6 +1,3 @@ INCLUDE(BuildPlugin) -# Disable C++11 -REMOVE_DEFINITIONS(-std=c++0x) - BUILD_PLUGIN(papu papu_instrument.cpp papu_instrument.h Basic_Gb_Apu.cpp Basic_Gb_Apu.h gb_apu/Gb_Oscs.cpp gb_apu/Gb_Apu.h gb_apu/Blip_Buffer.cpp gb_apu/Gb_Apu.cpp gb_apu/Gb_Oscs.h gb_apu/blargg_common.h gb_apu/Blip_Buffer.h gb_apu/Multi_Buffer.cpp gb_apu/blargg_source.h gb_apu/Multi_Buffer.h MOCFILES papu_instrument.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png") diff --git a/plugins/sfxr/sfxr.cpp b/plugins/sfxr/sfxr.cpp index c8370de82..d9e19a4fa 100644 --- a/plugins/sfxr/sfxr.cpp +++ b/plugins/sfxr/sfxr.cpp @@ -464,6 +464,7 @@ void sfxrInstrument::playNote( NotePlayHandle * _n, sampleFrame * _working_buffe } else if( static_cast(_n->m_pluginData)->isPlaying() == false ) { + memset(_working_buffer + offset, 0, sizeof(sampleFrame) * frameNum); _n->noteOff(); return; } diff --git a/plugins/vst_base/CMakeLists.txt b/plugins/vst_base/CMakeLists.txt index f92bb916e..b1e3d388a 100644 --- a/plugins/vst_base/CMakeLists.txt +++ b/plugins/vst_base/CMakeLists.txt @@ -33,15 +33,8 @@ IF(LMMS_BUILD_LINUX AND NOT WANT_VST_NOWINE) IF(LMMS_HOST_X86_64) SET(EXTRA_FLAGS -m32) - - EXEC_PROGRAM( ${WINE_CXX} ARGS "-v -m32 /dev/zero" OUTPUT_VARIABLE WINEBUILD_OUTPUT) - # workaround for broken wineg++ in WINE 1.4 (shipped e.g. with Ubuntu Precise) - IF("${WINEBUILD_OUTPUT}" MATCHES ".*x86_64-linux-gnu/wine/libwinecrt0.a.*") - SET(EXTRA_FLAGS ${EXTRA_FLAGS} -nodefaultlibs /usr/lib/i386-linux-gnu/wine/libwinecrt0.a -L/usr/lib/i386-linux-gnu/wine/ -luser32 -lkernel32 -lgdi32) - ENDIF() - # The following check works on Fedora systems - IF("${WINEBUILD_OUTPUT}" MATCHES "/usr/lib/lib64/wine/libwinecrt0.a.*") - SET(EXTRA_FLAGS ${EXTRA_FLAGS} -nodefaultlibs /usr/lib/i386/wine/libwinecrt0.a -luser32 -lkernel32 -lgdi32) + IF(WINE_LIBRARY_FIX) + SET(EXTRA_FLAGS ${EXTRA_FLAGS} -nodefaultlibs ${WINE_LIBRARY_FIX}wine/libwinecrt0.a -L${WINE_LIBRARY_FIX}wine/ -luser32 -lkernel32 -lgdi32) ENDIF() # Wine stable IF("${WINEBUILD_OUTPUT}" MATCHES "/opt/wine-stable/lib64/wine/libwinecrt0.a.*") diff --git a/plugins/zynaddsubfx/ZynAddSubFx.cpp b/plugins/zynaddsubfx/ZynAddSubFx.cpp index 275f0952d..c5627bcca 100644 --- a/plugins/zynaddsubfx/ZynAddSubFx.cpp +++ b/plugins/zynaddsubfx/ZynAddSubFx.cpp @@ -445,8 +445,8 @@ void ZynAddSubFxInstrument::initPlugin() RemotePlugin::message( IdZasfPresetDirectory ). addString( QSTR_TO_STDSTR( - QString( ConfigManager::inst()->factoryPresetsDir() + - QDir::separator() + "ZynAddSubFX" ) ) ) ); + QDir( ConfigManager::inst()->factoryPresetsDir() + + "/ZynAddSubFX" ).absolutePath() ) ) ); m_remotePlugin->updateSampleRate( Engine::mixer()->processingSampleRate() ); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 985f38052..c2a635eda 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,7 @@ SET(CMAKE_AUTOMOC ON) SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) # Enable C++11 -ADD_DEFINITIONS(-std=c++0x) +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") IF(LMMS_BUILD_APPLE) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 604a63c04..d9ef34bcd 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1,3 +1,7 @@ +IF(LMMS_HAVE_WEAKJACK) + set(WEAKJACK core/audio/AudioWeakJack.c) +ENDIF() + set(LMMS_SRCS ${LMMS_SRCS} core/AutomatableModel.cpp @@ -73,6 +77,7 @@ set(LMMS_SRCS core/audio/AudioFileOgg.cpp core/audio/AudioFileFlac.cpp core/audio/AudioFileWave.cpp + ${WEAKJACK} core/audio/AudioJack.cpp core/audio/AudioOss.cpp core/audio/AudioSndio.cpp diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index 5ccb4d345..231475002 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -503,7 +503,16 @@ void ConfigManager::loadConfigFile( const QString & configFile ) #elif defined(LMMS_BUILD_APPLE) m_stkDir = qApp->applicationDirPath() + "/../share/stk/rawwaves/"; #else - m_stkDir = "/usr/share/stk/rawwaves/"; + if ( qApp->applicationDirPath().startsWith("/tmp/") ) + { + // Assume AppImage bundle + m_stkDir = qApp->applicationDirPath() + "/../share/stk/rawwaves/"; + } + else + { + // Fallback to system provided location + m_stkDir = "/usr/share/stk/rawwaves/"; + } #endif } #endif diff --git a/src/core/InstrumentFunctions.cpp b/src/core/InstrumentFunctions.cpp index 4a542b081..2860045b8 100644 --- a/src/core/InstrumentFunctions.cpp +++ b/src/core/InstrumentFunctions.cpp @@ -305,7 +305,7 @@ InstrumentFunctionArpeggio::InstrumentFunctionArpeggio( Model * _parent ) : m_arpCycleModel( 0.0f, 0.0f, 6.0f, 1.0f, this, tr( "Cycle steps" ) ), m_arpSkipModel( 0.0f, 0.0f, 100.0f, 1.0f, this, tr( "Skip rate" ) ), m_arpMissModel( 0.0f, 0.0f, 100.0f, 1.0f, this, tr( "Miss rate" ) ), - m_arpTimeModel( 100.0f, 25.0f, 2000.0f, 1.0f, 2000, this, tr( "Arpeggio time" ) ), + m_arpTimeModel( 200.0f, 25.0f, 2000.0f, 1.0f, 2000, this, tr( "Arpeggio time" ) ), m_arpGateModel( 100.0f, 1.0f, 200.0f, 1.0f, this, tr( "Arpeggio gate" ) ), m_arpDirectionModel( this, tr( "Arpeggio direction" ) ), m_arpModeModel( this, tr( "Arpeggio mode" ) ) @@ -396,14 +396,13 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) frames_processed += remaining_frames_for_cur_arp; - // init with zero - int cur_arp_idx = 0; - // in sorted mode: is it our turn or do we have to be quiet for // now? if( m_arpModeModel.value() == SortMode && ( ( cur_frame / arp_frames ) % total_range ) / range != (f_cnt_t) _n->index() ) { + // Set master note if not playing arp note or it will play as an ordinary note + _n->setMasterNote(); // update counters frames_processed += arp_frames; cur_frame += arp_frames; @@ -416,10 +415,9 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) if( 100 * ( (float) rand() / (float)( RAND_MAX + 1.0f ) ) < m_arpSkipModel.value() ) { - if( cur_arp_idx == 0 ) - { - _n->setMasterNote(); - } + // Set master note to prevent the note to extend over skipped notes + // This may only be needed for lb302 + _n->setMasterNote(); // update counters frames_processed += arp_frames; cur_frame += arp_frames; @@ -440,6 +438,7 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) } } + int cur_arp_idx = 0; // process according to arpeggio-direction... if( dir == ArpDirUp ) { @@ -525,6 +524,13 @@ void InstrumentFunctionArpeggio::processNote( NotePlayHandle * _n ) frames_processed += arp_frames; cur_frame += arp_frames; } + + // make sure note is handled as arp-base-note, even + // if we didn't add a sub-note so far + if( m_arpModeModel.value() != FreeMode ) + { + _n->setMasterNote(); + } } diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 84d888fee..11f71d8f1 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -128,7 +128,7 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, } -void NotePlayHandle::done() +NotePlayHandle::~NotePlayHandle() { lock(); noteOff( 0 ); @@ -599,7 +599,7 @@ NotePlayHandle * NotePlayHandleManager::acquire( InstrumentTrack* instrumentTrac void NotePlayHandleManager::release( NotePlayHandle * nph ) { - nph->done(); + nph->NotePlayHandle::~NotePlayHandle(); s_mutex.lockForRead(); s_available[ s_availableIndex.fetchAndAddOrdered( 1 ) + 1 ] = nph; s_mutex.unlock(); diff --git a/src/core/PlayHandle.cpp b/src/core/PlayHandle.cpp index 5481ea3e2..9e92019a6 100644 --- a/src/core/PlayHandle.cpp +++ b/src/core/PlayHandle.cpp @@ -54,6 +54,7 @@ void PlayHandle::doProcessing() if( m_usesBuffer ) { m_bufferReleased = false; + BufferManager::clear(m_playHandleBuffer, Engine::mixer()->framesPerPeriod()); play( buffer() ); } else diff --git a/src/core/audio/AudioWeakJack.c b/src/core/audio/AudioWeakJack.c new file mode 100644 index 000000000..5cf93cdd8 --- /dev/null +++ b/src/core/audio/AudioWeakJack.c @@ -0,0 +1,273 @@ +/* runtime/weak dynamic JACK linking + * + * (C) 2014 Robin Gareus + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "AudioWeakJack.h" + +#ifndef USE_WEAK_JACK + +int have_libjack (void) { + return 0; +} + +#else + +#include +#include +#include + +#ifdef _WIN32 +#include +#else +#include +#endif + +static void* lib_open(const char* const so) { +#ifdef _WIN32 + return (void*) LoadLibraryA(so); +#else + return dlopen(so, RTLD_NOW|RTLD_LOCAL); +#endif +} + +static void* lib_symbol(void* const lib, const char* const sym) { +#ifdef _WIN32 + return (void*) GetProcAddress((HMODULE)lib, sym); +#else + return dlsym(lib, sym); +#endif +} + +#if _MSC_VER && !__INTEL_COMPILER +typedef void * pvoid_t; +#define MAPSYM(SYM, FAIL) _j._ ## SYM = (func_t)lib_symbol(lib, "jack_" # SYM); \ + if (!_j._ ## SYM) err |= FAIL; +#elif defined NDEBUG +typedef void * __attribute__ ((__may_alias__)) pvoid_t; +#define MAPSYM(SYM, FAIL) *(pvoid_t *)(&_j._ ## SYM) = lib_symbol(lib, "jack_" # SYM); \ + if (!_j._ ## SYM) err |= FAIL; +#else +typedef void * __attribute__ ((__may_alias__)) pvoid_t; +#define MAPSYM(SYM, FAIL) *(pvoid_t *)(&_j._ ## SYM) = lib_symbol(lib, "jack_" # SYM); \ + if (!_j._ ## SYM) { \ + if (FAIL) { \ + fprintf(stderr, "*** WEAK-JACK: required symbol 'jack_%s' was not found\n", "" # SYM); \ + } \ + err |= FAIL; \ + } +#endif + +typedef void (* func_t) (void); + +/* function pointers to the real jack API */ +static struct WeakJack { + func_t _client_open; // special case due to varargs + +#define JCFUN(ERR, RTYPE, NAME, RVAL) func_t _ ## NAME ; +#define JPFUN(ERR, RTYPE, NAME, DEF, ARGS, RVAL) func_t _ ## NAME ; +#define JXFUN(ERR, RTYPE, NAME, DEF, ARGS, CODE) func_t _ ## NAME ; +#define JVFUN(ERR, NAME, DEF, ARGS, CODE) func_t _ ## NAME ; + +#include "AudioWeakJack.def" + +#undef JCFUN +#undef JPFUN +#undef JXFUN +#undef JVFUN +} _j; + +static int _status = -1; + +__attribute__((constructor)) +static void init_weak_jack(void) +{ + void* lib; + int err = 0; +#ifndef NDEBUG + fprintf(stderr, "*** WEAK-JACK: initializing\n"); +#endif + + memset(&_j, 0, sizeof(_j)); + +#ifdef __APPLE__ + lib = lib_open("libjack.dylib"); + if (!lib) { + lib = lib_open("/usr/local/lib/libjack.dylib"); + } +#elif (defined _WIN32) +# ifdef __x86_64__ + lib = lib_open("libjack64.dll"); +# else + lib = lib_open("libjack.dll"); +# endif +#else + lib = lib_open("libjack.so.0"); +#endif + if (!lib) { +#ifndef NDEBUG + fprintf(stderr, "*** WEAK-JACK: libjack was not found\n"); +#endif + _status = -2; + return; + } + + /* found library, now lookup functions */ + MAPSYM(client_open, 2) + +#define JCFUN(ERR, RTYPE, NAME, RVAL) MAPSYM(NAME, ERR) +#define JPFUN(ERR, RTYPE, NAME, DEF, ARGS, RVAL) MAPSYM(NAME, ERR) +#define JXFUN(ERR, RTYPE, NAME, DEF, ARGS, CODE) MAPSYM(NAME, ERR) +#define JVFUN(ERR, NAME, DEF, ARGS, CODE) MAPSYM(NAME, ERR) + +#include "AudioWeakJack.def" + +#undef JCFUN +#undef JPFUN +#undef JXFUN +#undef JVFUN + + /* if a required symbol is not found, disable JACK completly */ + if (err) { + _j._client_open = NULL; + } + _status = err; +#ifndef NDEBUG + fprintf(stderr, "*** WEAK-JACK: %s. (%d)\n", err ? "jack is not available" : "OK", _status); +#endif +} + +int have_libjack (void) { + if (_status == -1) { + init_weak_jack(); + } + return _status; +} + +/******************************************************************************* + * helper macros + */ + +#if defined(__GNUC__) && (__GNUC__ > 2) && !defined(NDEBUG) +#define likely(expr) (__builtin_expect (!!(expr), 1)) +#else +#define likely(expr) (expr) +#endif + +#ifndef NDEBUG +# define WJACK_WARNING(NAME) \ + fprintf(stderr, "*** WEAK-JACK: function 'jack_%s' ignored\n", "" # NAME); +#else +# define WJACK_WARNING(NAME) ; +#endif + +/****************************************************************************** + * JACK API wrapper functions. + * + * if a function pointer is set in the static struct WeakJack _j, + * the function is called directly. + * Otherwise a dummy NOOP implementation is provided. + * The latter is mainly for compile-time warnings. + * + * If libjack is not found, jack_client_open() will fail. + * In that case the application should not call any other libjack + * functions. Hence a real implementation is not needed. + * (jack ringbuffer may be an exception for some apps) + */ + +/* dedicated support for jack_client_open(,..) variable arg function macro */ +func_t WJACK_get_client_open(void) { + if (_status == -1) { + init_weak_jack(); + } + return _j._client_open; +} + +/* callback to set status */ +jack_client_t * WJACK_no_client_open (const char *client_name, jack_options_t options, jack_status_t *status, ...) { + WJACK_WARNING(client_open); + if (status) { *status = JackFailure; } + return NULL; +} + +/******************************************************************************* + * Macros to wrap jack API + */ + +/* abstraction for jack_client functions + * rtype jack_function_name (jack_client_t *client) { return rval; } + */ +#define JCFUN(ERR, RTYPE, NAME, RVAL) \ + RTYPE WJACK_ ## NAME (jack_client_t *client) { \ + if likely(_j._ ## NAME) { \ + return ((RTYPE (*)(jack_client_t *client)) _j._ ## NAME)(client); \ + } else { \ + WJACK_WARNING(NAME) \ + return RVAL; \ + } \ + } + +/* abstraction for NOOP functions with return value + * rtype jack_function_name (ARGS) { return rval; } + */ +#define JPFUN(ERR, RTYPE, NAME, DEF, ARGS, RVAL) \ + RTYPE WJACK_ ## NAME DEF { \ + if likely(_j._ ## NAME) { \ + return ((RTYPE (*)DEF) _j._ ## NAME) ARGS; \ + } else { \ + WJACK_WARNING(NAME) \ + return RVAL; \ + } \ + } + +/* abstraction for functions that need custom code. + * e.g. functions with return-value-pointer args, + * use CODE to initialize value + * + * rtype jack_function_name (ARGS) { CODE } + */ +#define JXFUN(ERR, RTYPE, NAME, DEF, ARGS, CODE) \ + RTYPE WJACK_ ## NAME DEF { \ + if likely(_j._ ## NAME) { \ + return ((RTYPE (*)DEF) _j._ ## NAME) ARGS; \ + } else { \ + WJACK_WARNING(NAME) \ + CODE \ + } \ + } + +/* abstraction for void functions with return-value-pointer args + * void jack_function_name (ARGS) { CODE } + */ +#define JVFUN(ERR, NAME, DEF, ARGS, CODE) \ + void WJACK_ ## NAME DEF { \ + if likely(_j._ ## NAME) { \ + ((void (*)DEF) _j._ ## NAME) ARGS; \ + } else { \ + WJACK_WARNING(NAME) \ + CODE \ + } \ + } + +#include "AudioWeakJack.def" + +#undef JCFUN +#undef JPFUN +#undef JXFUN +#undef JVFUN + +#endif // end USE_WEAK_JACK diff --git a/src/lmmsconfig.h.in b/src/lmmsconfig.h.in index 71e9ad3ca..248041f70 100644 --- a/src/lmmsconfig.h.in +++ b/src/lmmsconfig.h.in @@ -11,6 +11,7 @@ #cmakedefine LMMS_HAVE_ALSA #cmakedefine LMMS_HAVE_FLUIDSYNTH #cmakedefine LMMS_HAVE_JACK +#cmakedefine LMMS_HAVE_WEAKJACK #cmakedefine LMMS_HAVE_MP3LAME #cmakedefine LMMS_HAVE_OGGVORBIS #cmakedefine LMMS_HAVE_OSS