* ReverbSC: Method to change samplerate (#3401) * ReverbSC: added mutex for protected malloc * ReverbSC: small CMake fix to remove warning message * ReverbSC: samplerate changed to uint32_t. more CMakeFile tweaks * Fix dc block on oversampling
This commit is contained in:
committed by
Oskar Wallgren
parent
69d09f0186
commit
f390fd1723
@@ -12,13 +12,13 @@ BUILD_PLUGIN(
|
||||
ReverbSCControlDialog.cpp
|
||||
base.c
|
||||
revsc.c
|
||||
dcblock.c
|
||||
MOCFILES
|
||||
ReverbSC.h
|
||||
ReverbSCControls.h
|
||||
ReverbSCControlDialog.h
|
||||
base.h
|
||||
revsc.h
|
||||
dcblock.h
|
||||
dcblock.c
|
||||
ReverbSC.h
|
||||
MOCFILES
|
||||
ReverbSCControls.h
|
||||
ReverbSCControlDialog.h
|
||||
EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png"
|
||||
)
|
||||
|
||||
@@ -58,8 +58,8 @@ ReverbSCEffect::ReverbSCEffect( Model* parent, const Descriptor::SubPluginFeatur
|
||||
sp_dcblock_create(&dcblk[0]);
|
||||
sp_dcblock_create(&dcblk[1]);
|
||||
|
||||
sp_dcblock_init(sp, dcblk[0]);
|
||||
sp_dcblock_init(sp, dcblk[1]);
|
||||
sp_dcblock_init(sp, dcblk[0], Engine::mixer()->currentQualitySettings().sampleRateMultiplier() );
|
||||
sp_dcblock_init(sp, dcblk[1], Engine::mixer()->currentQualitySettings().sampleRateMultiplier() );
|
||||
}
|
||||
|
||||
ReverbSCEffect::~ReverbSCEffect()
|
||||
@@ -125,6 +125,27 @@ bool ReverbSCEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
|
||||
|
||||
return isRunning();
|
||||
}
|
||||
|
||||
void ReverbSCEffect::changeSampleRate()
|
||||
{
|
||||
// Change sr variable in Soundpipe. does not need to be destroyed
|
||||
sp->sr = Engine::mixer()->processingSampleRate();
|
||||
|
||||
mutex.lock();
|
||||
sp_revsc_destroy(&revsc);
|
||||
sp_dcblock_destroy(&dcblk[0]);
|
||||
sp_dcblock_destroy(&dcblk[1]);
|
||||
|
||||
sp_revsc_create(&revsc);
|
||||
sp_revsc_init(sp, revsc);
|
||||
|
||||
sp_dcblock_create(&dcblk[0]);
|
||||
sp_dcblock_create(&dcblk[1]);
|
||||
|
||||
sp_dcblock_init(sp, dcblk[0], Engine::mixer()->currentQualitySettings().sampleRateMultiplier() );
|
||||
sp_dcblock_init(sp, dcblk[1], Engine::mixer()->currentQualitySettings().sampleRateMultiplier() );
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
@@ -48,12 +48,14 @@ public:
|
||||
return &m_reverbSCControls;
|
||||
}
|
||||
|
||||
void changeSampleRate();
|
||||
|
||||
private:
|
||||
ReverbSCControls m_reverbSCControls;
|
||||
sp_data *sp;
|
||||
sp_revsc *revsc;
|
||||
sp_dcblock *dcblk[2];
|
||||
QMutex mutex;
|
||||
friend class ReverbSCControls;
|
||||
} ;
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ ReverbSCControls::ReverbSCControls( ReverbSCEffect* effect ) :
|
||||
m_colorModel( 10000.0f, 100.0f, 15000.0f, 0.1f, this, tr( "Color" ) ),
|
||||
m_outputGainModel( 0.0f, -60.0f, 15, 0.1f, this, tr( "Output Gain" ) )
|
||||
{
|
||||
connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() ));
|
||||
}
|
||||
|
||||
void ReverbSCControls::changeControl()
|
||||
@@ -60,3 +61,7 @@ void ReverbSCControls::saveSettings( QDomDocument& doc, QDomElement& _this )
|
||||
m_outputGainModel.saveSettings( doc, _this, "output_gain" );
|
||||
}
|
||||
|
||||
void ReverbSCControls::changeSampleRate()
|
||||
{
|
||||
m_effect->changeSampleRate();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void changeControl();
|
||||
void changeSampleRate();
|
||||
|
||||
private:
|
||||
ReverbSCEffect* m_effect;
|
||||
|
||||
@@ -25,7 +25,7 @@ typedef struct sp_auxdata {
|
||||
|
||||
typedef struct sp_data {
|
||||
SPFLOAT *out;
|
||||
int sr;
|
||||
uint32_t sr;
|
||||
int nchan;
|
||||
unsigned long len;
|
||||
unsigned long pos;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include "base.h"
|
||||
#include "dcblock.h"
|
||||
@@ -26,11 +27,11 @@ int sp_dcblock_destroy(sp_dcblock **p)
|
||||
return SP_OK;
|
||||
}
|
||||
|
||||
int sp_dcblock_init(sp_data *sp, sp_dcblock *p)
|
||||
int sp_dcblock_init(sp_data *sp, sp_dcblock *p, int oversampling )
|
||||
{
|
||||
p->outputs = 0.0;
|
||||
p->inputs = 0.0;
|
||||
p->gain = 0.99;
|
||||
p->gain = pow( 0.99, 1.0f / oversampling );
|
||||
if (p->gain == 0.0 || p->gain>=1.0 || p->gain<=-1.0)
|
||||
p->gain = 0.99;
|
||||
return SP_OK;
|
||||
|
||||
@@ -7,5 +7,5 @@ typedef struct {
|
||||
|
||||
int sp_dcblock_create(sp_dcblock **p);
|
||||
int sp_dcblock_destroy(sp_dcblock **p);
|
||||
int sp_dcblock_init(sp_data *sp, sp_dcblock *p);
|
||||
int sp_dcblock_init(sp_data *sp, sp_dcblock *p, int oversampling );
|
||||
int sp_dcblock_compute(sp_data *sp, sp_dcblock *p, SPFLOAT *in, SPFLOAT *out);
|
||||
|
||||
Reference in New Issue
Block a user