diff --git a/Source/PS_Source/Input/AInputS.h b/Source/PS_Source/Input/AInputS.h index 7fcf278..bbbf174 100644 --- a/Source/PS_Source/Input/AInputS.h +++ b/Source/PS_Source/Input/AInputS.h @@ -23,6 +23,7 @@ #include "../JuceLibraryCode/JuceHeader.h" #include "InputS.h" +#include inline double ramp(int64_t pos, int64_t totallen, int64_t rampinlen, int64_t rampoutlen) { @@ -238,7 +239,10 @@ public: if (m_afreader != nullptr && m_using_memory_buffer == false) m_afreader->read(&m_crossfadebuf, 0, m_xfadelen, (int64_t)(m_activerange.getStart()*info.nsamples), true, true); if (m_afreader == nullptr && m_using_memory_buffer == true) - m_crossfadebuf.copyFrom(0, 0, m_readbuf, 0, (int64_t)(m_activerange.getStart()*info.nsamples), m_xfadelen); + { + for (int i=0;i((int64_t)(m_activerange.getStart()*info.nsamples),(int64_t)(m_activerange.getStart()*info.nsamples+m_xfadelen)); } diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index b0f260e..11df881 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -46,6 +46,7 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor (Pa }; m_wavecomponent.ShowFileCacheRange = true; startTimer(1, 100); + startTimer(2, 1000); m_wavecomponent.startTimer(100); } @@ -113,6 +114,14 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id) double prebufavail=processor.m_control->getPreBufferingPercent(); m_info_label.setText(String(prebufavail,1), dontSendNotification); } + if (id == 2) + { + if (processor.getAudioFile() != File() && processor.getAudioFile() != m_wavecomponent.getAudioFile()) + { + m_wavecomponent.setAudioFile(processor.getAudioFile()); + } + m_wavecomponent.setTimeSelection(processor.getTimeSelection()); + } } void PaulstretchpluginAudioProcessorEditor::setAudioFile(File f) @@ -264,6 +273,7 @@ void WaveformComponent::setAudioFile(File f) else { m_thumb->setSource(nullptr); + m_curfile = File(); } repaint(); } @@ -318,6 +328,7 @@ void WaveformComponent::setViewRange(Range rng) void WaveformComponent::mouseDown(const MouseEvent & e) { m_mousedown = true; + m_lock_timesel_set = true; double pos = jmap(e.x, 0, getWidth(), m_view_range.getStart(), m_view_range.getEnd()); if (e.y < m_topmargin) { @@ -341,6 +352,7 @@ void WaveformComponent::mouseDown(const MouseEvent & e) void WaveformComponent::mouseUp(const MouseEvent & /*e*/) { + m_lock_timesel_set = false; m_mousedown = false; m_didseek = false; if (m_didchangetimeselection) diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index d0ce6eb..95d654d 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -78,6 +78,7 @@ public: void changeListenerCallback(ChangeBroadcaster* cb) override; void paint(Graphics& g) override; void setAudioFile(File f); + const File& getAudioFile() const { return m_curfile; } void setAudioBuffer(AudioBuffer* buf, int samplerate, int len); void beginAddingAudioBlocks(int channels, int samplerate, int totalllen); void addAudioBlock(AudioBuffer& buf, int samplerate, int pos); @@ -97,6 +98,8 @@ public: } void setTimeSelection(Range rng) { + if (m_lock_timesel_set == true) + return; if (rng.isEmpty()) rng = { -1.0,1.0 }; m_time_sel_start = rng.getStart(); @@ -128,6 +131,7 @@ private: OpenGLContext m_ogl; bool m_use_opengl = false; double m_rec_pos = 0.0; + bool m_lock_timesel_set = false; }; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index e037d61..3a4845e 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -280,7 +280,6 @@ void PaulstretchpluginAudioProcessor::getStateInformation (MemoryBlock& destData void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { - return; ValueTree tree = ValueTree::readFromData(data, sizeInBytes); if (tree.isValid()) { @@ -296,15 +295,6 @@ void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int m_using_memory_buffer = false; File f(fn); setAudioFile(f); - Timer::callAfterDelay(500, [this,f]() - { - callGUI(this,[f,this](PaulstretchpluginAudioProcessorEditor* ed) - { - ed->setAudioFile(f); - ed->m_wavecomponent.setTimeSelection({ *getFloatParameter(5),*getFloatParameter(6) }); - }, false); - }); - } } } @@ -354,6 +344,11 @@ String PaulstretchpluginAudioProcessor::setAudioFile(File f) return String(); } +Range PaulstretchpluginAudioProcessor::getTimeSelection() +{ + return { *getFloatParameter(5),*getFloatParameter(6) }; +} + void PaulstretchpluginAudioProcessor::finishRecording(int lenrecording) { m_is_recording = false; diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 3042a5a..461c026 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -64,6 +64,7 @@ public: double getRecordingPositionPercent(); String setAudioFile(File f); File getAudioFile() { return m_current_file; } + Range getTimeSelection(); std::unique_ptr m_afm; std::unique_ptr m_control; private: @@ -75,7 +76,7 @@ private: bool m_is_recording = false; int m_rec_pos = 0; void finishRecording(int lenrecorded); - bool m_using_memory_buffer = false; + bool m_using_memory_buffer = true; int m_cur_num_out_chans = 2; std::mutex m_mutex; File m_current_file; diff --git a/paulstretchplugin.jucer b/paulstretchplugin.jucer index d037cfe..166aeb9 100644 --- a/paulstretchplugin.jucer +++ b/paulstretchplugin.jucer @@ -86,11 +86,11 @@ + headerPath="Source/PS_Source Source/WDL " vstBinaryLocation="C:\VSTPlugins_64bit"/> + headerPath="Source/PS_Source Source/WDL " vstBinaryLocation="C:\VSTPlugins_64bit"/>