Performance improvements for painting waveform during capture mode etc

This commit is contained in:
xenakios 2018-02-12 20:51:05 +02:00
parent 07a54c4cdc
commit c65812f709
3 changed files with 29 additions and 11 deletions

View File

@ -243,6 +243,7 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
infotext += " (offline rendering)";
if (processor.m_playposinfo.isPlaying)
infotext += " "+String(processor.m_playposinfo.timeInSeconds,1);
infotext += " " + String(m_wavecomponent.m_image_init_count) + " " + String(m_wavecomponent.m_image_update_count);
m_info_label.setText(infotext, dontSendNotification);
m_perfmeter.repaint();
}
@ -394,8 +395,21 @@ WaveformComponent::~WaveformComponent()
void WaveformComponent::changeListenerCallback(ChangeBroadcaster * /*cb*/)
{
m_waveimage = Image();
repaint();
jassert(MessageManager::getInstance()->isThisTheMessageThread());
m_image_dirty = true;
//repaint();
}
void WaveformComponent::updateCachedImage()
{
Graphics tempg(m_waveimage);
tempg.fillAll(Colours::black);
tempg.setColour(Colours::darkgrey);
double thumblen = m_thumbnail->getTotalLength();
m_thumbnail->drawChannels(tempg, { 0,0,getWidth(),getHeight() - m_topmargin },
thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 1.0f);
m_image_dirty = false;
++m_image_update_count;
}
void WaveformComponent::paint(Graphics & g)
@ -425,16 +439,17 @@ void WaveformComponent::paint(Graphics & g)
bool m_use_cached_image = true;
if (m_use_cached_image == true)
{
if (m_waveimage.isValid() == false || m_waveimage.getWidth() != getWidth()
if (m_image_dirty == true || m_waveimage.getWidth() != getWidth()
|| m_waveimage.getHeight() != getHeight() - m_topmargin)
{
//Logger::writeToLog("updating cached waveform image");
m_waveimage = Image(Image::ARGB, getWidth(), getHeight() - m_topmargin, true);
Graphics tempg(m_waveimage);
tempg.fillAll(Colours::black);
tempg.setColour(Colours::darkgrey);
m_thumbnail->drawChannels(tempg, { 0,0,getWidth(),getHeight() - m_topmargin },
thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 1.0f);
if (m_waveimage.getWidth() != getWidth()
|| m_waveimage.getHeight() != getHeight() - m_topmargin)
{
m_waveimage = Image(Image::ARGB, getWidth(), getHeight() - m_topmargin, true);
++m_image_init_count;
}
updateCachedImage();
}
g.drawImage(m_waveimage, 0, m_topmargin, getWidth(), getHeight() - m_topmargin, 0, 0, getWidth(), getHeight() - m_topmargin);

View File

@ -115,6 +115,8 @@ public:
void setViewRange(Range<double> rng);
Value ShowFileCacheRange;
void setRecordingPosition(double pos) { m_rec_pos = pos; }
int m_image_init_count = 0;
int m_image_update_count = 0;
private:
AudioThumbnail* m_thumbnail = nullptr;
Range<double> m_view_range{ 0.0,1.0 };
@ -128,13 +130,14 @@ private:
int m_topmargin = 0;
int getTimeSelectionEdge(int x, int y);
std::pair<Range<double>, Range<double>> m_file_cached;
bool m_image_dirty = false;
Image m_waveimage;
OpenGLContext m_ogl;
bool m_use_opengl = false;
double m_rec_pos = 0.0;
bool m_lock_timesel_set = false;
bool m_using_audio_buffer = false;
void updateCachedImage();
};
class SpectralChainEditor : public Component

View File

@ -7,7 +7,7 @@
buildVST3="0" buildAU="1" buildAUv3="0" buildRTAS="0" buildAAX="0"
buildStandalone="1" enableIAA="0" pluginName="PaulXStretch" pluginDesc="PaulXStretch"
pluginManufacturer="Xenakios" pluginManufacturerCode="XenS" pluginCode="Fn1r"
pluginChannelConfigs="{2,2},{2,4}, {2,8}, {8,8}" pluginIsSynth="0"
pluginChannelConfigs="{2,4}, {2,8}, {8,8}, {2,2}" pluginIsSynth="0"
pluginWantsMidiIn="0" pluginProducesMidiOut="0" pluginIsMidiEffectPlugin="0"
pluginEditorRequiresKeys="0" pluginAUExportPrefix="paulxstretchAU"
pluginRTASCategory="" aaxIdentifier="com.yourcompany.paulstretchplugin"