Freeverb3: make it work properly on all samplerates

This commit is contained in:
Vesa
2014-11-09 21:01:31 +02:00
parent f207613d5f
commit b441bdae15
4 changed files with 59 additions and 56 deletions

View File

@@ -581,7 +581,6 @@ sample_rate_t LadspaEffect::maxSamplerate( const QString & _name )
__buggy_plugins["C* AmpVTS"] = 88200;
__buggy_plugins["Chorus2"] = 44100;
__buggy_plugins["Notch Filter"] = 96000;
__buggy_plugins["Freeverb"] = 44100;
__buggy_plugins["TAP Reflector"] = 192000;
}
if( __buggy_plugins.contains( _name ) )

View File

@@ -6,33 +6,34 @@
#include "revmodel.h"
revmodel::revmodel()
revmodel::revmodel( float sampleRatio ) :
m_sampleRatio( sampleRatio )
{
// Tie the components to their buffers
combL[0].setbuffer(bufcombL1,combtuningL1);
combR[0].setbuffer(bufcombR1,combtuningR1);
combL[1].setbuffer(bufcombL2,combtuningL2);
combR[1].setbuffer(bufcombR2,combtuningR2);
combL[2].setbuffer(bufcombL3,combtuningL3);
combR[2].setbuffer(bufcombR3,combtuningR3);
combL[3].setbuffer(bufcombL4,combtuningL4);
combR[3].setbuffer(bufcombR4,combtuningR4);
combL[4].setbuffer(bufcombL5,combtuningL5);
combR[4].setbuffer(bufcombR5,combtuningR5);
combL[5].setbuffer(bufcombL6,combtuningL6);
combR[5].setbuffer(bufcombR6,combtuningR6);
combL[6].setbuffer(bufcombL7,combtuningL7);
combR[6].setbuffer(bufcombR7,combtuningR7);
combL[7].setbuffer(bufcombL8,combtuningL8);
combR[7].setbuffer(bufcombR8,combtuningR8);
allpassL[0].setbuffer(bufallpassL1,allpasstuningL1);
allpassR[0].setbuffer(bufallpassR1,allpasstuningR1);
allpassL[1].setbuffer(bufallpassL2,allpasstuningL2);
allpassR[1].setbuffer(bufallpassR2,allpasstuningR2);
allpassL[2].setbuffer(bufallpassL3,allpasstuningL3);
allpassR[2].setbuffer(bufallpassR3,allpasstuningR3);
allpassL[3].setbuffer(bufallpassL4,allpasstuningL4);
allpassR[3].setbuffer(bufallpassR4,allpasstuningR4);
combL[0].setbuffer(bufcombL1,static_cast<int>( combtuningL1 * m_sampleRatio ));
combR[0].setbuffer(bufcombR1,static_cast<int>( combtuningR1 * m_sampleRatio ));
combL[1].setbuffer(bufcombL2,static_cast<int>( combtuningL2 * m_sampleRatio ));
combR[1].setbuffer(bufcombR2,static_cast<int>( combtuningR2 * m_sampleRatio ));
combL[2].setbuffer(bufcombL3,static_cast<int>( combtuningL3 * m_sampleRatio ));
combR[2].setbuffer(bufcombR3,static_cast<int>( combtuningR3 * m_sampleRatio ));
combL[3].setbuffer(bufcombL4,static_cast<int>( combtuningL4 * m_sampleRatio ));
combR[3].setbuffer(bufcombR4,static_cast<int>( combtuningR4 * m_sampleRatio ));
combL[4].setbuffer(bufcombL5,static_cast<int>( combtuningL5 * m_sampleRatio ));
combR[4].setbuffer(bufcombR5,static_cast<int>( combtuningR5 * m_sampleRatio ));
combL[5].setbuffer(bufcombL6,static_cast<int>( combtuningL6 * m_sampleRatio ));
combR[5].setbuffer(bufcombR6,static_cast<int>( combtuningR6 * m_sampleRatio ));
combL[6].setbuffer(bufcombL7,static_cast<int>( combtuningL7 * m_sampleRatio ));
combR[6].setbuffer(bufcombR7,static_cast<int>( combtuningR7 * m_sampleRatio ));
combL[7].setbuffer(bufcombL8,static_cast<int>( combtuningL8 * m_sampleRatio ));
combR[7].setbuffer(bufcombR8,static_cast<int>( combtuningR8 * m_sampleRatio ));
allpassL[0].setbuffer(bufallpassL1,static_cast<int>( allpasstuningL1 * m_sampleRatio ));
allpassR[0].setbuffer(bufallpassR1,static_cast<int>( allpasstuningR1 * m_sampleRatio ));
allpassL[1].setbuffer(bufallpassL2,static_cast<int>( allpasstuningL2 * m_sampleRatio ));
allpassR[1].setbuffer(bufallpassR2,static_cast<int>( allpasstuningR2 * m_sampleRatio ));
allpassL[2].setbuffer(bufallpassL3,static_cast<int>( allpasstuningL3 * m_sampleRatio ));
allpassR[2].setbuffer(bufallpassR3,static_cast<int>( allpasstuningR3 * m_sampleRatio ));
allpassL[3].setbuffer(bufallpassL4,static_cast<int>( allpasstuningL4 * m_sampleRatio ));
allpassR[3].setbuffer(bufallpassR4,static_cast<int>( allpasstuningR4 * m_sampleRatio ));
// Set default values
allpassL[0].setfeedback(0.5f);

View File

@@ -11,10 +11,12 @@
#include "allpass.h"
#include "tuning.h"
const int maxSampleRatio = 18; // enough for largest possible samplerate, 8 * 96000
class revmodel
{
public:
revmodel();
revmodel( float sampleRatio );
void mute();
void processmix(float *inputL, float *inputR, float *outputL, float *outputR, long numsamples, int skip);
void processreplace(float *inputL, float *inputR, float *outputL, float *outputR, long numsamples, int skip);
@@ -40,6 +42,8 @@ private:
float dry;
float width;
float mode;
float m_sampleRatio;
// The following are all declared inline
// to remove the need for dynamic allocation
@@ -54,32 +58,32 @@ private:
allpass allpassR[numallpasses];
// Buffers for the combs
float bufcombL1[combtuningL1];
float bufcombR1[combtuningR1];
float bufcombL2[combtuningL2];
float bufcombR2[combtuningR2];
float bufcombL3[combtuningL3];
float bufcombR3[combtuningR3];
float bufcombL4[combtuningL4];
float bufcombR4[combtuningR4];
float bufcombL5[combtuningL5];
float bufcombR5[combtuningR5];
float bufcombL6[combtuningL6];
float bufcombR6[combtuningR6];
float bufcombL7[combtuningL7];
float bufcombR7[combtuningR7];
float bufcombL8[combtuningL8];
float bufcombR8[combtuningR8];
float bufcombL1[combtuningL1 * maxSampleRatio];
float bufcombR1[combtuningR1 * maxSampleRatio];
float bufcombL2[combtuningL2 * maxSampleRatio];
float bufcombR2[combtuningR2 * maxSampleRatio];
float bufcombL3[combtuningL3 * maxSampleRatio];
float bufcombR3[combtuningR3 * maxSampleRatio];
float bufcombL4[combtuningL4 * maxSampleRatio];
float bufcombR4[ combtuningR4 * maxSampleRatio ];
float bufcombL5[ combtuningL5 * maxSampleRatio ];
float bufcombR5[ combtuningR5 * maxSampleRatio ];
float bufcombL6[ combtuningL6 * maxSampleRatio ];
float bufcombR6[ combtuningR6 * maxSampleRatio ];
float bufcombL7[ combtuningL7 * maxSampleRatio ];
float bufcombR7[ combtuningR7 * maxSampleRatio ];
float bufcombL8[ combtuningL8 * maxSampleRatio ];
float bufcombR8[ combtuningR8 * maxSampleRatio ];
// Buffers for the allpasses
float bufallpassL1[allpasstuningL1];
float bufallpassR1[allpasstuningR1];
float bufallpassL2[allpasstuningL2];
float bufallpassR2[allpasstuningR2];
float bufallpassL3[allpasstuningL3];
float bufallpassR3[allpasstuningR3];
float bufallpassL4[allpasstuningL4];
float bufallpassR4[allpasstuningR4];
float bufallpassL1[ allpasstuningL1 * maxSampleRatio ];
float bufallpassR1[ allpasstuningR1 * maxSampleRatio ];
float bufallpassL2[ allpasstuningL2 * maxSampleRatio ];
float bufallpassR2[ allpasstuningR2 * maxSampleRatio ];
float bufallpassL3[ allpasstuningL3 * maxSampleRatio ];
float bufallpassR3[ allpasstuningR3 * maxSampleRatio ];
float bufallpassL4[ allpasstuningL4 * maxSampleRatio ];
float bufallpassR4[ allpasstuningR4 * maxSampleRatio ];
};
#endif//_revmodel_

View File

@@ -57,14 +57,13 @@ class Freeverb3 : public CMT_PluginInstance, public revmodel {
public:
Freeverb3(const LADSPA_Descriptor *, unsigned long lSampleRate)
: CMT_PluginInstance(FV_NumPorts) {
/* Richard's note 17/5/2000. Hmm - not sure I like the fact that
lSampleRate isn't actually used in this function! */
}
: CMT_PluginInstance(FV_NumPorts),
revmodel( (float) lSampleRate / 44100.0f )
{}
friend void activateFreeverb3(LADSPA_Handle Instance);
friend void runFreeverb3(LADSPA_Handle Instance,
unsigned long SampleCount);
};
/*****************************************************************************/