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:
@@ -89,8 +89,6 @@ public:
|
||||
|
||||
virtual void stopProcessing();
|
||||
|
||||
void applyQualitySettings();
|
||||
|
||||
protected:
|
||||
// subclasses can re-implement this for being used in conjunction with
|
||||
// processNextBuffer()
|
||||
@@ -110,13 +108,6 @@ protected:
|
||||
void clearS16Buffer( int_sample_t * _outbuf,
|
||||
const fpp_t _frames );
|
||||
|
||||
// resample given buffer from samplerate _src_sr to samplerate _dst_sr
|
||||
fpp_t resample( const surroundSampleFrame * _src,
|
||||
const fpp_t _frames,
|
||||
surroundSampleFrame * _dst,
|
||||
const sample_rate_t _src_sr,
|
||||
const sample_rate_t _dst_sr );
|
||||
|
||||
inline void setSampleRate( const sample_rate_t _new_sr )
|
||||
{
|
||||
m_sampleRate = _new_sr;
|
||||
@@ -142,9 +133,6 @@ private:
|
||||
|
||||
QMutex m_devMutex;
|
||||
|
||||
SRC_DATA m_srcData;
|
||||
SRC_STATE * m_srcState;
|
||||
|
||||
surroundSampleFrame * m_buffer;
|
||||
|
||||
};
|
||||
|
||||
@@ -104,7 +104,7 @@ private:
|
||||
delete[] b;
|
||||
}
|
||||
|
||||
const int microseconds = static_cast<int>( audioEngine()->framesPerPeriod() * 1000000.0f / audioEngine()->processingSampleRate() - timer.elapsed() );
|
||||
const int microseconds = static_cast<int>( audioEngine()->framesPerPeriod() * 1000000.0f / audioEngine()->outputSampleRate() - timer.elapsed() );
|
||||
if( microseconds > 0 )
|
||||
{
|
||||
usleep( microseconds );
|
||||
|
||||
@@ -108,13 +108,6 @@ public:
|
||||
|
||||
struct qualitySettings
|
||||
{
|
||||
enum class Mode
|
||||
{
|
||||
Draft,
|
||||
HighQuality,
|
||||
FinalMix
|
||||
} ;
|
||||
|
||||
enum class Interpolation
|
||||
{
|
||||
Linear,
|
||||
@@ -123,53 +116,11 @@ public:
|
||||
SincBest
|
||||
} ;
|
||||
|
||||
enum class Oversampling
|
||||
{
|
||||
None,
|
||||
X2,
|
||||
X4,
|
||||
X8
|
||||
} ;
|
||||
|
||||
Interpolation interpolation;
|
||||
Oversampling oversampling;
|
||||
|
||||
qualitySettings(Mode m)
|
||||
qualitySettings(Interpolation i) :
|
||||
interpolation(i)
|
||||
{
|
||||
switch (m)
|
||||
{
|
||||
case Mode::Draft:
|
||||
interpolation = Interpolation::Linear;
|
||||
oversampling = Oversampling::None;
|
||||
break;
|
||||
case Mode::HighQuality:
|
||||
interpolation =
|
||||
Interpolation::SincFastest;
|
||||
oversampling = Oversampling::X2;
|
||||
break;
|
||||
case Mode::FinalMix:
|
||||
interpolation = Interpolation::SincBest;
|
||||
oversampling = Oversampling::X8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
qualitySettings(Interpolation i, Oversampling o) :
|
||||
interpolation(i),
|
||||
oversampling(o)
|
||||
{
|
||||
}
|
||||
|
||||
int sampleRateMultiplier() const
|
||||
{
|
||||
switch( oversampling )
|
||||
{
|
||||
case Oversampling::None: return 1;
|
||||
case Oversampling::X2: return 2;
|
||||
case Oversampling::X4: return 4;
|
||||
case Oversampling::X8: return 8;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int libsrcInterpolation() const
|
||||
@@ -289,8 +240,6 @@ public:
|
||||
sample_rate_t baseSampleRate() const;
|
||||
sample_rate_t outputSampleRate() const;
|
||||
sample_rate_t inputSampleRate() const;
|
||||
sample_rate_t processingSampleRate() const;
|
||||
|
||||
|
||||
inline float masterGain() const
|
||||
{
|
||||
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
*/
|
||||
static inline float freqToLen( float f )
|
||||
{
|
||||
return freqToLen( f, Engine::audioEngine()->processingSampleRate() );
|
||||
return freqToLen( f, Engine::audioEngine()->outputSampleRate() );
|
||||
}
|
||||
|
||||
/*! \brief This method converts frequency to wavelength, but you can use any custom sample rate with it.
|
||||
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
|
||||
inline f_cnt_t timeout() const
|
||||
{
|
||||
const float samples = Engine::audioEngine()->processingSampleRate() * m_autoQuitModel.value() / 1000.0f;
|
||||
const float samples = Engine::audioEngine()->outputSampleRate() * m_autoQuitModel.value() / 1000.0f;
|
||||
return 1 + ( static_cast<int>( samples ) / Engine::audioEngine()->framesPerPeriod() );
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ protected:
|
||||
sample_rate_t _dst_sr )
|
||||
{
|
||||
resample( 0, _src_buf,
|
||||
Engine::audioEngine()->processingSampleRate(),
|
||||
Engine::audioEngine()->outputSampleRate(),
|
||||
_dst_buf, _dst_sr,
|
||||
Engine::audioEngine()->framesPerPeriod() );
|
||||
}
|
||||
@@ -202,9 +202,9 @@ protected:
|
||||
sample_rate_t _src_sr )
|
||||
{
|
||||
resample( 1, _src_buf, _src_sr, _dst_buf,
|
||||
Engine::audioEngine()->processingSampleRate(),
|
||||
Engine::audioEngine()->outputSampleRate(),
|
||||
Engine::audioEngine()->framesPerPeriod() * _src_sr /
|
||||
Engine::audioEngine()->processingSampleRate() );
|
||||
Engine::audioEngine()->outputSampleRate() );
|
||||
}
|
||||
void reinitSRC();
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ public:
|
||||
control.f1 + 1 :
|
||||
0;
|
||||
control.band = waveTableBandFromFreq(
|
||||
m_freq * m_detuning_div_samplerate * Engine::audioEngine()->processingSampleRate());
|
||||
m_freq * m_detuning_div_samplerate * Engine::audioEngine()->outputSampleRate());
|
||||
return control;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,8 @@ public:
|
||||
};
|
||||
|
||||
Sample() = default;
|
||||
Sample(const QByteArray& base64, int sampleRate = Engine::audioEngine()->processingSampleRate());
|
||||
Sample(const sampleFrame* data, size_t numFrames, int sampleRate = Engine::audioEngine()->processingSampleRate());
|
||||
Sample(const QByteArray& base64, int sampleRate = Engine::audioEngine()->outputSampleRate());
|
||||
Sample(const sampleFrame* data, size_t numFrames, int sampleRate = Engine::audioEngine()->outputSampleRate());
|
||||
Sample(const Sample& other);
|
||||
Sample(Sample&& other);
|
||||
explicit Sample(const QString& audioFile);
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
SampleBuffer(const QString& base64, int sampleRate);
|
||||
SampleBuffer(std::vector<sampleFrame> data, int sampleRate);
|
||||
SampleBuffer(
|
||||
const sampleFrame* data, size_t numFrames, int sampleRate = Engine::audioEngine()->processingSampleRate());
|
||||
const sampleFrame* data, size_t numFrames, int sampleRate = Engine::audioEngine()->outputSampleRate());
|
||||
|
||||
friend void swap(SampleBuffer& first, SampleBuffer& second) noexcept;
|
||||
auto toBase64() const -> QString;
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
private:
|
||||
std::vector<sampleFrame> m_data;
|
||||
QString m_audioFile;
|
||||
sample_rate_t m_sampleRate = Engine::audioEngine()->processingSampleRate();
|
||||
sample_rate_t m_sampleRate = Engine::audioEngine()->outputSampleRate();
|
||||
};
|
||||
|
||||
} // namespace lmms
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
static QString openWaveformFile(const QString& previousFile = "");
|
||||
static std::shared_ptr<const SampleBuffer> createBufferFromFile(const QString& filePath);
|
||||
static std::shared_ptr<const SampleBuffer> createBufferFromBase64(
|
||||
const QString& base64, int sampleRate = Engine::audioEngine()->processingSampleRate());
|
||||
const QString& base64, int sampleRate = Engine::audioEngine()->outputSampleRate());
|
||||
private:
|
||||
static void displayError(const QString& message);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user