Calculate smoothed prebuffering available amount in the processor
This commit is contained in:
parent
d42971e09f
commit
60293c6a84
@ -359,14 +359,20 @@ public:
|
||||
}
|
||||
void setSlope(double x, double sr)
|
||||
{
|
||||
m_slope = x;
|
||||
double srCompensate = srCompensate = sr / 100.0;
|
||||
double compensated_a = powf(x, (1.0 / srCompensate));
|
||||
m_a = compensated_a;
|
||||
m_b = 1.0 - m_a;
|
||||
if (x != m_slope || sr != m_sr)
|
||||
{
|
||||
m_slope = x;
|
||||
m_sr = sr;
|
||||
double srCompensate = srCompensate = sr / 100.0;
|
||||
double compensated_a = powf(x, (1.0 / srCompensate));
|
||||
m_a = compensated_a;
|
||||
m_b = 1.0 - m_a;
|
||||
}
|
||||
}
|
||||
double slope() const { return m_slope; }
|
||||
double getSlope() const { return m_slope; }
|
||||
double getSamplerate() const { return m_sr; }
|
||||
private:
|
||||
double m_a, m_b, m_z;
|
||||
double m_slope;
|
||||
double m_sr = 0.0;
|
||||
};
|
||||
|
@ -1277,7 +1277,6 @@ PerfMeterComponent::PerfMeterComponent(PaulstretchpluginAudioProcessor * p)
|
||||
m_gradient.addColour(0.0, Colours::red);
|
||||
m_gradient.addColour(0.25, Colours::yellow);
|
||||
m_gradient.addColour(1.0, Colours::green);
|
||||
m_smoother.setSlope(0.9, 10.0);
|
||||
}
|
||||
|
||||
void PerfMeterComponent::paint(Graphics & g)
|
||||
@ -1285,7 +1284,7 @@ void PerfMeterComponent::paint(Graphics & g)
|
||||
m_gradient.point1 = {0.0f,0.0f};
|
||||
m_gradient.point2 = {(float)getWidth(),0.0f};
|
||||
g.fillAll(Colours::grey);
|
||||
double amt = m_smoother.process(m_proc->getPreBufferingPercent());
|
||||
double amt = m_proc->getPreBufferingPercent();
|
||||
g.setColour(Colours::green);
|
||||
int w = amt * getWidth();
|
||||
//g.setGradientFill(m_gradient);
|
||||
|
@ -113,7 +113,6 @@ public:
|
||||
PaulstretchpluginAudioProcessor* m_proc = nullptr;
|
||||
private:
|
||||
ColourGradient m_gradient;
|
||||
SignalSmoother m_smoother;
|
||||
};
|
||||
|
||||
class MyThumbCache : public AudioThumbnailCache
|
||||
|
@ -639,7 +639,9 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
|
||||
double srtemp = getSampleRate();
|
||||
if (srtemp != m_cur_sr)
|
||||
m_cur_sr = srtemp;
|
||||
const int totalNumInputChannels = getTotalNumInputChannels();
|
||||
m_prebufsmoother.setSlope(0.9, srtemp / buffer.getNumSamples());
|
||||
m_smoothed_prebuffer_ready = m_prebufsmoother.process(m_buffering_source->getPercentReady());
|
||||
const int totalNumInputChannels = getTotalNumInputChannels();
|
||||
const int totalNumOutputChannels = getTotalNumOutputChannels();
|
||||
for (int i = 0; i < totalNumInputChannels; ++i)
|
||||
m_input_buffer.copyFrom(i, 0, buffer, i, 0, buffer.getNumSamples());
|
||||
@ -822,7 +824,7 @@ double PaulstretchpluginAudioProcessor::getPreBufferingPercent()
|
||||
{
|
||||
if (m_buffering_source==nullptr)
|
||||
return 0.0;
|
||||
return m_buffering_source->getPercentReady();
|
||||
return m_smoothed_prebuffer_ready;
|
||||
}
|
||||
|
||||
void PaulstretchpluginAudioProcessor::timerCallback(int id)
|
||||
|
@ -235,7 +235,8 @@ private:
|
||||
std::unique_ptr<MyBufferingAudioSource> m_buffering_source;
|
||||
int m_prebuffer_amount = 1;
|
||||
bool m_recreate_buffering_source = true;
|
||||
|
||||
double m_smoothed_prebuffer_ready = 0.0;
|
||||
SignalSmoother m_prebufsmoother;
|
||||
int m_fft_size_to_use = 1024;
|
||||
double m_last_outpos_pos = 0.0;
|
||||
double m_last_in_pos = 0.0;
|
||||
|
Loading…
Reference in New Issue
Block a user