zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit e673b9012ce804642bcef37c7b2d387c0475c91a
parent 608620d75b967b27553f770e7c7b2ca372eb7e9c
Author: Johannes Lorenz <[email protected]>
Date:   Sun, 17 Jun 2018 01:22:27 +0200

Enable starting fusion from CMake-configured path

* Fix rtosc issue
* Enable starting fusion from CMake-configured path
* Fix zyn complaining it cannot kill already stopped process
* Partially fix fusion issue #140

Diffstat:
Msrc/CMakeLists.txt | 5+++++
Msrc/Params/Controller.cpp | 4++--
Msrc/UI/PartUI.fl | 4++--
Msrc/main.cpp | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
Asrc/zyn-config.h.in | 23+++++++++++++++++++++++
Msrc/zyn-version.h.in | 4++--
6 files changed, 89 insertions(+), 32 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt @@ -96,6 +96,8 @@ SET (NoNeonPlease False CACHE BOOL SET (PluginLibDir "lib" CACHE STRING "Install directory for plugin libraries PREFIX/PLUGIN_LIB_DIR/{lv2,vst}") SET (DemoMode FALSE CACHE BOOL "Enable 10 minute silence") +SET (ZynFusionDir "" CACHE STRING "Developers only: zest binary's dir; useful if fusion is not system-instealled.") +mark_as_advanced(FORCE ZynFusionDir) # Now, handle the incoming settings and set define flags/variables based # on this @@ -181,6 +183,7 @@ option (BuildForAMD_X86_64 "Build for AMD x86_64 system" OFF) option (BuildForCore2_X86_64 "Build for Intel Core2 x86_64 system" OFF) option (BuildForDebug "Include gdb debugging support" OFF) option (IncludeWhatYouUse "Check for useless includes" OFF) +mark_as_advanced(IncludeWhatYouUse) set(CMAKE_BUILD_TYPE "Release") @@ -444,6 +447,8 @@ endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zyn-version.h.in ${CMAKE_CURRENT_BINARY_DIR}/zyn-version.h) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zyn-config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/zyn-config.h) link_directories(${AUDIO_LIBRARY_DIRS} ${ZLIB_LIBRARY_DIRS} ${FFTW_LIBRARY_DIRS} ${MXML_LIBRARY_DIRS} ${FLTK_LIBRARY_DIRS} ${NTK_LIBRARY_DIRS}) diff --git a/src/Params/Controller.cpp b/src/Params/Controller.cpp @@ -44,9 +44,9 @@ const rtosc::Ports Controller::ports = { rToggle(modwheel.exponential, rShort("mdw.exp"), rDefault(false), "Modwheel Exponential Mode"), rToggle(pitchwheel.is_split, rDefault(false), - "If PitchWheel Has unified bendrange or not"), + "If PitchWheel has unified bendrange or not"), rParamI(pitchwheel.bendrange, rShort("pch.d"), rDefault(200), - rLinear(-6400, 6400), + rLinear(-6400, 6400), rUnit(% of semitone), "Range of MIDI Pitch Wheel"), rParamI(pitchwheel.bendrange_down, rDefault(0), "Lower Range of MIDI Pitch Wheel"), diff --git a/src/UI/PartUI.fl b/src/UI/PartUI.fl @@ -487,8 +487,8 @@ else {bendrng->oscMove("pitchwheel.bendrange");}} xywh {205 37 69 15} down_box DOWN_BOX labelsize 10 } Fl_Counter bendrng { - label {PWheelB.Rng (cents)} - tooltip {Pitch Wheel Bend Range (cents)} xywh {165 15 110 20} labelsize 10 align 1 minimum -6400 maximum 6400 step 1 + label {PWheelB.Rng (% semitone)} + tooltip {Pitch Wheel Bend Range (cents of semitone)} xywh {165 15 110 20} labelsize 10 align 1 minimum -6400 maximum 6400 step 1 code0 {o->init("pitchwheel.bendrange", 'i');} code1 {o->lstep(100);} class Fl_Osc_Counter diff --git a/src/main.cpp b/src/main.cpp @@ -40,6 +40,7 @@ #include "Misc/Master.h" #include "Misc/Part.h" #include "Misc/Util.h" +#include "zyn-config.h" #include "zyn-version.h" //Nio System @@ -658,37 +659,57 @@ int wmidi = -1; #ifndef WIN32 gui_pid = fork(); if(gui_pid == 0) { - execlp("zyn-fusion", "zyn-fusion", addr, "--builtin", "--no-hotload", 0); - execlp("./zyn-fusion", "zyn-fusion", addr, "--builtin", "--no-hotload", 0); - + auto exec_fusion = [&addr](const char* path) { + execlp(path, "zyn-fusion", addr, "--builtin", "--no-hotload", 0); }; + if(fusion_dir && *fusion_dir) + { + std::string fusion = fusion_dir; + fusion += "/zest"; + if(access(fusion.c_str(), X_OK)) + fputs("Warning: CMake's ZynFusionDir does not contain a" + "\"zest\" binary - ignoring.", stderr); + else { + const char* cur = getenv("LD_LIBRARY_PATH"); + std::string ld_library_path; + if(cur) { + ld_library_path += cur; + ld_library_path += ":"; + } + ld_library_path += fusion_dir; + setenv("LD_LIBRARY_PATH", ld_library_path.c_str(), 1); + exec_fusion(fusion.c_str()); + } + } + exec_fusion("./zyn-fusion"); + exec_fusion("zyn-fusion"); err(1,"Failed to launch Zyn-Fusion"); } #else STARTUPINFO si; -PROCESS_INFORMATION pi; -memset(&si, 0, sizeof(si)); -memset(&pi, 0, sizeof(pi)); -char *why_windows = strrchr(addr, ':'); -char *seriously_why = why_windows + 1; -char start_line[256] = {0}; -if(why_windows) - snprintf(start_line, sizeof(start_line), "zyn-fusion.exe osc.udp://127.0.0.1:%s", seriously_why); -else { - printf("COULD NOT PARSE <%s>\n", addr); - exit(1); -} -printf("[INFO] starting subprocess via <%s>\n", start_line); -if(!CreateProcess(NULL, start_line, -NULL, NULL, 0, 0, NULL, NULL, &si, &pi)) { - printf("Failed to launch Zyn-Fusion...\n"); - exit(1); -} - + PROCESS_INFORMATION pi; + memset(&si, 0, sizeof(si)); + memset(&pi, 0, sizeof(pi)); + char *why_windows = strrchr(addr, ':'); + char *seriously_why = why_windows + 1; + char start_line[256] = {0}; + if(why_windows) + snprintf(start_line, sizeof(start_line), "zyn-fusion.exe osc.udp://127.0.0.1:%s", seriously_why); + else { + printf("COULD NOT PARSE <%s>\n", addr); + exit(1); + } + printf("[INFO] starting subprocess via <%s>\n", start_line); + if(!CreateProcess(NULL, start_line, + NULL, NULL, 0, 0, NULL, NULL, &si, &pi)) { + printf("Failed to launch Zyn-Fusion...\n"); + exit(1); + } #endif } #endif printf("[INFO] Main Loop...\n"); + bool already_exited = false; while(Pexitprogram == 0) { #ifndef WIN32 #if USE_NSM @@ -732,19 +753,27 @@ done: if(!noui) { int status = 0; int ret = waitpid(gui_pid, &status, WNOHANG); - if(ret == gui_pid) + if(ret == gui_pid) { Pexitprogram = 1; + already_exited = true; + } } #endif #endif } #ifdef ZEST_GUI #ifndef WIN32 - int ret = kill(gui_pid, SIGHUP); - if (ret == -1) { - err(1, "Failed to terminate Zyn-Fusion...\n"); + if(!already_exited) { + int ret = kill(gui_pid, SIGHUP); + if (ret == -1) { + err(1, "Failed to terminate Zyn-Fusion...\n"); + } } +#else + (void)already_exited; #endif +#else + (void)already_exited; #endif exitprogram(config); return 0; diff --git a/src/zyn-config.h.in b/src/zyn-config.h.in @@ -0,0 +1,23 @@ +/* + ZynAddSubFX - a software synthesizer + + config.h - options configurable by CMake + Copyright (C) 2018 Johannes Lorenz + Author: Johannes Lorenz + + 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 + of the License, or (at your option) any later version. +*/ + +#ifndef ZYN_CONFIG_H_IN +#define ZYN_CONFIG_H_IN + +namespace zyn { + +constexpr const char* fusion_dir = "@ZynFusionDir@"; + +} + +#endif diff --git a/src/zyn-version.h.in b/src/zyn-version.h.in @@ -12,8 +12,8 @@ of the License, or (at your option) any later version. */ -#ifndef VERSION_H -#define VERSION_H +#ifndef ZYN_VERSION_H +#define ZYN_VERSION_H #include <iosfwd>