From 890c568155442d666bbc962fc815da42b0d1342b Mon Sep 17 00:00:00 2001 From: xenakios Date: Mon, 2 Apr 2018 20:07:55 +0300 Subject: [PATCH] Attempt implementing seek while frozen, doesn't work too well like this...Don't use opengl stuff at all if the opengl module isn't set available. --- Source/PS_Source/StretchSource.cpp | 21 ++++++++++++++++++--- Source/PS_Source/StretchSource.h | 2 +- Source/PluginEditor.cpp | 4 ++++ Source/PluginEditor.h | 2 ++ paulstretchplugin.jucer | 4 ---- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index 1041963..3c7065b 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -246,13 +246,20 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer if (m_stretchoutringbuf.available() > 0) m_output_has_begun = true; bool freezing = m_freezing; - - if (m_stretchers[0]->isFreezing() != freezing) + if (m_do_freeze_seek == true) + { + freezing = false; + m_stretchoutringbuf.clear(); + m_firstbuffer = true; + } + if (m_stretchers[0]->isFreezing() != freezing) { if (freezing == true && m_inputfile!=nullptr) m_freeze_pos = 1.0/m_inputfile->info.nsamples*m_inputfile->getCurrentPosition(); for (auto& e : m_stretchers) - e->set_freezing(m_freezing); + { + e->set_freezing(freezing); + } } @@ -381,6 +388,12 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer //Logger::writeToLog("Rerunning resampler task"); resamplertask(); } + if (m_do_freeze_seek == true) + { + for (auto& e : m_stretchers) + e->set_freezing(true); + m_do_freeze_seek = false; + } bool source_ended = m_inputfile->hasEnded(); double samplelimit = 16384.0; if (m_clip_output == true) @@ -666,6 +679,8 @@ bool StretchAudioSource::isPaused() const void StretchAudioSource::seekPercent(double pos) { ScopedLock locker(m_cs); + if (m_freezing == true) + m_do_freeze_seek = true; m_seekpos = pos; //m_resampler->Reset(); m_inputfile->seek(pos); diff --git a/Source/PS_Source/StretchSource.h b/Source/PS_Source/StretchSource.h index 5a4fbee..c112249 100644 --- a/Source/PS_Source/StretchSource.h +++ b/Source/PS_Source/StretchSource.h @@ -130,7 +130,7 @@ private: double m_seekpos = 0.0; bool m_freezing = false; - + bool m_do_freeze_seek = false; int m_pause_state = 0; Range m_playrange{ 0.0,1.0 }; int64_t m_rand_count = 0; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index cd58b5f..9d0714f 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -505,8 +505,10 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() WaveformComponent::WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb) { TimeSelectionChangedCallback = [](Range, int) {}; +#ifdef JUCE_MODULE_AVAILABLE_juce_opengl if (m_use_opengl == true) m_ogl.attachTo(*this); +#endif m_thumbnail = thumb; m_thumbnail->addChangeListener(this); setOpaque(true); @@ -514,8 +516,10 @@ WaveformComponent::WaveformComponent(AudioFormatManager* afm, AudioThumbnail* th WaveformComponent::~WaveformComponent() { +#ifdef JUCE_MODULE_AVAILABLE_juce_opengl if (m_use_opengl == true) m_ogl.detach(); +#endif m_thumbnail->removeChangeListener(this); } diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 2aff22e..6e04b41 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -165,8 +165,10 @@ private: std::pair, Range> m_file_cached; bool m_image_dirty = false; Image m_waveimage; +#ifdef JUCE_MODULE_AVAILABLE_juce_opengl OpenGLContext m_ogl; bool m_use_opengl = false; +#endif double m_rec_pos = 0.0; bool m_lock_timesel_set = false; bool m_using_audio_buffer = false; diff --git a/paulstretchplugin.jucer b/paulstretchplugin.jucer index 8dc36f9..0d374a5 100644 --- a/paulstretchplugin.jucer +++ b/paulstretchplugin.jucer @@ -69,7 +69,6 @@ - @@ -99,7 +98,6 @@ - @@ -123,7 +121,6 @@ - @@ -148,7 +145,6 @@ -