Skip to content

Commit 7aba3f2

Browse files
committed
JDSP4Linux relevant changes
1 parent c082020 commit 7aba3f2

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/liveprogWrapper.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ void NSEEL_HOSTSTUB_LeaveMutex() { }
44
void LiveProgConstructor(JamesDSPLib *jdsp)
55
{
66
LiveProg *pg = &jdsp->eel;
7+
pg->active = 1;
78
pg->compileSucessfully = 0;
89
pg->codehandleInit = 0;
910
pg->codehandleProcess = 0;
@@ -148,7 +149,7 @@ int LiveProgStringParser(JamesDSPLib *jdsp, char *eelCode)
148149
void LiveProgProcess(JamesDSPLib *jdsp, size_t n)
149150
{
150151
LiveProg *eel = &jdsp->eel;
151-
if (eel->compileSucessfully)
152+
if (eel->compileSucessfully && eel->active)
152153
{
153154
for (size_t i = 0; i < n; i++)
154155
{
@@ -159,4 +160,4 @@ void LiveProgProcess(JamesDSPLib *jdsp, size_t n)
159160
jdsp->tmpBuffer[1][i] = (float)*eel->input2;
160161
}
161162
}
162-
}
163+
}

Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/reverb.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ static inline void delay_make(sf_rv_delay_st *delay, int size)
7878

7979
static inline float delay_step(sf_rv_delay_st *delay, float v)
8080
{
81+
// Prevent FPE due to division by zero! Usually caused by an empty delay buffer (init phase)
82+
if(delay->size == 0)
83+
{
84+
return 0;
85+
}
86+
8187
float out = delay->buf[delay->pos];
8288
delay->buf[delay->pos] = v;
8389
delay->pos = (delay->pos + 1) % delay->size;

Main/libjamesdsp/jni/jamesdsp/jdsp/Effects/stereoEnhancement.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ void analysisWarpedPFBStereo(WarpedPFB *pfb1, WarpedPFB *pfb2, float *x1, float
99
void synthesisWarpedPFBStereo(WarpedPFB *pfb1, WarpedPFB *pfb2, float *y1, float *y2);
1010
void StereoEnhancementSetParam(JamesDSPLib *jdsp, float mix)
1111
{
12+
jdsp_lock(jdsp);
1213
jdsp->sterEnh.mix = mix;
1314
jdsp->sterEnh.minusMix = 1.0f - jdsp->sterEnh.mix;
1415
if (jdsp->sterEnh.mix > 0.5f)
@@ -36,17 +37,22 @@ void StereoEnhancementSetParam(JamesDSPLib *jdsp, float mix)
3637
float ms = 0.75f; // 0.75 ms
3738
for (unsigned int i = 0; i < 5; i++)
3839
jdsp->sterEnh.emaAlpha[i] = 1.0f - powf(10.0f, (log10f(0.5f) / (ms / 1000.0f) / (jdsp->fs / (float)Sk[i])));
40+
jdsp_unlock(jdsp);
3941
}
4042
void StereoEnhancementConstructor(JamesDSPLib *jdsp)
4143
{
44+
jdsp_lock(jdsp);
4245
jdsp->sterEnh.subband[1] = jdsp->sterEnh.subband[0] = 0;
46+
jdsp_unlock(jdsp);
4347
}
4448
void StereoEnhancementDestructor(JamesDSPLib *jdsp)
4549
{
50+
jdsp_lock(jdsp);
4651
if (jdsp->sterEnh.subband[0])
4752
free(jdsp->sterEnh.subband[0]);
4853
if (jdsp->sterEnh.subband[1])
4954
free(jdsp->sterEnh.subband[1]);
55+
jdsp_unlock(jdsp);
5056
}
5157
void StereoEnhancementEnable(JamesDSPLib *jdsp)
5258
{
@@ -88,4 +94,4 @@ void StereoEnhancementProcess(JamesDSPLib *jdsp, size_t n)
8894
jdsp->tmpBuffer[0][i] = y1 * snh->gain;
8995
jdsp->tmpBuffer[1][i] = y2 * snh->gain;
9096
}
91-
}
97+
}

Main/libjamesdsp/jni/jamesdsp/jdsp/jdsp_header.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ typedef enum
348348
SF_REVERB_PRESET_LONGREVERB1,
349349
SF_REVERB_PRESET_LONGREVERB2
350350
} sf_reverb_preset;
351+
extern void sf_advancereverb(sf_reverb_state_st *rv, int rate, int oversamplefactor, float ertolate, float erefwet, float dry, float ereffactor, float erefwidth, float width, float wet, float wander, float bassb, float spin, float inputlpf, float basslpf, float damplpf, float outputlpf, float rt60, float delay);
352+
351353
typedef struct
352354
{
353355
char *subband[2];
@@ -362,6 +364,7 @@ typedef struct
362364
NSEEL_CODEHANDLE codehandleInit, codehandleProcess;
363365
float *vmFs, *input1, *input2;
364366
int compileSucessfully;
367+
int active;
365368
} LiveProg;
366369
typedef struct
367370
{

0 commit comments

Comments
 (0)