Skip to content

Commit

Permalink
Remove dependency on libsamplerate
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwillis committed Jun 30, 2020
1 parent e36c8aa commit a60bef8
Show file tree
Hide file tree
Showing 46 changed files with 44 additions and 391,649 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ On Linux or MacOS, invoke `make` to build Dragonfly Reverb.
* libgl1-mesa-dev
* libjack-jackd2-dev

You can build against the system libsamplerate with using SYSTEM_LIBSAMPLERATE=true at build time. If this flag is not set, the bundled libsamplerate will be used.

You can build against the system freeverb3 with using SYSTEM_FREEVERB3=true at build time. If this flag is not set, the bundled freeverb3 will be used.
You can build against the system freeverb3 with using SYSTEM_FREEVERB3=true at build time. If this flag is not set, the bundled freeverb3 will be used. If SYSTEM_FREEVERB3=true, the build also requires libsamplerate.

### Cross compiling for Windows (on Linux)

Expand Down
23 changes: 1 addition & 22 deletions common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ OBJS += \
freeverb/progenitor.cpp.o \
freeverb/progenitor2.cpp.o \
freeverb/revbase.cpp.o \
freeverb/src.cpp.o \
freeverb/slot.cpp.o \
freeverb/strev.cpp.o \
freeverb/utils.cpp.o \
Expand All @@ -28,31 +27,11 @@ OBJS += \
kiss_fft/kiss_fftr.c.o
endif

ifneq ($(SYSTEM_LIBSAMPLERATE),true)
OBJS += \
libsamplerate2/samplerate.c.o \
libsamplerate2/samplerate_common.c.o \
libsamplerate2/src_common.c.o \
libsamplerate2/src_linear.c.o \
libsamplerate2/src_sinc.c.o \
libsamplerate2/src_zoh.c.o
endif

all: $(OBJS)

ifneq ($(SYSTEM_LIBSAMPLERATE),true)
libsamplerate2/%.c.o: libsamplerate2/%.c
$(CC) $< $(BUILD_C_FLAGS) -I. -DLIBSRATE2_FLOAT -c -o $@
endif


ifneq ($(SYSTEM_FREEVERB3),true)
freeverb/%.cpp.o: freeverb/%.cpp
ifneq ($(SYSTEM_LIBSAMPLERATE),true)
$(CXX) $< $(BUILD_CXX_FLAGS) -I. -DLIBSRATE2_FLOAT -DLIBFV3_FLOAT -Wno-unused-parameter -c -o $@
else
$(CXX) $< $(BUILD_CXX_FLAGS) -I. -DLIBSRATE1 -DLIBFV3_FLOAT -Wno-unused-parameter -c -o $@
endif
$(CXX) $< $(BUILD_CXX_FLAGS) -I. -DLIBFV3_FLOAT -Wno-unused-parameter -c -o $@
endif

kiss_fft/%.c.o: kiss_fft/%.c
Expand Down
4 changes: 0 additions & 4 deletions common/freeverb/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ copyright notices of each sources in this library.
* Copyright (C) 2002 Steve Harris <[email protected]>
* GPLv2 (COPYING)

= libsamplerate-0.1.7
* Erik de Castro Lopo <[email protected]>
* GPLv2 (COPYING)

The following list is copyright notices of original sources or
articles, which are not covered by GPL.

