From eace6f6d538699e91f3d35baaa7877bf6cbf9873 Mon Sep 17 00:00:00 2001 From: xenakios Date: Thu, 13 Sep 2018 14:04:56 +0300 Subject: [PATCH] Playcursor tweaks but still wonky --- Source/PS_Source/StretchSource.h | 1 + Source/PluginEditor.cpp | 6 ++++-- Source/PluginProcessor.cpp | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Source/PS_Source/StretchSource.h b/Source/PS_Source/StretchSource.h index 352b1db..f607b93 100644 --- a/Source/PS_Source/StretchSource.h +++ b/Source/PS_Source/StretchSource.h @@ -112,6 +112,7 @@ public: double getLastSeekPos() const { return m_seekpos; } CriticalSection* getMutex() { return &m_cs; } int64_t getLastSourcePosition() const { return m_last_filepos; } + int m_prebuffersize = 0; private: CircularBuffer m_stretchoutringbuf{ 1024 * 1024 }; AudioBuffer m_file_inbuf; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 24e7066..ee285cc 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -702,8 +702,10 @@ void WaveformComponent::paint(Graphics & g) if (CursorPosCallback) { double timediff = (Time::getMillisecondCounterHiRes() - m_last_source_pos_update_time)*(1.0/m_sas->getRate()); - double curpos = ((double)m_last_source_pos / m_sas->getOutputSamplerate()) + (timediff/1000.0); - curpos = 1.0 / m_sas->getInfileLengthSeconds()*curpos; + double curpos = ((double)m_last_source_pos / m_sas->getOutputSamplerate()); + double prebufoffset = (double)m_sas->m_prebuffersize / m_sas->getOutputSamplerate(); + curpos -= prebufoffset; + curpos = 1.0 / m_sas->getInfileLengthSeconds()*(curpos+(timediff / 1000.0)); g.fillRect(normalizedToViewX(curpos), m_topmargin, 1, getHeight() - m_topmargin); g.drawText(String(curpos), 1, 30, 200,30, Justification::left); //g.fillRect(normalizedToViewX(CursorPosCallback()), m_topmargin, 1, getHeight() - m_topmargin); diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 21e7ce5..60b6256 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -226,7 +226,8 @@ void PaulstretchpluginAudioProcessor::setPreBufferAmount(int x) String err; startplay({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) }, m_cur_num_out_chans, m_curmaxblocksize, err); - m_prebuffering_inited = true; + + m_prebuffering_inited = true; } } @@ -422,6 +423,7 @@ void PaulstretchpluginAudioProcessor::startplay(Range playrange, int num m_stretch_source->setNumOutChannels(numoutchans); m_stretch_source->setFFTSize(m_fft_size_to_use); m_stretch_source->setProcessParameters(&m_ppar); + m_stretch_source->m_prebuffersize = bufamt; m_last_outpos_pos = 0.0; m_last_in_pos = playrange.getStart()*m_stretch_source->getInfileLengthSeconds(); m_buffering_source->prepareToPlay(maxBlockSize, getSampleRateChecked());