Remove global oversampling (#7228)

Oversampling can have many different effects to the audio signal such as latency, phase issues, clipping, smearing, etc, so this should really be an option on a per-plugin basis, not globally across all of LMMS (which, in some places, shouldn't really need to oversample at all but were oversampled anyways).
This commit is contained in:
saker
2024-05-05 04:37:43 -04:00
committed by GitHub
parent 9bdc8adf33
commit 9b6e33aa5c
75 changed files with 155 additions and 373 deletions

View File

@@ -284,7 +284,7 @@ auto AudioFileProcessor::beatLen(NotePlayHandle* note) const -> int
// Otherwise, use the remaining sample duration
const auto baseFreq = instrumentTrack()->baseFreq();
const auto freqFactor = baseFreq / note->frequency()
* Engine::audioEngine()->processingSampleRate()
* Engine::audioEngine()->outputSampleRate()
/ Engine::audioEngine()->baseSampleRate();
const auto startFrame = m_nextPlayStartPoint >= m_sample.endFrame()

View File

@@ -118,7 +118,7 @@ bool BassBoosterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames
inline void BassBoosterEffect::changeFrequency()
{
const sample_t fac = Engine::audioEngine()->processingSampleRate() / 44100.0f;
const sample_t fac = Engine::audioEngine()->outputSampleRate() / 44100.0f;
m_bbFX.leftFX().setFrequency( m_bbControls.m_freqModel.value() * fac );
m_bbFX.rightFX().setFrequency( m_bbControls.m_freqModel.value() * fac );

View File

@@ -265,7 +265,7 @@ void BitInvader::playNote( NotePlayHandle * _n,
const_cast<float*>( m_graph.samples() ),
_n,
m_interpolation.value(), factor,
Engine::audioEngine()->processingSampleRate() );
Engine::audioEngine()->outputSampleRate() );
}
const fpp_t frames = _n->framesLeftForCurrentPeriod();

View File

@@ -59,7 +59,7 @@ Plugin::Descriptor PLUGIN_EXPORT bitcrush_plugin_descriptor =
BitcrushEffect::BitcrushEffect( Model * parent, const Descriptor::SubPluginFeatures::Key * key ) :
Effect( &bitcrush_plugin_descriptor, parent, key ),
m_controls( this ),
m_sampleRate( Engine::audioEngine()->processingSampleRate() ),
m_sampleRate( Engine::audioEngine()->outputSampleRate() ),
m_filter( m_sampleRate )
{
m_buffer = new sampleFrame[Engine::audioEngine()->framesPerPeriod() * OS_RATE];
@@ -83,7 +83,7 @@ BitcrushEffect::~BitcrushEffect()
void BitcrushEffect::sampleRateChanged()
{
m_sampleRate = Engine::audioEngine()->processingSampleRate();
m_sampleRate = Engine::audioEngine()->outputSampleRate();
m_filter.setSampleRate( m_sampleRate );
m_filter.setLowpass( m_sampleRate * ( CUTOFF_RATIO * OS_RATIO ) );
m_needsUpdate = true;

View File

@@ -259,7 +259,7 @@ uint32_t CarlaInstrument::handleGetBufferSize() const
double CarlaInstrument::handleGetSampleRate() const
{
return Engine::audioEngine()->processingSampleRate();
return Engine::audioEngine()->outputSampleRate();
}
bool CarlaInstrument::handleIsOffline() const

View File

@@ -56,7 +56,7 @@ CompressorEffect::CompressorEffect(Model* parent, const Descriptor::SubPluginFea
Effect(&compressor_plugin_descriptor, parent, key),
m_compressorControls(this)
{
m_sampleRate = Engine::audioEngine()->processingSampleRate();
m_sampleRate = Engine::audioEngine()->outputSampleRate();
m_yL[0] = m_yL[1] = COMP_NOISE_FLOOR;
@@ -560,7 +560,7 @@ inline void CompressorEffect::calcTiltFilter(sample_t inputSample, sample_t &out
void CompressorEffect::changeSampleRate()
{
m_sampleRate = Engine::audioEngine()->processingSampleRate();
m_sampleRate = Engine::audioEngine()->outputSampleRate();
m_coeffPrecalc = COMP_LOG / (m_sampleRate * 0.001f);

View File

@@ -55,7 +55,7 @@ Plugin::Descriptor PLUGIN_EXPORT crossovereq_plugin_descriptor =
CrossoverEQEffect::CrossoverEQEffect( Model* parent, const Descriptor::SubPluginFeatures::Key* key ) :
Effect( &crossovereq_plugin_descriptor, parent, key ),
m_controls( this ),
m_sampleRate( Engine::audioEngine()->processingSampleRate() ),
m_sampleRate( Engine::audioEngine()->outputSampleRate() ),
m_lp1( m_sampleRate ),
m_lp2( m_sampleRate ),
m_lp3( m_sampleRate ),
@@ -78,7 +78,7 @@ CrossoverEQEffect::~CrossoverEQEffect()
void CrossoverEQEffect::sampleRateChanged()
{
m_sampleRate = Engine::audioEngine()->processingSampleRate();
m_sampleRate = Engine::audioEngine()->outputSampleRate();
m_lp1.setSampleRate( m_sampleRate );
m_lp2.setSampleRate( m_sampleRate );
m_lp3.setSampleRate( m_sampleRate );

View File

@@ -58,8 +58,8 @@ DelayEffect::DelayEffect( Model* parent, const Plugin::Descriptor::SubPluginFeat
m_delayControls( this )
{
m_delay = 0;
m_delay = new StereoDelay( 20, Engine::audioEngine()->processingSampleRate() );
m_lfo = new Lfo( Engine::audioEngine()->processingSampleRate() );
m_delay = new StereoDelay( 20, Engine::audioEngine()->outputSampleRate() );
m_lfo = new Lfo( Engine::audioEngine()->outputSampleRate() );
m_outGain = 1.0;
}
@@ -88,7 +88,7 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
return( false );
}
double outSum = 0.0;
const float sr = Engine::audioEngine()->processingSampleRate();
const float sr = Engine::audioEngine()->outputSampleRate();
const float d = dryLevel();
const float w = wetLevel();
auto dryS = std::array<sample_t, 2>{};
@@ -123,7 +123,7 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
m_delay->setFeedback( *feedbackPtr );
m_lfo->setFrequency( *lfoTimePtr );
m_currentLength = static_cast<int>(*lengthPtr * Engine::audioEngine()->processingSampleRate());
m_currentLength = static_cast<int>(*lengthPtr * Engine::audioEngine()->outputSampleRate());
m_delay->setLength( m_currentLength + ( *amplitudePtr * ( float )m_lfo->tick() ) );
m_delay->tick( buf[f] );
@@ -151,8 +151,8 @@ bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
void DelayEffect::changeSampleRate()
{
m_lfo->setSampleRate( Engine::audioEngine()->processingSampleRate() );
m_delay->setSampleRate( Engine::audioEngine()->processingSampleRate() );
m_lfo->setSampleRate( Engine::audioEngine()->outputSampleRate() );
m_delay->setSampleRate( Engine::audioEngine()->outputSampleRate() );
}

View File

@@ -52,7 +52,7 @@ Plugin::Descriptor PLUGIN_EXPORT dispersion_plugin_descriptor =
DispersionEffect::DispersionEffect(Model* parent, const Descriptor::SubPluginFeatures::Key* key) :
Effect(&dispersion_plugin_descriptor, parent, key),
m_dispersionControls(this),
m_sampleRate(Engine::audioEngine()->processingSampleRate()),
m_sampleRate(Engine::audioEngine()->outputSampleRate()),
m_amountVal(0)
{
}

View File

@@ -57,8 +57,8 @@ DualFilterEffect::DualFilterEffect( Model* parent, const Descriptor::SubPluginFe
Effect( &dualfilter_plugin_descriptor, parent, key ),
m_dfControls( this )
{
m_filter1 = new BasicFilters<2>( Engine::audioEngine()->processingSampleRate() );
m_filter2 = new BasicFilters<2>( Engine::audioEngine()->processingSampleRate() );
m_filter1 = new BasicFilters<2>( Engine::audioEngine()->outputSampleRate() );
m_filter2 = new BasicFilters<2>( Engine::audioEngine()->outputSampleRate() );
// ensure filters get updated
m_filter1changed = true;

View File

@@ -111,8 +111,8 @@ void DualFilterControls::updateFilters()
delete m_effect->m_filter1;
delete m_effect->m_filter2;
m_effect->m_filter1 = new BasicFilters<2>( Engine::audioEngine()->processingSampleRate() );
m_effect->m_filter2 = new BasicFilters<2>( Engine::audioEngine()->processingSampleRate() );
m_effect->m_filter1 = new BasicFilters<2>( Engine::audioEngine()->outputSampleRate() );
m_effect->m_filter2 = new BasicFilters<2>( Engine::audioEngine()->outputSampleRate() );
// flag filters as needing recalculation

View File

@@ -64,8 +64,8 @@ DynProcEffect::DynProcEffect( Model * _parent,
m_dpControls( this )
{
m_currentPeak[0] = m_currentPeak[1] = DYN_NOISE_FLOOR;
m_rms[0] = new RmsHelper( 64 * Engine::audioEngine()->processingSampleRate() / 44100 );
m_rms[1] = new RmsHelper( 64 * Engine::audioEngine()->processingSampleRate() / 44100 );
m_rms[0] = new RmsHelper( 64 * Engine::audioEngine()->outputSampleRate() / 44100 );
m_rms[1] = new RmsHelper( 64 * Engine::audioEngine()->outputSampleRate() / 44100 );
calcAttack();
calcRelease();
}
@@ -82,12 +82,12 @@ DynProcEffect::~DynProcEffect()
inline void DynProcEffect::calcAttack()
{
m_attCoeff = std::exp((DNF_LOG / (m_dpControls.m_attackModel.value() * 0.001)) / Engine::audioEngine()->processingSampleRate());
m_attCoeff = std::exp((DNF_LOG / (m_dpControls.m_attackModel.value() * 0.001)) / Engine::audioEngine()->outputSampleRate());
}
inline void DynProcEffect::calcRelease()
{
m_relCoeff = std::exp((DNF_LOG / (m_dpControls.m_releaseModel.value() * 0.001)) / Engine::audioEngine()->processingSampleRate());
m_relCoeff = std::exp((DNF_LOG / (m_dpControls.m_releaseModel.value() * 0.001)) / Engine::audioEngine()->outputSampleRate());
}
@@ -122,8 +122,8 @@ bool DynProcEffect::processAudioBuffer( sampleFrame * _buf,
if( m_needsUpdate )
{
m_rms[0]->setSize( 64 * Engine::audioEngine()->processingSampleRate() / 44100 );
m_rms[1]->setSize( 64 * Engine::audioEngine()->processingSampleRate() / 44100 );
m_rms[0]->setSize( 64 * Engine::audioEngine()->outputSampleRate() / 44100 );
m_rms[1]->setSize( 64 * Engine::audioEngine()->outputSampleRate() / 44100 );
calcAttack();
calcRelease();
m_needsUpdate = false;

View File

@@ -201,7 +201,7 @@ bool EqHandle::mousePressed() const
float EqHandle::getPeakCurve( float x )
{
double freqZ = xPixelToFreq( EqHandle::x(), m_width );
const int SR = Engine::audioEngine()->processingSampleRate();
const int SR = Engine::audioEngine()->outputSampleRate();
double w0 = 2 * LD_PI * freqZ / SR ;
double c = cosf( w0 );
double s = sinf( w0 );
@@ -238,7 +238,7 @@ float EqHandle::getPeakCurve( float x )
float EqHandle::getHighShelfCurve( float x )
{
double freqZ = xPixelToFreq( EqHandle::x(), m_width );
const int SR = Engine::audioEngine()->processingSampleRate();
const int SR = Engine::audioEngine()->outputSampleRate();
double w0 = 2 * LD_PI * freqZ / SR;
double c = cosf( w0 );
double s = sinf( w0 );
@@ -274,7 +274,7 @@ float EqHandle::getHighShelfCurve( float x )
float EqHandle::getLowShelfCurve( float x )
{
double freqZ = xPixelToFreq( EqHandle::x(), m_width );
const int SR = Engine::audioEngine()->processingSampleRate();
const int SR = Engine::audioEngine()->outputSampleRate();
double w0 = 2 * LD_PI * freqZ / SR ;
double c = cosf( w0 );
double s = sinf( w0 );
@@ -310,7 +310,7 @@ float EqHandle::getLowShelfCurve( float x )
float EqHandle::getLowCutCurve( float x )
{
double freqZ = xPixelToFreq( EqHandle::x(), m_width );
const int SR = Engine::audioEngine()->processingSampleRate();
const int SR = Engine::audioEngine()->outputSampleRate();
double w0 = 2 * LD_PI * freqZ / SR ;
double c = cosf( w0 );
double s = sinf( w0 );
@@ -353,7 +353,7 @@ float EqHandle::getLowCutCurve( float x )
float EqHandle::getHighCutCurve( float x )
{
double freqZ = xPixelToFreq( EqHandle::x(), m_width );
const int SR = Engine::audioEngine()->processingSampleRate();
const int SR = Engine::audioEngine()->outputSampleRate();
double w0 = 2 * LD_PI * freqZ / SR ;
double c = cosf( w0 );
double s = sinf( w0 );
@@ -527,7 +527,7 @@ void EqHandle::setlp48()
double EqHandle::calculateGain(const double freq, const double a1, const double a2, const double b0, const double b1, const double b2 )
{
const int SR = Engine::audioEngine()->processingSampleRate();
const int SR = Engine::audioEngine()->outputSampleRate();
const double w = 2 * LD_PI * freq / SR ;
const double PHI = pow( sin( w / 2 ), 2 ) * 4;

View File

@@ -66,7 +66,7 @@ EqEffect::EqEffect( Model *parent, const Plugin::Descriptor::SubPluginFeatures::
bool EqEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames )
{
const int sampleRate = Engine::audioEngine()->processingSampleRate();
const int sampleRate = Engine::audioEngine()->outputSampleRate();
//wet/dry controls
const float dry = dryLevel();

View File

@@ -102,7 +102,7 @@ void EqAnalyser::analyze( sampleFrame *buf, const fpp_t frames )
return;
}
m_sampleRate = Engine::audioEngine()->processingSampleRate();
m_sampleRate = Engine::audioEngine()->outputSampleRate();
const int LOWEST_FREQ = 0;
const int HIGHEST_FREQ = m_sampleRate / 2;

View File

@@ -58,9 +58,9 @@ FlangerEffect::FlangerEffect( Model *parent, const Plugin::Descriptor::SubPlugin
Effect( &flanger_plugin_descriptor, parent, key ),
m_flangerControls( this )
{
m_lfo = new QuadratureLfo( Engine::audioEngine()->processingSampleRate() );
m_lDelay = new MonoDelay( 1, Engine::audioEngine()->processingSampleRate() );
m_rDelay = new MonoDelay( 1, Engine::audioEngine()->processingSampleRate() );
m_lfo = new QuadratureLfo( Engine::audioEngine()->outputSampleRate() );
m_lDelay = new MonoDelay( 1, Engine::audioEngine()->outputSampleRate() );
m_rDelay = new MonoDelay( 1, Engine::audioEngine()->outputSampleRate() );
m_noise = new Noise;
}
@@ -99,9 +99,9 @@ bool FlangerEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames )
double outSum = 0.0;
const float d = dryLevel();
const float w = wetLevel();
const float length = m_flangerControls.m_delayTimeModel.value() * Engine::audioEngine()->processingSampleRate();
const float length = m_flangerControls.m_delayTimeModel.value() * Engine::audioEngine()->outputSampleRate();
const float noise = m_flangerControls.m_whiteNoiseAmountModel.value();
float amplitude = m_flangerControls.m_lfoAmountModel.value() * Engine::audioEngine()->processingSampleRate();
float amplitude = m_flangerControls.m_lfoAmountModel.value() * Engine::audioEngine()->outputSampleRate();
bool invertFeedback = m_flangerControls.m_invertFeedbackModel.value();
m_lfo->setFrequency( 1.0/m_flangerControls.m_lfoFrequencyModel.value() );
m_lfo->setOffset( m_flangerControls.m_lfoPhaseModel.value() / 180 * D_PI );
@@ -143,9 +143,9 @@ bool FlangerEffect::processAudioBuffer( sampleFrame *buf, const fpp_t frames )
void FlangerEffect::changeSampleRate()
{
m_lfo->setSampleRate( Engine::audioEngine()->processingSampleRate() );
m_lDelay->setSampleRate( Engine::audioEngine()->processingSampleRate() );
m_rDelay->setSampleRate( Engine::audioEngine()->processingSampleRate() );
m_lfo->setSampleRate( Engine::audioEngine()->outputSampleRate() );
m_lDelay->setSampleRate( Engine::audioEngine()->outputSampleRate() );
m_rDelay->setSampleRate( Engine::audioEngine()->outputSampleRate() );
}

View File

@@ -231,7 +231,7 @@ float FreeBoyInstrument::desiredReleaseTimeMs() const
void FreeBoyInstrument::playNote(NotePlayHandle* nph, sampleFrame* workingBuffer)
{
const f_cnt_t tfp = nph->totalFramesPlayed();
const int samplerate = Engine::audioEngine()->processingSampleRate();
const int samplerate = Engine::audioEngine()->outputSampleRate();
const fpp_t frames = nph->framesLeftForCurrentPeriod();
const f_cnt_t offset = nph->noteOffset();

View File

@@ -323,7 +323,7 @@ void GigInstrument::playNote( NotePlayHandle * _n, sampleFrame * )
void GigInstrument::play( sampleFrame * _working_buffer )
{
const fpp_t frames = Engine::audioEngine()->framesPerPeriod();
const int rate = Engine::audioEngine()->processingSampleRate();
const int rate = Engine::audioEngine()->outputSampleRate();
// Initialize to zeros
std::memset( &_working_buffer[0][0], 0, DEFAULT_CHANNELS * frames * sizeof( float ) );
@@ -746,7 +746,7 @@ void GigInstrument::addSamples( GigNote & gignote, bool wantReleaseSample )
if( gignote.midiNote >= keyLow && gignote.midiNote <= keyHigh )
{
float attenuation = pDimRegion->GetVelocityAttenuation( gignote.velocity );
float length = (float) pSample->SamplesTotal / Engine::audioEngine()->processingSampleRate();
float length = (float) pSample->SamplesTotal / Engine::audioEngine()->outputSampleRate();
// TODO: sample panning? crossfade different layers?

View File

@@ -160,7 +160,7 @@ void KickerInstrument::playNote( NotePlayHandle * _n,
{
const fpp_t frames = _n->framesLeftForCurrentPeriod();
const f_cnt_t offset = _n->noteOffset();
const float decfr = m_decayModel.value() * Engine::audioEngine()->processingSampleRate() / 1000.0f;
const float decfr = m_decayModel.value() * Engine::audioEngine()->outputSampleRate() / 1000.0f;
const f_cnt_t tfp = _n->totalFramesPlayed();
if (!_n->m_pluginData)
@@ -184,7 +184,7 @@ void KickerInstrument::playNote( NotePlayHandle * _n,
}
auto so = static_cast<SweepOsc*>(_n->m_pluginData);
so->update( _working_buffer + offset, frames, Engine::audioEngine()->processingSampleRate() );
so->update( _working_buffer + offset, frames, Engine::audioEngine()->outputSampleRate() );
if( _n->isReleased() )
{

View File

@@ -50,7 +50,7 @@ extern "C"
LOMMEffect::LOMMEffect(Model* parent, const Descriptor::SubPluginFeatures::Key* key) :
Effect(&lomm_plugin_descriptor, parent, key),
m_lommControls(this),
m_sampleRate(Engine::audioEngine()->processingSampleRate()),
m_sampleRate(Engine::audioEngine()->outputSampleRate()),
m_lp1(m_sampleRate),
m_lp2(m_sampleRate),
m_hp1(m_sampleRate),
@@ -76,7 +76,7 @@ LOMMEffect::LOMMEffect(Model* parent, const Descriptor::SubPluginFeatures::Key*
void LOMMEffect::changeSampleRate()
{
m_sampleRate = Engine::audioEngine()->processingSampleRate();
m_sampleRate = Engine::audioEngine()->outputSampleRate();
m_lp1.setSampleRate(m_sampleRate);
m_lp2.setSampleRate(m_sampleRate);
m_hp1.setSampleRate(m_sampleRate);

View File

@@ -90,11 +90,11 @@ LadspaPortDialog::LadspaPortDialog( const ladspa_key_t & _key )
{
if( min != NOHINT )
{
min *= Engine::audioEngine()->processingSampleRate();
min *= Engine::audioEngine()->outputSampleRate();
}
if( max != NOHINT )
{
max *= Engine::audioEngine()->processingSampleRate();
max *= Engine::audioEngine()->outputSampleRate();
}
}

View File

@@ -143,13 +143,13 @@ bool LadspaEffect::processAudioBuffer( sampleFrame * _buf,
sampleFrame * o_buf = nullptr;
QVarLengthArray<sample_t> sBuf(_frames * DEFAULT_CHANNELS);
if( m_maxSampleRate < Engine::audioEngine()->processingSampleRate() )
if( m_maxSampleRate < Engine::audioEngine()->outputSampleRate() )
{
o_buf = _buf;
_buf = reinterpret_cast<sampleFrame*>(sBuf.data());
sampleDown( o_buf, _buf, m_maxSampleRate );
frames = _frames * m_maxSampleRate /
Engine::audioEngine()->processingSampleRate();
Engine::audioEngine()->outputSampleRate();
}
// Copy the LMMS audio buffer to the LADSPA input buffer and initialize
@@ -587,7 +587,7 @@ sample_rate_t LadspaEffect::maxSamplerate( const QString & _name )
{
return( __buggy_plugins[_name] );
}
return( Engine::audioEngine()->processingSampleRate() );
return( Engine::audioEngine()->outputSampleRate() );
}

View File

@@ -72,7 +72,7 @@ namespace lmms
{
//#define engine::audioEngine()->processingSampleRate() 44100.0f
//#define engine::audioEngine()->outputSampleRate() 44100.0f
const float sampleRateCutoff = 44100.0f;
extern "C"
@@ -111,8 +111,8 @@ void Lb302Filter::recalc()
{
vcf_e1 = exp(6.109 + 1.5876*(fs->envmod) + 2.1553*(fs->cutoff) - 1.2*(1.0-(fs->reso)));
vcf_e0 = exp(5.613 - 0.8*(fs->envmod) + 2.1553*(fs->cutoff) - 0.7696*(1.0-(fs->reso)));
vcf_e0*=M_PI/Engine::audioEngine()->processingSampleRate();
vcf_e1*=M_PI/Engine::audioEngine()->processingSampleRate();
vcf_e0*=M_PI/Engine::audioEngine()->outputSampleRate();
vcf_e1*=M_PI/Engine::audioEngine()->outputSampleRate();
vcf_e1 -= vcf_e0;
vcf_rescoeff = exp(-1.20 + 3.455*(fs->reso));
@@ -233,7 +233,7 @@ void Lb302Filter3Pole::envRecalc()
#ifdef LB_24_IGNORE_ENVELOPE
// kfcn = fs->cutoff;
kfcn = 2.0 * kfco / Engine::audioEngine()->processingSampleRate();
kfcn = 2.0 * kfco / Engine::audioEngine()->outputSampleRate();
#else
kfcn = w;
#endif
@@ -414,7 +414,7 @@ void Lb302Synth::filterChanged()
float d = 0.2 + (2.3*vcf_dec_knob.value());
d *= Engine::audioEngine()->processingSampleRate(); // d *= smpl rate
d *= Engine::audioEngine()->outputSampleRate(); // d *= smpl rate
fs.envdecay = pow(0.1, 1.0/d * ENVINC); // decay is 0.1 to the 1/d * ENVINC
// vcf_envdecay is now adjusted for both
// sampling rate and ENVINC
@@ -448,7 +448,7 @@ void Lb302Synth::recalcFilter()
// THIS IS OLD 3pole/24dB code, I may reintegrate it. Don't need it
// right now. Should be toggled by LB_24_RES_TRICK at the moment.
/*kfcn = 2.0 * (((vcf_cutoff*3000))) / engine::audioEngine()->processingSampleRate();
/*kfcn = 2.0 * (((vcf_cutoff*3000))) / engine::audioEngine()->outputSampleRate();
kp = ((-2.7528*kfcn + 3.0429)*kfcn + 1.718)*kfcn - 0.9984;
kp1 = kp+1.0;
kp1h = 0.5*kp1;
@@ -459,12 +459,12 @@ void Lb302Synth::recalcFilter()
}
inline float GET_INC(float freq) {
return freq/Engine::audioEngine()->processingSampleRate(); // TODO: Use actual sampling rate.
return freq/Engine::audioEngine()->outputSampleRate(); // TODO: Use actual sampling rate.
}
int Lb302Synth::process(sampleFrame *outbuf, const int size)
{
const float sampleRatio = 44100.f / Engine::audioEngine()->processingSampleRate();
const float sampleRatio = 44100.f / Engine::audioEngine()->outputSampleRate();
// Hold on to the current VCF, and use it throughout this period
Lb302Filter *filter = vcf.loadAcquire();
@@ -648,7 +648,7 @@ int Lb302Synth::process(sampleFrame *outbuf, const int size)
// Handle Envelope
if(vca_mode==VcaMode::Attack) {
vca_a+=(vca_a0-vca_a)*vca_attack;
if(sample_cnt>=0.5*Engine::audioEngine()->processingSampleRate())
if(sample_cnt>=0.5*Engine::audioEngine()->outputSampleRate())
vca_mode = VcaMode::Idle;
}
else if(vca_mode == VcaMode::Decay) {

View File

@@ -1447,7 +1447,7 @@ void MonstroInstrument::updateLFOAtts()
void MonstroInstrument::updateSamplerate()
{
m_samplerate = Engine::audioEngine()->processingSampleRate();
m_samplerate = Engine::audioEngine()->outputSampleRate();
m_integrator = 0.5f - ( 0.5f - INTEGRATOR ) * 44100.0f / m_samplerate;
m_fmCorrection = 44100.f / m_samplerate * FM_AMOUNT;

View File

@@ -55,7 +55,7 @@ MultitapEchoEffect::MultitapEchoEffect( Model* parent, const Descriptor::SubPlug
m_stages( 1 ),
m_controls( this ),
m_buffer( 16100.0f ),
m_sampleRate( Engine::audioEngine()->processingSampleRate() ),
m_sampleRate( Engine::audioEngine()->outputSampleRate() ),
m_sampleRatio( 1.0f / m_sampleRate )
{
m_work = new sampleFrame[Engine::audioEngine()->framesPerPeriod()];

View File

@@ -172,7 +172,7 @@ void MultitapEchoControls::lengthChanged()
void MultitapEchoControls::sampleRateChanged()
{
m_effect->m_sampleRate = Engine::audioEngine()->processingSampleRate();
m_effect->m_sampleRate = Engine::audioEngine()->outputSampleRate();
m_effect->m_sampleRatio = 1.0f / m_effect->m_sampleRate;
m_effect->updateFilters( 0, 19 );
}

View File

@@ -552,7 +552,7 @@ void NesInstrument::playNote( NotePlayHandle * n, sampleFrame * workingBuffer )
if (!n->m_pluginData)
{
auto nes = new NesObject(this, Engine::audioEngine()->processingSampleRate(), n);
auto nes = new NesObject(this, Engine::audioEngine()->outputSampleRate(), n);
n->m_pluginData = nes;
}

View File

@@ -140,7 +140,7 @@ OpulenzInstrument::OpulenzInstrument( InstrumentTrack * _instrument_track ) :
// Create an emulator - samplerate, 16 bit, mono
emulatorMutex.lock();
theEmulator = new CTemuopl(Engine::audioEngine()->processingSampleRate(), true, false);
theEmulator = new CTemuopl(Engine::audioEngine()->outputSampleRate(), true, false);
theEmulator->init();
// Enable waveform selection
theEmulator->write(0x01,0x20);
@@ -231,7 +231,7 @@ OpulenzInstrument::~OpulenzInstrument() {
void OpulenzInstrument::reloadEmulator() {
delete theEmulator;
emulatorMutex.lock();
theEmulator = new CTemuopl(Engine::audioEngine()->processingSampleRate(), true, false);
theEmulator = new CTemuopl(Engine::audioEngine()->outputSampleRate(), true, false);
theEmulator->init();
theEmulator->write(0x01,0x20);
emulatorMutex.unlock();

View File

@@ -605,10 +605,10 @@ void OscillatorObject::updateDetuning()
{
m_detuningLeft = powf( 2.0f, OrganicInstrument::s_harmonics[ static_cast<int>( m_harmModel.value() ) ]
+ (float)m_detuneModel.value() * CENT ) /
Engine::audioEngine()->processingSampleRate();
Engine::audioEngine()->outputSampleRate();
m_detuningRight = powf( 2.0f, OrganicInstrument::s_harmonics[ static_cast<int>( m_harmModel.value() ) ]
- (float)m_detuneModel.value() * CENT ) /
Engine::audioEngine()->processingSampleRate();
Engine::audioEngine()->outputSampleRate();
}

View File

@@ -55,7 +55,7 @@ ReverbSCEffect::ReverbSCEffect( Model* parent, const Descriptor::SubPluginFeatur
m_reverbSCControls( this )
{
sp_create(&sp);
sp->sr = Engine::audioEngine()->processingSampleRate();
sp->sr = Engine::audioEngine()->outputSampleRate();
sp_revsc_create(&revsc);
sp_revsc_init(sp, revsc);
@@ -63,8 +63,8 @@ ReverbSCEffect::ReverbSCEffect( Model* parent, const Descriptor::SubPluginFeatur
sp_dcblock_create(&dcblk[0]);
sp_dcblock_create(&dcblk[1]);
sp_dcblock_init(sp, dcblk[0], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() );
sp_dcblock_init(sp, dcblk[1], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() );
sp_dcblock_init(sp, dcblk[0], 1);
sp_dcblock_init(sp, dcblk[1], 1);
}
ReverbSCEffect::~ReverbSCEffect()
@@ -132,7 +132,7 @@ bool ReverbSCEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames )
void ReverbSCEffect::changeSampleRate()
{
// Change sr variable in Soundpipe. does not need to be destroyed
sp->sr = Engine::audioEngine()->processingSampleRate();
sp->sr = Engine::audioEngine()->outputSampleRate();
mutex.lock();
sp_revsc_destroy(&revsc);
@@ -145,8 +145,8 @@ void ReverbSCEffect::changeSampleRate()
sp_dcblock_create(&dcblk[0]);
sp_dcblock_create(&dcblk[1]);
sp_dcblock_init(sp, dcblk[0], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() );
sp_dcblock_init(sp, dcblk[1], Engine::audioEngine()->currentQualitySettings().sampleRateMultiplier() );
sp_dcblock_init(sp, dcblk[0], 1);
sp_dcblock_init(sp, dcblk[1], 1);
mutex.unlock();
}

View File

@@ -574,7 +574,7 @@ void Sf2Instrument::reloadSynth()
double tempRate;
// Set & get, returns the true sample rate
fluid_settings_setnum( m_settings, (char *) "synth.sample-rate", Engine::audioEngine()->processingSampleRate() );
fluid_settings_setnum( m_settings, (char *) "synth.sample-rate", Engine::audioEngine()->outputSampleRate() );
fluid_settings_getnum( m_settings, (char *) "synth.sample-rate", &tempRate );
m_internalSampleRate = static_cast<int>( tempRate );
@@ -616,7 +616,7 @@ void Sf2Instrument::reloadSynth()
fluid_synth_set_interp_method( m_synth, -1, FLUID_INTERP_DEFAULT );
}
m_synthMutex.unlock();
if( m_internalSampleRate < Engine::audioEngine()->processingSampleRate() )
if( m_internalSampleRate < Engine::audioEngine()->outputSampleRate() )
{
m_synthMutex.lock();
if( m_srcState != nullptr )
@@ -872,10 +872,10 @@ void Sf2Instrument::renderFrames( f_cnt_t frames, sampleFrame * buf )
{
m_synthMutex.lock();
fluid_synth_get_gain(m_synth); // This flushes voice updates as a side effect
if( m_internalSampleRate < Engine::audioEngine()->processingSampleRate() &&
if( m_internalSampleRate < Engine::audioEngine()->outputSampleRate() &&
m_srcState != nullptr )
{
const fpp_t f = frames * m_internalSampleRate / Engine::audioEngine()->processingSampleRate();
const fpp_t f = frames * m_internalSampleRate / Engine::audioEngine()->outputSampleRate();
#ifdef __GNUC__
sampleFrame tmp[f];
#else

View File

@@ -444,7 +444,7 @@ QString SfxrInstrument::nodeName() const
void SfxrInstrument::playNote( NotePlayHandle * _n, sampleFrame * _working_buffer )
{
float currentSampleRate = Engine::audioEngine()->processingSampleRate();
float currentSampleRate = Engine::audioEngine()->outputSampleRate();
fpp_t frameNum = _n->framesLeftForCurrentPeriod();
const f_cnt_t offset = _n->noteOffset();

View File

@@ -289,7 +289,7 @@ void SidInstrument::playNote( NotePlayHandle * _n,
sampleFrame * _working_buffer )
{
const int clockrate = C64_PAL_CYCLES_PER_SEC;
const int samplerate = Engine::audioEngine()->processingSampleRate();
const int samplerate = Engine::audioEngine()->outputSampleRate();
if (!_n->m_pluginData)
{

View File

@@ -88,7 +88,7 @@ void SlicerT::playNote(NotePlayHandle* handle, sampleFrame* workingBuffer)
float speedRatio = static_cast<float>(m_originalBPM.value()) / bpm;
if (!m_enableSync.value()) { speedRatio = 1; }
speedRatio *= pitchRatio;
speedRatio *= Engine::audioEngine()->processingSampleRate() / static_cast<float>(m_originalSample.sampleRate());
speedRatio *= Engine::audioEngine()->outputSampleRate() / static_cast<float>(m_originalSample.sampleRate());
float sliceStart, sliceEnd;
if (noteIndex == 0) // full sample at base note
@@ -132,7 +132,7 @@ void SlicerT::playNote(NotePlayHandle* handle, sampleFrame* workingBuffer)
playbackState->setNoteDone(nextNoteDone);
// exponential fade out, applyRelease() not used since it extends the note length
int fadeOutFrames = m_fadeOutFrames.value() / 1000.0f * Engine::audioEngine()->processingSampleRate();
int fadeOutFrames = m_fadeOutFrames.value() / 1000.0f * Engine::audioEngine()->outputSampleRate();
int noteFramesLeft = noteLeft * m_originalSample.sampleSize() * speedRatio;
for (int i = 0; i < frames; i++)
{

View File

@@ -53,7 +53,7 @@ SaProcessor::SaProcessor(const SaControls *controls) :
m_terminate(false),
m_inBlockSize(FFT_BLOCK_SIZES[0]),
m_fftBlockSize(FFT_BLOCK_SIZES[0]),
m_sampleRate(Engine::audioEngine()->processingSampleRate()),
m_sampleRate(Engine::audioEngine()->outputSampleRate()),
m_framesFilledUp(0),
m_spectrumActive(false),
m_waterfallActive(false),
@@ -166,7 +166,7 @@ void SaProcessor::analyze(LocklessRingBuffer<sampleFrame> &ring_buffer)
#endif
// update sample rate
m_sampleRate = Engine::audioEngine()->processingSampleRate();
m_sampleRate = Engine::audioEngine()->outputSampleRate();
// apply FFT window
for (unsigned int i = 0; i < m_inBlockSize; i++)

View File

@@ -342,7 +342,7 @@ void MalletsInstrument::playNote( NotePlayHandle * _n,
m_vibratoFreqModel.value(),
p,
(uint8_t) m_spreadModel.value(),
Engine::audioEngine()->processingSampleRate() );
Engine::audioEngine()->outputSampleRate() );
}
else if( p == 9 )
{
@@ -355,7 +355,7 @@ void MalletsInstrument::playNote( NotePlayHandle * _n,
m_lfoSpeedModel.value(),
m_adsrModel.value(),
(uint8_t) m_spreadModel.value(),
Engine::audioEngine()->processingSampleRate() );
Engine::audioEngine()->outputSampleRate() );
}
else
{
@@ -368,7 +368,7 @@ void MalletsInstrument::playNote( NotePlayHandle * _n,
m_strikeModel.value() * 128.0,
speed,
(uint8_t) m_spreadModel.value(),
Engine::audioEngine()->processingSampleRate() );
Engine::audioEngine()->outputSampleRate() );
}
m.unlock();
static_cast<MalletsSynth *>(_n->m_pluginData)->setPresetIndex(p);

View File

@@ -177,7 +177,7 @@ void OscillatorObject::updateDetuningLeft()
{
m_detuningLeft = powf( 2.0f, ( (float)m_coarseModel.value() * 100.0f
+ (float)m_fineLeftModel.value() ) / 1200.0f )
/ Engine::audioEngine()->processingSampleRate();
/ Engine::audioEngine()->outputSampleRate();
}
@@ -187,7 +187,7 @@ void OscillatorObject::updateDetuningRight()
{
m_detuningRight = powf( 2.0f, ( (float)m_coarseModel.value() * 100.0f
+ (float)m_fineRightModel.value() ) / 1200.0f )
/ Engine::audioEngine()->processingSampleRate();
/ Engine::audioEngine()->outputSampleRate();
}

View File

@@ -206,7 +206,7 @@ void Vibed::playNote(NotePlayHandle* n, sampleFrame* workingBuffer)
if (!n->m_pluginData)
{
const auto newContainer = new StringContainer{n->frequency(),
Engine::audioEngine()->processingSampleRate(), s_sampleLength};
Engine::audioEngine()->outputSampleRate(), s_sampleLength};
n->m_pluginData = newContainer;

View File

@@ -338,7 +338,7 @@ void VstPlugin::updateSampleRate()
{
lock();
sendMessage( message( IdSampleRateInformation ).
addInt( Engine::audioEngine()->processingSampleRate() ) );
addInt( Engine::audioEngine()->outputSampleRate() ) );
waitForMessage( IdInformationUpdated, true );
unlock();
}

View File

@@ -332,7 +332,7 @@ void WatsynInstrument::playNote( NotePlayHandle * _n,
if (!_n->m_pluginData)
{
auto w = new WatsynObject(&A1_wave[0], &A2_wave[0], &B1_wave[0], &B2_wave[0], m_amod.value(), m_bmod.value(),
Engine::audioEngine()->processingSampleRate(), _n, Engine::audioEngine()->framesPerPeriod(), this);
Engine::audioEngine()->outputSampleRate(), _n, Engine::audioEngine()->framesPerPeriod(), this);
_n->m_pluginData = w;
}

View File

@@ -204,14 +204,14 @@ void Xpressive::playNote(NotePlayHandle* nph, sampleFrame* working_buffer) {
if (!nph->m_pluginData) {
auto exprO1 = new ExprFront(m_outputExpression[0].constData(),
Engine::audioEngine()->processingSampleRate()); // give the "last" function a whole second
auto exprO2 = new ExprFront(m_outputExpression[1].constData(), Engine::audioEngine()->processingSampleRate());
Engine::audioEngine()->outputSampleRate()); // give the "last" function a whole second
auto exprO2 = new ExprFront(m_outputExpression[1].constData(), Engine::audioEngine()->outputSampleRate());
auto init_expression_step1 = [this, nph](ExprFront* e) { //lambda function to init exprO1 and exprO2
//add the constants and the variables to the expression.
e->add_constant("key", nph->key());//the key that was pressed.
e->add_constant("bnote", nph->instrumentTrack()->baseNote()); // the base note
e->add_constant("srate", Engine::audioEngine()->processingSampleRate());// sample rate of the audio engine
e->add_constant("srate", Engine::audioEngine()->outputSampleRate());// sample rate of the audio engine
e->add_constant("v", nph->getVolume() / 255.0); //volume of the note.
e->add_constant("tempo", Engine::getSong()->getTempo());//tempo of the song.
e->add_variable("A1", m_A1);//A1,A2,A3: general purpose input controls.
@@ -225,7 +225,7 @@ void Xpressive::playNote(NotePlayHandle* nph, sampleFrame* working_buffer) {
m_W2.setInterpolate(m_interpolateW2.value());
m_W3.setInterpolate(m_interpolateW3.value());
nph->m_pluginData = new ExprSynth(&m_W1, &m_W2, &m_W3, exprO1, exprO2, nph,
Engine::audioEngine()->processingSampleRate(), &m_panning1, &m_panning2, m_relTransition.value());
Engine::audioEngine()->outputSampleRate(), &m_panning1, &m_panning2, m_relTransition.value());
}
auto ps = static_cast<ExprSynth*>(nph->m_pluginData);

View File

@@ -451,7 +451,7 @@ void ZynAddSubFxInstrument::initPlugin()
QDir( ConfigManager::inst()->factoryPresetsDir() +
"/ZynAddSubFX" ).absolutePath() ) ) );
m_remotePlugin->updateSampleRate( Engine::audioEngine()->processingSampleRate() );
m_remotePlugin->updateSampleRate( Engine::audioEngine()->outputSampleRate() );
// temporary workaround until the VST synchronization feature gets stripped out of the RemotePluginClient class
// causing not to send buffer size information requests
@@ -463,7 +463,7 @@ void ZynAddSubFxInstrument::initPlugin()
else
{
m_plugin = new LocalZynAddSubFx;
m_plugin->setSampleRate( Engine::audioEngine()->processingSampleRate() );
m_plugin->setSampleRate( Engine::audioEngine()->outputSampleRate() );
m_plugin->setBufferSize( Engine::audioEngine()->framesPerPeriod() );
}