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)"; infotext += " (offline rendering)";
if (processor.m_playposinfo.isPlaying) if (processor.m_playposinfo.isPlaying)
infotext += " "+String(processor.m_playposinfo.timeInSeconds,1); 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_info_label.setText(infotext, dontSendNotification);
m_perfmeter.repaint(); m_perfmeter.repaint();
} }
@ -394,8 +395,21 @@ WaveformComponent::~WaveformComponent()
void WaveformComponent::changeListenerCallback(ChangeBroadcaster * /*cb*/) void WaveformComponent::changeListenerCallback(ChangeBroadcaster * /*cb*/)
{ {
m_waveimage = Image(); jassert(MessageManager::getInstance()->isThisTheMessageThread());
repaint(); 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) void WaveformComponent::paint(Graphics & g)
@ -425,16 +439,17 @@ void WaveformComponent::paint(Graphics & g)
bool m_use_cached_image = true; bool m_use_cached_image = true;
if (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) || m_waveimage.getHeight() != getHeight() - m_topmargin)
{ {
//Logger::writeToLog("updating cached waveform image"); //Logger::writeToLog("updating cached waveform image");
m_waveimage = Image(Image::ARGB, getWidth(), getHeight() - m_topmargin, true); if (m_waveimage.getWidth() != getWidth()
Graphics tempg(m_waveimage); || m_waveimage.getHeight() != getHeight() - m_topmargin)
tempg.fillAll(Colours::black); {
tempg.setColour(Colours::darkgrey); m_waveimage = Image(Image::ARGB, getWidth(), getHeight() - m_topmargin, true);
m_thumbnail->drawChannels(tempg, { 0,0,getWidth(),getHeight() - m_topmargin }, ++m_image_init_count;
thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 1.0f); }
updateCachedImage();
} }
g.drawImage(m_waveimage, 0, m_topmargin, getWidth(), getHeight() - m_topmargin, 0, 0, getWidth(), getHeight() - m_topmargin); 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); void setViewRange(Range<double> rng);
Value ShowFileCacheRange; Value ShowFileCacheRange;
void setRecordingPosition(double pos) { m_rec_pos = pos; } void setRecordingPosition(double pos) { m_rec_pos = pos; }
int m_image_init_count = 0;
int m_image_update_count = 0;
private: private:
AudioThumbnail* m_thumbnail = nullptr; AudioThumbnail* m_thumbnail = nullptr;
Range<double> m_view_range{ 0.0,1.0 }; Range<double> m_view_range{ 0.0,1.0 };
@ -128,13 +130,14 @@ private:
int m_topmargin = 0; int m_topmargin = 0;
int getTimeSelectionEdge(int x, int y); int getTimeSelectionEdge(int x, int y);
std::pair<Range<double>, Range<double>> m_file_cached; std::pair<Range<double>, Range<double>> m_file_cached;
bool m_image_dirty = false;
Image m_waveimage; Image m_waveimage;
OpenGLContext m_ogl; OpenGLContext m_ogl;
bool m_use_opengl = false; bool m_use_opengl = false;
double m_rec_pos = 0.0; double m_rec_pos = 0.0;
bool m_lock_timesel_set = false; bool m_lock_timesel_set = false;
bool m_using_audio_buffer = false; bool m_using_audio_buffer = false;
void updateCachedImage();
}; };
class SpectralChainEditor : public Component class SpectralChainEditor : public Component

View File

@ -7,7 +7,7 @@
buildVST3="0" buildAU="1" buildAUv3="0" buildRTAS="0" buildAAX="0" buildVST3="0" buildAU="1" buildAUv3="0" buildRTAS="0" buildAAX="0"
buildStandalone="1" enableIAA="0" pluginName="PaulXStretch" pluginDesc="PaulXStretch" buildStandalone="1" enableIAA="0" pluginName="PaulXStretch" pluginDesc="PaulXStretch"
pluginManufacturer="Xenakios" pluginManufacturerCode="XenS" pluginCode="Fn1r" 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" pluginWantsMidiIn="0" pluginProducesMidiOut="0" pluginIsMidiEffectPlugin="0"
pluginEditorRequiresKeys="0" pluginAUExportPrefix="paulxstretchAU" pluginEditorRequiresKeys="0" pluginAUExportPrefix="paulxstretchAU"
pluginRTASCategory="" aaxIdentifier="com.yourcompany.paulstretchplugin" pluginRTASCategory="" aaxIdentifier="com.yourcompany.paulstretchplugin"