From e411a99f704755590b2aa5b44940af107d640c3b Mon Sep 17 00:00:00 2001 From: xenakios Date: Wed, 13 Dec 2017 05:18:39 +0200 Subject: [PATCH] If capture buffer used, refresh waveform when GUI has been closed and reopened. --- Source/PS_Source/Input/AInputS.h | 6 ++++++ Source/PS_Source/Input/InputS.h | 2 +- Source/PS_Source/StretchSource.cpp | 7 +++++++ Source/PS_Source/StretchSource.h | 2 ++ Source/PluginEditor.cpp | 10 +++++++++- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Source/PS_Source/Input/AInputS.h b/Source/PS_Source/Input/AInputS.h index ad347b0..11a0619 100644 --- a/Source/PS_Source/Input/AInputS.h +++ b/Source/PS_Source/Input/AInputS.h @@ -65,6 +65,12 @@ public: seek(m_activerange.getStart()); updateXFadeCache(); } + virtual AudioBuffer* getAudioBuffer() override + { + if (m_using_memory_buffer) + return &m_readbuf; + return nullptr; + } bool openAudioFile(File file) override { m_silenceoutputted = 0; diff --git a/Source/PS_Source/Input/InputS.h b/Source/PS_Source/Input/InputS.h index b80b4d8..7742178 100644 --- a/Source/PS_Source/Input/InputS.h +++ b/Source/PS_Source/Input/InputS.h @@ -79,7 +79,7 @@ public: { return m_currentsample >= info.nsamples*m_activerange.getEnd(); } - + virtual AudioBuffer* getAudioBuffer()=0; protected: volatile int64_t m_currentsample = 0; int m_silenceoutputted = 0; diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index 00184a3..b74f02b 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -44,6 +44,13 @@ void StretchAudioSource::releaseResources() } +AudioBuffer* StretchAudioSource::getSourceAudioBuffer() +{ + if (m_inputfile==nullptr) + return nullptr; + return m_inputfile->getAudioBuffer(); +} + bool StretchAudioSource::isResampling() { if (m_inputfile==nullptr || m_inputfile->info.samplerate==0) diff --git a/Source/PS_Source/StretchSource.h b/Source/PS_Source/StretchSource.h index 3ffc413..054f5f0 100644 --- a/Source/PS_Source/StretchSource.h +++ b/Source/PS_Source/StretchSource.h @@ -51,6 +51,8 @@ public: String setAudioFile(File file); File getAudioFile(); + AudioBuffer* getSourceAudioBuffer(); + void setNumOutChannels(int chans); int getNumOutChannels() { return m_num_outchans; } double getInfilePositionPercent(); diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index f612f0c..9096472 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -111,6 +111,13 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id) { m_wavecomponent.setAudioFile(processor.getAudioFile()); } + if (processor.getAudioFile()==File() && processor.isRecordingEnabled()==false) + { + auto bufptr = processor.getStretchSource()->getSourceAudioBuffer(); + if (bufptr!=nullptr) + m_wavecomponent.setAudioBuffer(bufptr, + processor.getSampleRate(), bufptr->getNumSamples()); + } m_wavecomponent.setTimeSelection(processor.getTimeSelection()); } @@ -297,7 +304,8 @@ void WaveformComponent::setAudioFile(File f) void WaveformComponent::setAudioBuffer(AudioBuffer* buf, int samplerate, int len) { - m_waveimage = Image(); + jassert(buf!=nullptr); + m_waveimage = Image(); m_curfile = File(); m_thumb->reset(buf->getNumChannels(), samplerate, len); m_thumb->addBlock(0, *buf, 0, len);