Expand Down
8 changes: 2 additions & 6 deletions common/freeverb/dl_gardner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,9 @@ void FV3_(gd_largeroom)::processreplace(fv3_float_t *inputL, fv3_float_t *inputR
throw(std::bad_alloc)
{
if(numsamples <= 0) return;
long count = numsamples*SRC.getSRCFactor();
try{growWave(count);}catch(std::bad_alloc){throw;}
long count = numsamples;

fv3_float_t outL, outR, *origOutL = outputL, *origOutR = outputR;
SRC.usrc(inputL, inputR, over.L, over.R, numsamples);
inputL = over.L; inputR = over.R; outputL = overO.L; outputR = overO.R;
fv3_float_t outL, outR;

while(count-- > 0)
{
Expand All @@ -119,7 +116,6 @@ void FV3_(gd_largeroom)::processreplace(fv3_float_t *inputL, fv3_float_t *inputR
UNDENORMAL(*outputL); UNDENORMAL(*outputR);
inputL ++; inputR ++; outputL ++; outputR ++;
}
SRC.dsrc(overO.L, overO.R, origOutL, origOutR, numsamples);
}

void FV3_(gd_largeroom)::setFsFactors()
Expand Down
14 changes: 6 additions & 8 deletions common/freeverb/earlyref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,11 @@ fv3_float_t FV3_(earlyref)::getDiffusionApFreq()

void FV3_(earlyref)::setoutputlpf(fv3_float_t value)
{
long factor = getOSFactor();
if(value < 0) value = 0;
if(value > factor*currentfs/2) value = factor*currentfs/2;
if(value > currentfs/2) value = currentfs/2;
outputlpf = value;
out1_lpf.setLPF_BW(outputlpf, factor*currentfs);
out2_lpf.setLPF_BW(outputlpf, factor*currentfs);
out1_lpf.setLPF_BW(outputlpf, currentfs);
out2_lpf.setLPF_BW(outputlpf, currentfs);
}

fv3_float_t FV3_(earlyref)::getoutputlpf() const
Expand All @@ -369,12 +368,11 @@ fv3_float_t FV3_(earlyref)::getoutputlpf() const

void FV3_(earlyref)::setoutputhpf(fv3_float_t value)
{
long factor = getOSFactor();
if(value < 0) value = 0;
if(value > factor*currentfs/2) value = factor*currentfs/2;
if(value > currentfs/2) value = currentfs/2;
outputhpf = value;
out1_hpf.setHPF_BW(outputhpf, factor*currentfs);
out2_hpf.setHPF_BW(outputhpf, factor*currentfs);
out1_hpf.setHPF_BW(outputhpf, currentfs);
out2_hpf.setHPF_BW(outputhpf, currentfs);
}

fv3_float_t FV3_(earlyref)::getoutputhpf() const
Expand Down
5 changes: 0 additions & 5 deletions common/freeverb/fv3_type_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
typedef float fv3_float_t;
#define FV3_(name) name ## _f
#define FFTW_(name) fftwf_ ## name
#ifdef LIBSRATE1
#define SRC_(name) name
#else // LIBSRATE1
#define SRC_(name) name ## _f
#endif // LIBSRATE1
#else
#ifdef LIBFV3_DOUBLE
typedef double fv3_float_t;
Expand Down
132 changes: 1 addition & 131 deletions common/freeverb/nrev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,14 @@ FV3_(nrev)::FV3_(nrev)()
throw(std::bad_alloc)
{
hpf = lpfL = lpfR = 0;
setRearDelay(0);
setrt60(1);
setfeedback(0.7);
setdamp(0.5);
setdamp2(0.5);
setdamp3(0.5);
setwetrear(-10);
setdccutfreq(8);
}

void FV3_(nrev)::setRearDelay(long numsamples)
{
if(initialDelay >= 0)
{
rearDelay = numsamples;
delayRearL.setsize(0);
delayRearR.setsize(0);
}
delayRearL.mute();
delayRearR.mute();
}

long FV3_(nrev)::getRearDelay()
{
return rearDelay;
}

void FV3_(nrev)::printconfig()
{
std::fprintf(stderr, "*** NRev config ***\n");
Expand All @@ -75,66 +56,16 @@ void FV3_(nrev)::mute()
{
allpassL[i].mute(); allpassR[i].mute();
}
overORear.mute();
hpf = lpfL = lpfR = 0;
inDCC.mute(); lLDCC.mute(); lRDCC.mute();
}

void FV3_(nrev)::growWave(long size)
throw(std::bad_alloc)
{
if(size > over.getsize())
{
freeWave();
try
{
FV3_(revbase)::growWave(size);
overORear.alloc(size,2);
}
catch(std::bad_alloc)
{
std::fprintf(stderr, "nrev::growWave(%ld): bad_alloc", size);
freeWave();
throw;
}
}
}

void FV3_(nrev)::freeWave()
{
FV3_(revbase)::freeWave();
overORear.free();
}

void FV3_(nrev)::processreplace(fv3_float_t *inputL, fv3_float_t *inputR, fv3_float_t *outputL, fv3_float_t *outputR, long numsamples)
throw(std::bad_alloc)
{
processreplace(inputL,inputR,outputL,outputR,NULL,NULL,numsamples);
}

void FV3_(nrev)::processreplace(fv3_float_t *inputL, fv3_float_t *inputR, fv3_float_t *outputL, fv3_float_t *outputR,
fv3_float_t *outputRearL, fv3_float_t *outputRearR, long numsamples)
throw(std::bad_alloc)
{
if(numsamples <= 0) return;
long count = numsamples*SRC.getSRCFactor();
try{ growWave(count); }catch(std::bad_alloc){ throw; }
SRC.usrc(inputL, inputR, over.L, over.R, numsamples);
if(outputRearL == NULL||outputRearR == NULL)
{
processloop2(count, over.L, over.R, overO.L, overO.R);
SRC.dsrc(overO.L, overO.R, outputL, outputR, numsamples);
}
else
{
processloop4(count, over.L, over.R, overO.L, overO.R, overORear.L, overORear.R);
SRC.dsrc(overO.L, overO.R, outputL, outputR, numsamples);
SRCRear.dsrc(overORear.L, overORear.R, outputRearL, outputRearR, numsamples);
}
}
long count = numsamples;

void FV3_(nrev)::processloop2(long count, fv3_float_t *inputL, fv3_float_t *inputR, fv3_float_t *outputL, fv3_float_t *outputR)
{
fv3_float_t outL, outR;
while(count-- > 0)
{
Expand Down Expand Up @@ -162,48 +93,6 @@ void FV3_(nrev)::processloop2(long count, fv3_float_t *inputL, fv3_float_t *inpu
}
}

void FV3_(nrev)::processloop4(long count, fv3_float_t *inputL, fv3_float_t *inputR, fv3_float_t *outputL, fv3_float_t *outputR,
fv3_float_t *outRearL, fv3_float_t *outRearR)
{
fv3_float_t outL, outR;
while(count-- > 0)
{
outL = outR = 0;
hpf = damp3_1*inDCC(*inputL + *inputR) - damp3*hpf;
UNDENORMAL(hpf);

hpf *= FV3_NREV_SCALE_WET;

for(long i = 0;i < FV3_NREV_NUM_COMB;i ++) outL += combL[i]._process(hpf);
for(long i = 0;i < 3;i ++) outL = allpassL[i]._process_ov(outL);
lpfL = damp2*lpfL + damp2_1*outL; UNDENORMAL(lpfL);
outL = allpassL[3]._process_ov(lpfL);
*outRearL = allpassL[4]._process_ov(outL);
outL = allpassL[5]._process_ov(outL);
outL = delayWL(lLDCC(outL));

*outRearL = allpassL[7]._process_ov(*outRearL)*wetRear;
*outRearL = delayRearL(*outRearL);
outRearL ++;

for(long i = 0;i < FV3_NREV_NUM_COMB;i ++) outR += combR[i]._process(hpf);
for(long i = 0;i < 3;i ++) outR = allpassR[i]._process_ov(outR);
lpfR = damp2*lpfR + damp2_1*outR; UNDENORMAL(lpfR);
outR = allpassR[3]._process_ov(lpfR);
*outRearR = allpassR[4]._process_ov(outR);
outR = allpassL[6]._process_ov(outR);
outR = delayWR(lRDCC(outR));

*outRearR = allpassL[8]._process_ov(*outRearR)*wetRear;
*outRearR = delayRearR(*outRearR);
outRearR ++;

*outputL = outL*wet1 + outR*wet2 + delayL(*inputL)*dry;
*outputR = outR*wet1 + outL*wet2 + delayR(*inputR)*dry;
inputL ++; inputR ++; outputL ++; outputR ++;
}
}

void FV3_(nrev)::setcombfeedback(fv3_float_t back, long zero)
{
for(long i = 0;i < FV3_NREV_NUM_COMB;i ++)
Expand Down Expand Up @@ -280,25 +169,6 @@ fv3_float_t FV3_(nrev)::getdamp3()
return damp3;
}

void FV3_(nrev)::setwetrear(fv3_float_t value)
{
wetRearReal = value;
wetRear = FV3_(utils)::dB2R(value)*FV3_NREV_SCALE_WET;
}

fv3_float_t FV3_(nrev)::getwetrear()
{
return wetRearReal;
}

void FV3_(nrev)::setOSFactor(long factor, long converter_type)
throw(std::bad_alloc)
{
FV3_(revbase)::setOSFactor(factor, converter_type);
SRCRear.setSRCFactor(factor, converter_type);
setFsFactors();
}

void FV3_(nrev)::setdccutfreq(fv3_float_t value)
{
dccutfq = limFs2(value);
Expand Down
31 changes: 3 additions & 28 deletions common/freeverb/nrev_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,10 @@ class _FV3_(nrev) : public _FV3_(revbase)
public:
_FV3_(nrev)() throw(std::bad_alloc);
virtual void mute();
virtual void setOSFactor(long factor, long converter_type) throw(std::bad_alloc);
void processreplace(_fv3_float_t *inputL, _fv3_float_t *inputR, _fv3_float_t *outputL, _fv3_float_t *outputR,
_fv3_float_t *outputRearL, _fv3_float_t *outputRearR, long numsamples)
throw(std::bad_alloc);

void processreplace(_fv3_float_t *inputL, _fv3_float_t *inputR, _fv3_float_t *outputL, _fv3_float_t *outputR, long numsamples)
throw(std::bad_alloc);

/**
* set the delay length of the reverb rear sound.
* @param[in] value reverb time in samples (not seconds).
*/
void setRearDelay(long numsamples);
long getRearDelay();

/**
* set the time length (T60/RT60) of the reverb.
* @param[in] value reverb time in seconds.
Expand Down Expand Up @@ -72,13 +62,6 @@ class _FV3_(nrev) : public _FV3_(revbase)
void setdamp3(_fv3_float_t value);
_fv3_float_t getdamp3();

/**
* set the reverb rear sound level.
* @param[in] value dB level.
*/
void setwetrear(_fv3_float_t value);
_fv3_float_t getwetrear();

/**
* set the cut on frequency of the input signals' DC cut filter.
* @param[in] value actual freqneucy.
Expand All @@ -89,21 +72,13 @@ class _FV3_(nrev) : public _FV3_(revbase)
virtual void printconfig();

protected:
virtual void processloop2(long count, _fv3_float_t *inputL, _fv3_float_t *inputR, _fv3_float_t *outputL, _fv3_float_t *outputR);
virtual void processloop4(long count, _fv3_float_t *inputL, _fv3_float_t *inputR, _fv3_float_t *outputL, _fv3_float_t *outputR,
_fv3_float_t *outRearL, _fv3_float_t *outRearR);
virtual void growWave(long size) throw(std::bad_alloc);
virtual void freeWave();
virtual void setcombfeedback(_fv3_float_t back, long zero);
virtual void setFsFactors();
_FV3_(slot) overORear;
_fv3_float_t roomsize, feedback, damp, damp2, damp2_1, damp3, damp3_1;
_fv3_float_t wetRearReal, wetRear, dccutfq;
_fv3_float_t dccutfq;
_FV3_(allpass) allpassL[FV3_NREV_NUM_ALLPASS], allpassR[FV3_NREV_NUM_ALLPASS];
_FV3_(comb) combL[FV3_NREV_NUM_COMB], combR[FV3_NREV_NUM_COMB];
_FV3_(src) SRCRear;
long rearDelay;
_FV3_(delay) delayRearL, delayRearR;

const static long combCo[FV3_NREV_NUM_COMB], allpassCo[FV3_NREV_NUM_ALLPASS];
_FV3_(dccut) inDCC, lLDCC, lRDCC;
// work values
Expand Down
8 changes: 2 additions & 6 deletions common/freeverb/progenitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,9 @@ void FV3_(progenitor)::processreplace(fv3_float_t *inputL, fv3_float_t *inputR,
throw(std::bad_alloc)
{
if(numsamples <= 0) return;
long count = numsamples*getOSFactor();
try{growWave(count);}catch(std::bad_alloc){throw;}
long count = numsamples;

fv3_float_t outL, outR, *origOutL = outputL, *origOutR = outputR;
SRC.usrc(inputL, inputR, over.L, over.R, numsamples);
inputL = over.L; inputR = over.R; outputL = overO.L; outputR = overO.R;
fv3_float_t outL, outR;

while(count-- > 0)
{
Expand Down Expand Up @@ -148,7 +145,6 @@ void FV3_(progenitor)::processreplace(fv3_float_t *inputL, fv3_float_t *inputR,
UNDENORMAL(*outputL); UNDENORMAL(*outputR);
inputL ++; inputR ++; outputL ++; outputR ++;
}
SRC.dsrc(overO.L, overO.R, origOutL, origOutR, numsamples);
}

void FV3_(progenitor)::setdccutfreq(fv3_float_t value)
Expand Down
Loading

0 comments on commit a60bef8

Please sign in to comment.