Enabled showing the file source cached time ranges

This commit is contained in:
xenakios 2019-02-28 16:04:04 +02:00
parent cfb8f4f303
commit 27b014a6e7
3 changed files with 14 additions and 6 deletions

View File

@ -53,6 +53,11 @@ inline String toString(double x)
return String(x,3);
}
template<typename T>
inline String toString(const Range<T>& x)
{
return String(x.getStart()) + " " + String(x.getEnd());
}
template<typename... Args>
inline String formatted(Args... args)

View File

@ -160,7 +160,7 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau
if (processor.getStretchSource()->getPlayRange().contains(pos))
processor.getStretchSource()->seekPercent(pos);
};
m_wavecomponent.ShowFileCacheRange = true;
m_spec_order_ed.setSource(processor.getStretchSource());
addAndMakeVisible(&m_spec_order_ed);
m_spec_order_ed.ModuleSelectedCallback = [this](int id)
@ -446,6 +446,7 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
m_wavecomponent.setAudioInfo(processor.getSampleRateChecked(), processor.getStretchSource()->getLastSeekPos(),
processor.getStretchSource()->getFFTSize());
String infotext;
m_wavecomponent.ShowFileCacheRange = processor.m_show_technical_info;
if (processor.m_show_technical_info)
{
infotext += String(processor.getStretchSource()->getDiskReadSampleCount()) + " ";
@ -705,20 +706,21 @@ void WaveformComponent::paint(Graphics & g)
int xcorright = normalizedToViewX<int>(m_time_sel_end);
g.fillRect(xcorleft, m_topmargin, xcorright - xcorleft, getHeight() - m_topmargin);
}
if (m_file_cached.first.getLength() > 0.0 &&
(bool)ShowFileCacheRange.getValue())
if (m_file_cached.first.getLength() > 0.0 && ShowFileCacheRange == true)
{
g.setColour(Colours::red.withAlpha(0.2f));
int xcorleft = (int)jmap<double>(m_file_cached.first.getStart(), m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
int xcorright = (int)jmap<double>(m_file_cached.first.getEnd(), m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
g.fillRect(xcorleft, 0, xcorright - xcorleft, m_topmargin / 2);
g.fillRect(xcorleft, 0, xcorright - xcorleft, getHeight());
xcorleft = (int)jmap<double>(m_file_cached.second.getStart(), m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
xcorright = (int)jmap<double>(m_file_cached.second.getEnd(), m_view_range.getStart(), m_view_range.getEnd(), 0, getWidth());
if (xcorright - xcorleft>0)
{
g.setColour(Colours::blue.withAlpha(0.2f));
g.fillRect(xcorleft, m_topmargin / 2, xcorright - xcorleft, m_topmargin / 2);
g.fillRect(xcorleft, m_topmargin / 2, xcorright - xcorleft, getHeight());
}
g.setColour(Colours::white);
g.drawText(toString(m_file_cached.first), 0, 30, 200, 30, Justification::centredLeft);
}
g.setColour(Colours::white);
@ -750,6 +752,7 @@ void WaveformComponent::timerCallback()
m_last_source_pos = m_sas->getLastSourcePosition();
m_last_source_pos_update_time = Time::getMillisecondCounterHiRes();
}
m_file_cached = m_sas->getFileCachedRangesNormalized();
repaint();
}

View File

@ -151,7 +151,7 @@ public:
void setFileCachedRange(std::pair<Range<double>, Range<double>> rng);
void setTimerEnabled(bool b);
void setViewRange(Range<double> rng);
Value ShowFileCacheRange;
bool ShowFileCacheRange=false;
void setRecordingPosition(double pos) { m_rec_pos = pos; }
int m_image_init_count = 0;
int m_image_update_count = 0;