308 lines
9.2 KiB
Diff
308 lines
9.2 KiB
Diff
--- src/Misc/SynthEngine.cpp.orig 2017-10-15 22:35:17.000000000 +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 (HAVE_RANDOM_R)
|
|
memset(&random_buf, 0, sizeof(random_buf));
|
|
|
|
if (initstate_r(samplerate + buffersize + oscilsize, random_state,
|
|
sizeof(random_state), &random_buf))
|
|
Runtime.Log("SynthEngine Init failed on general randomness");
|
|
+#else
|
|
+ if (!initstate(samplerate + buffersize + oscilsize, random_state, sizeof(random_state)))
|
|
+ Runtime.Log("SynthEngine Init failed on general randomness");
|
|
+#endif
|
|
|
|
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
|