yoshimi: fix build (for real)

This commit is contained in:
newbluemoon 2017-10-20 15:20:32 +02:00 committed by Enno Boland
parent e8d8db0918
commit 39179aa064
5 changed files with 353 additions and 182 deletions

View file

@ -1,32 +1,56 @@
--- src/CMakeLists.txt.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/CMakeLists.txt 2017-10-20 09:13:13.740336950 +0200
@@ -118,6 +118,19 @@
+++ src/CMakeLists.txt 2017-10-22 18:09:47.997475553 +0200
@@ -105,7 +105,7 @@
set (BuildOptionsBasic
"-O3 -msse -msse2 -mfpmath=sse -ffast-math -fomit-frame-pointer"
- CACHE STRING "basic X86 complier options"
+ CACHE STRING "basic X86 compiler options"
)
set (BuildOptionsDebug
@@ -118,6 +118,34 @@
message(FATAL_ERROR "pkg-config required but not found")
endif (PKG_CONFIG_FOUND)
+include (CheckFunctionExists)
+check_function_exists(random_r HAVE_RANDOM_R)
+
+# musl systems dont have random_r() and also need argp-standalone
+if (NOT HAVE_RANDOM_R)
+ find_library (ARGP_LIB argp REQUIRED)
+ if (ARGP_LIB)
+ message(STATUS "Found argp")
+ else()
+ message(FATAL_ERROR "argp required but not found")
+ endif()
+endif()
+check_function_exists(random_r randomR)
+
+if (randomR)
+ add_definitions(-DHAVE_RANDOM_R)
+endif(randomR)
+
+check_c_source_compiles (
+ "#include <argp.h>
+ int main () {
+ int argc=1;
+ char *argv[]={\"test\"};
+ argp_parse(0,argc,argv,0,0,0);
+ return 0;
+ }" LIBC_HAS_ARGP
+)
+
+if (NOT LIBC_HAS_ARGP)
+ message(STATUS "libc does not have argp")
+ find_library (ARGP_LIB argp REQUIRED)
+ if (ARGP_LIB)
+ message(STATUS "Found libargp")
+ else(ARGP_LIB)
+ message(FATAL_ERROR "libargp required but not found")
+ endif(ARGP_LIB)
+endif(NOT LIBC_HAS_ARGP)
+
# libz
set (CMAKE_REQUIRED_LIBRARIES z)
check_c_source_compiles (
@@ -497,6 +510,10 @@
@@ -497,6 +525,10 @@
target_link_libraries (yoshimi ${ExternLibraries})
+if (NOT HAVE_RANDOM_R)
+ target_link_libraries (yoshimi ${ARGP_LIB})
+endif()
+if (ARGP_LIB)
+ target_link_libraries (yoshimi ${ARGP_LIB})
+endif(ARGP_LIB)
+
install (TARGETS yoshimi RUNTIME DESTINATION bin)

View file

@ -0,0 +1,21 @@
--- src/main.cpp.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/main.cpp 2017-10-22 15:26:56.153363369 +0200
@@ -97,6 +97,8 @@
static void *mainGuiThread(void *arg)
{
+ Fl::lock();
+
sem_post((sem_t *)arg);
map<SynthEngine *, MusicClient *>::iterator it;
@@ -334,9 +336,6 @@
int minVmajor = 1; // need to improve this idea
int minVminor = 5;
- // moved from mainGuiThread() to prevent leaking from early GuiThreadMessage
- Fl::lock();
-
if (!mainCreateNewInstance(0))
{
goto bail_out;

View file

@ -1,172 +1,10 @@
--- src/Synth/OscilGen.h.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Synth/OscilGen.h 2017-10-20 08:45:28.828335039 +0200
@@ -204,20 +204,38 @@
unsigned int randseed;
float random_0_1;
+ char random_state[256];
+ int ret;
+
+#if defined (HAVE_RANDOM_R)
int32_t random_result;
struct random_data random_buf;
- char random_state[256];
+#else
+ long int random_result;
+#endif
float harmonic_random_0_1;
+ char harmonic_random_state[256];
+
+#if defined (HAVE_RANDOM_R)
int32_t harmonic_random_result;
struct random_data harmonic_random_buf;
- char harmonic_random_state[256];
+#else
+ long int harmonic_random_result;
+#endif
};
inline float OscilGen::numRandom(void)
{
- if (!random_r(&random_buf, &random_result))
+#if defined (HAVE_RANDOM_R)
+ ret = random_r(&random_buf, &random_result);
+#else
+ random_result = random();
+ ret = 0;
+#endif
+
+ if (!ret)
{
random_0_1 = (float)random_result / (float)INT_MAX;
if (isgreater(random_0_1, 1.0f))
@@ -248,7 +266,14 @@
inline float OscilGen::harmonicRandom(void)
{
- if (!random_r(&harmonic_random_buf, &harmonic_random_result))
+#if defined (HAVE_RANDOM_R)
+ ret = random_r(&harmonic_random_buf, &harmonic_random_result);
+#else
+ harmonic_random_result = random();
+ ret = 0;
+#endif
+
+ if (!ret)
{
harmonic_random_0_1 = (float)harmonic_random_result / (float)INT_MAX;
harmonic_random_0_1 = (harmonic_random_0_1 > 1.0f) ? 1.0f : harmonic_random_0_1;
@@ -261,9 +286,14 @@
inline unsigned int OscilGen::random(void)
{
+#if defined (HAVE_RANDOM_R)
if (!random_r(&random_buf, &random_result))
return random_result + INT_MAX / 2;
return INT_MAX;
+#else
+ random_result = random();
+ return (unsigned int)random_result + INT_MAX / 2;
+#endif
}
#endif
--- src/Synth/OscilGen.cpp.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Synth/OscilGen.cpp 2017-10-20 08:15:44.680540189 +0200
@@ -950,10 +950,16 @@
//int i, j, k;
float a, b, c, d, hmagnew;
memset(random_state, 0, sizeof(random_state));
+#if defined (HAVE_RANDOM_R)
memset(&random_buf, 0, sizeof(random_buf));
if (initstate_r(synth->random(), random_state,
sizeof(random_state), &random_buf))
synth->getRuntime().Log("OscilGen failed to init general randomness");
+#else
+ if (!initstate(synth->random(), random_state, sizeof(random_state)))
+ synth->getRuntime().Log("OscilGen failed to init general randomness");
+#endif
+
if (oldbasepar != Pbasefuncpar
|| oldbasefunc != Pcurrentbasefunc
|| oldbasefuncmodulation != Pbasefuncmodulation
@@ -1292,10 +1298,16 @@
// unsigned int realrnd = random();
// srandom_r(randseed, &harmonic_random_buf);
memset(harmonic_random_state, 0, sizeof(harmonic_random_state));
+#if defined (HAVE_RANDOM_R)
memset(&harmonic_random_buf, 0, sizeof(harmonic_random_buf));
if (initstate_r(randseed, harmonic_random_state,
sizeof(harmonic_random_state), &harmonic_random_buf))
synth->getRuntime().Log("OscilGen failed to init harmonic amplitude amplitude randomness");
+#else
+ if (!initstate(randseed, harmonic_random_state, sizeof(harmonic_random_state)))
+ synth->getRuntime().Log("OscilGen failed to init harmonic amplitude amplitude randomness");
+#endif
+
float power = Pamprandpower / 127.0f;
float normalize = 1.0f / (1.2f - power);
switch (Pamprandtype)
--- src/Misc/SynthEngine.h.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Misc/SynthEngine.h 2017-10-20 08:43:31.915561436 +0200
@@ -269,9 +269,16 @@
XMLwrapper *stateXMLtree;
char random_state[256];
+ float random_0_1;
+ int ret;
+
+#if defined (HAVE_RANDOM_R)
struct random_data random_buf;
int32_t random_result;
- float random_0_1;
+#else
+ long int random_result;
+#endif
+
public:
MasterUI *guiMaster; // need to read this in InterChange::returns
private:
@@ -285,7 +292,14 @@
inline float SynthEngine::numRandom(void)
{
- if (!random_r(&random_buf, &random_result))
+#if defined (HAVE_RANDOM_R)
+ ret = random_r(&random_buf, &random_result);
+#else
+ random_result = random();
+ ret = 0;
+#endif
+
+ if (!ret)
{
random_0_1 = (float)random_result / (float)INT_MAX;
random_0_1 = (random_0_1 > 1.0f) ? 1.0f : random_0_1;
@@ -297,9 +311,14 @@
inline unsigned int SynthEngine::random(void)
{
+#if defined (HAVE_RANDOM_R)
if (!random_r(&random_buf, &random_result))
return random_result + INT_MAX / 2;
return INT_MAX / 2;
+#else
+ random_result = random();
+ return (unsigned int)random_result + INT_MAX / 2;
+#endif
}
#endif
--- src/Misc/SynthEngine.cpp.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Misc/SynthEngine.cpp 2017-10-20 08:13:09.711523496 +0200
+++ src/Misc/SynthEngine.cpp 2017-10-22 15:19:00.761619805 +0200
@@ -229,11 +229,16 @@
}
memset(random_state, 0, sizeof(random_state));
+#if defined (HAVE_RANDOM_R)
+#if (HAVE_RANDOM_R)
memset(&random_buf, 0, sizeof(random_buf));
if (initstate_r(samplerate + buffersize + oscilsize, random_state,
@ -179,3 +17,291 @@
if (oscilsize < (buffersize / 2))
{
--- src/Misc/SynthEngine.h.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Misc/SynthEngine.h 2017-10-22 15:19:00.762619810 +0200
@@ -4,7 +4,7 @@
Original ZynAddSubFX author Nasca Octavian Paul
Copyright (C) 2002-2005 Nasca Octavian Paul
Copyright 2009-2011, Alan Calvert
- Copyright 2014-2016, Will Godfrey & others
+ Copyright 2014-2017, Will Godfrey & others
This file is part of yoshimi, which is free software: you can redistribute
it and/or modify it under the terms of the GNU Library General Public
@@ -22,7 +22,7 @@
This file is derivative of ZynAddSubFX original code.
- Modified September 2017
+ Modified October 2017
*/
#ifndef SYNTHENGINE_H
@@ -137,7 +137,7 @@
void ClearNRPNs(void);
void resetAll(void);
float numRandom(void);
- unsigned int random(void);
+ unsigned int randomSE(void);
void ShutUp(void);
void allStop(unsigned int stopType);
int MasterAudio(float *outl [NUM_MIDI_PARTS + 1], float *outr [NUM_MIDI_PARTS + 1], int to_process = 0);
@@ -269,9 +269,15 @@
XMLwrapper *stateXMLtree;
char random_state[256];
+ float random_0_1;
+
+#if (HAVE_RANDOM_R)
struct random_data random_buf;
int32_t random_result;
- float random_0_1;
+#else
+ long int random_result;
+#endif
+
public:
MasterUI *guiMaster; // need to read this in InterChange::returns
private:
@@ -285,7 +291,15 @@
inline float SynthEngine::numRandom(void)
{
- if (!random_r(&random_buf, &random_result))
+ int ret;
+#if (HAVE_RANDOM_R)
+ ret = random_r(&random_buf, &random_result);
+#else
+ random_result = random();
+ ret = 0;
+#endif
+
+ if (!ret)
{
random_0_1 = (float)random_result / (float)INT_MAX;
random_0_1 = (random_0_1 > 1.0f) ? 1.0f : random_0_1;
@@ -295,11 +309,16 @@
return 0.05f;
}
-inline unsigned int SynthEngine::random(void)
+inline unsigned int SynthEngine::randomSE(void)
{
+#if (HAVE_RANDOM_R)
if (!random_r(&random_buf, &random_result))
return random_result + INT_MAX / 2;
return INT_MAX / 2;
+#else
+ random_result = random();
+ return (unsigned int)random_result + INT_MAX / 2;
+#endif
}
#endif
--- src/Synth/OscilGen.cpp.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Synth/OscilGen.cpp 2017-10-22 15:19:00.767619838 +0200
@@ -5,7 +5,7 @@
Copyright (C) 2002-2005 Nasca Octavian Paul
Copyright 2009-2011 Alan Calvert
Copyright 2009 James Morris
- Copyright 2016 Will Godfrey
+ Copyright 2016-2017 Will Godfrey & others
This file is part of yoshimi, which is free software: you can redistribute
it and/or modify it under the terms of the GNU Library General Public
@@ -21,7 +21,9 @@
yoshimi; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301, USA.
- This file is a derivative of a ZynAddSubFX original, modified December 2016
+ This file is a derivative of a ZynAddSubFX original.
+
+ Modified October 2017
*/
#include <cmath>
@@ -947,13 +949,18 @@
// Prepare the Oscillator
void OscilGen::prepare(void)
{
- //int i, j, k;
float a, b, c, d, hmagnew;
memset(random_state, 0, sizeof(random_state));
+#if (HAVE_RANDOM_R)
memset(&random_buf, 0, sizeof(random_buf));
- if (initstate_r(synth->random(), random_state,
+ if (initstate_r(synth->randomSE(), random_state,
sizeof(random_state), &random_buf))
synth->getRuntime().Log("OscilGen failed to init general randomness");
+#else
+ if (!initstate(synth->randomSE(), random_state, sizeof(random_state)))
+ synth->getRuntime().Log("OscilGen failed to init general randomness");
+#endif
+
if (oldbasepar != Pbasefuncpar
|| oldbasefunc != Pcurrentbasefunc
|| oldbasefuncmodulation != Pbasefuncmodulation
@@ -1289,13 +1296,17 @@
// Harmonic Amplitude Randomness
if (freqHz > 0.1 && !ADvsPAD)
{
- // unsigned int realrnd = random();
-// srandom_r(randseed, &harmonic_random_buf);
memset(harmonic_random_state, 0, sizeof(harmonic_random_state));
+#if (HAVE_RANDOM_R)
memset(&harmonic_random_buf, 0, sizeof(harmonic_random_buf));
if (initstate_r(randseed, harmonic_random_state,
sizeof(harmonic_random_state), &harmonic_random_buf))
synth->getRuntime().Log("OscilGen failed to init harmonic amplitude amplitude randomness");
+#else
+ if (!initstate(randseed, harmonic_random_state, sizeof(harmonic_random_state)))
+ synth->getRuntime().Log("OscilGen failed to init harmonic amplitude amplitude randomness");
+#endif
+
float power = Pamprandpower / 127.0f;
float normalize = 1.0f / (1.2f - power);
switch (Pamprandtype)
@@ -1323,7 +1334,6 @@
}
break;
}
- // srandom_r(realrnd + 1, &random_data_buf);
}
if (freqHz > 0.1 && resonance != 0)
--- src/Synth/OscilGen.h.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Synth/OscilGen.h 2017-10-22 15:19:00.767619838 +0200
@@ -4,6 +4,7 @@
Original ZynAddSubFX author Nasca Octavian Paul
Copyright (C) 2002-2005 Nasca Octavian Paul
Copyright 2009-2011, Alan Calvert
+ Copyright 2017 Will Godfrey & others.
This file is part of yoshimi, which is free software: you can redistribute
it and/or modify it under the terms of the GNU Library General Public
@@ -19,7 +20,9 @@
yoshimi; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301, USA.
- This file is derivative of original ZynAddSubFX code, modified January 2011
+ This file is derivative of original ZynAddSubFX code.
+
+ Modified October 2017
*/
#ifndef OSCIL_GEN_H
@@ -64,7 +67,7 @@
// Make a new random seed for Amplitude Randomness -
// should be called every noteon event
- inline void newrandseed(void) { randseed = (unsigned int)random(); }
+ inline void newrandseed(void) { randseed = (unsigned int)randomOG(); }
// Parameters
@@ -117,7 +120,7 @@
bool ADvsPAD; // if it is used by ADsynth or by PADsynth
float numRandom(void);
- unsigned int random(void);
+ unsigned int randomOG(void);
private:
float *tmpsmps;
@@ -204,36 +207,38 @@
unsigned int randseed;
float random_0_1;
+ char random_state[256];
+
+#if (HAVE_RANDOM_R)
int32_t random_result;
struct random_data random_buf;
- char random_state[256];
+#else
+ long int random_result;
+#endif
float harmonic_random_0_1;
+ char harmonic_random_state[256];
+
+#if (HAVE_RANDOM_R)
int32_t harmonic_random_result;
struct random_data harmonic_random_buf;
- char harmonic_random_state[256];
+#else
+ long int harmonic_random_result;
+#endif
};
inline float OscilGen::numRandom(void)
{
- if (!random_r(&random_buf, &random_result))
- {
- random_0_1 = (float)random_result / (float)INT_MAX;
- if (isgreater(random_0_1, 1.0f))
- random_0_1 = 1.0f;
- else if (isless(random_0_1, 0.0f))
- random_0_1 = 0.0f;
- return random_0_1;
- }
- return 0.05f;
-}
-
+ int ret;
+#if (HAVE_RANDOM_R)
+ ret = random_r(&random_buf, &random_result);
+#else
+ random_result = random();
+ ret = 0;
+#endif
-/**
-inline float OscilGen::numRandom(void)
-{
- if (!random_r(&random_buf, &random_result))
+ if (!ret)
{
random_0_1 = (float)random_result / (float)INT_MAX;
random_0_1 = (random_0_1 > 1.0f) ? 1.0f : random_0_1;
@@ -243,12 +248,18 @@
return 0.05f;
}
-**/
-
inline float OscilGen::harmonicRandom(void)
{
- if (!random_r(&harmonic_random_buf, &harmonic_random_result))
+ int ret;
+#if (HAVE_RANDOM_R)
+ ret = random_r(&harmonic_random_buf, &harmonic_random_result);
+#else
+ harmonic_random_result = random();
+ ret = 0;
+#endif
+
+ if (!ret)
{
harmonic_random_0_1 = (float)harmonic_random_result / (float)INT_MAX;
harmonic_random_0_1 = (harmonic_random_0_1 > 1.0f) ? 1.0f : harmonic_random_0_1;
@@ -259,11 +270,16 @@
}
-inline unsigned int OscilGen::random(void)
+inline unsigned int OscilGen::randomOG(void)
{
+#if (HAVE_RANDOM_R)
if (!random_r(&random_buf, &random_result))
return random_result + INT_MAX / 2;
return INT_MAX;
+#else
+ random_result = random();
+ return (unsigned int)random_result + INT_MAX / 2;
+#endif
}
#endif

View file

@ -1,5 +1,5 @@
--- src/Misc/MiscFuncs.cpp.orig 2017-10-15 22:35:17.000000000 +0200
+++ src/Misc/MiscFuncs.cpp 2017-10-19 21:24:37.372316448 +0200
+++ src/Misc/MiscFuncs.cpp 2017-10-22 15:19:00.757619782 +0200
@@ -29,6 +29,7 @@
#include <iostream>
#include <string.h>

View file

@ -1,7 +1,7 @@
# Template file for 'yoshimi'
pkgname=yoshimi
version=1.5.4.1
revision=2
revision=3
build_style=cmake
build_wrksrc=src
hostmakedepends="pkg-config fltk"