| @@ -321,6 +321,7 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer | |||||
| int readed = 0; | int readed = 0; | ||||
| if (readsize != 0) | if (readsize != 0) | ||||
| { | { | ||||
| m_last_filepos = m_inputfile->getCurrentPosition(); | |||||
| readed = m_inputfile->readNextBlock(m_file_inbuf, readsize, m_num_outchans); | readed = m_inputfile->readNextBlock(m_file_inbuf, readsize, m_num_outchans); | ||||
| } | } | ||||
| if (m_rand_count % (int)m_free_filter_envelope->m_transform_y_random_rate == 0) | if (m_rand_count % (int)m_free_filter_envelope->m_transform_y_random_rate == 0) | ||||
| @@ -362,7 +363,7 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -57,7 +57,11 @@ public: | |||||
| double getInfilePositionSeconds(); | double getInfilePositionSeconds(); | ||||
| double getInfileLengthSeconds(); | double getInfileLengthSeconds(); | ||||
| void setRate(double rate); | void setRate(double rate); | ||||
| double getRate() { return m_playrate; } | |||||
| double getRate() | |||||
| { | |||||
| return m_playrate; | |||||
| } | |||||
| double getOutputSamplerate() const { return m_outsr; } | |||||
| void setProcessParameters(ProcessParameters* pars); | void setProcessParameters(ProcessParameters* pars); | ||||
| const ProcessParameters& getProcessParameters(); | const ProcessParameters& getProcessParameters(); | ||||
| void setFFTSize(int size); | void setFFTSize(int size); | ||||
| @@ -107,6 +111,7 @@ public: | |||||
| int m_param_change_count = 0; | int m_param_change_count = 0; | ||||
| double getLastSeekPos() const { return m_seekpos; } | double getLastSeekPos() const { return m_seekpos; } | ||||
| CriticalSection* getMutex() { return &m_cs; } | CriticalSection* getMutex() { return &m_cs; } | ||||
| int64_t getLastSourcePosition() const { return m_last_filepos; } | |||||
| private: | private: | ||||
| CircularBuffer<float> m_stretchoutringbuf{ 1024 * 1024 }; | CircularBuffer<float> m_stretchoutringbuf{ 1024 * 1024 }; | ||||
| AudioBuffer<float> m_file_inbuf; | AudioBuffer<float> m_file_inbuf; | ||||
| @@ -165,5 +170,6 @@ private: | |||||
| bool m_preview_dry = false; | bool m_preview_dry = false; | ||||
| double m_dryplayrate = 1.0; | double m_dryplayrate = 1.0; | ||||
| AudioBuffer<float> m_drypreviewbuf; | AudioBuffer<float> m_drypreviewbuf; | ||||
| int64_t m_last_filepos = 0; | |||||
| void playDrySound(const AudioSourceChannelInfo & bufferToFill); | void playDrySound(const AudioSourceChannelInfo & bufferToFill); | ||||
| }; | }; | ||||
| @@ -24,7 +24,7 @@ www.gnu.org/licenses | |||||
| //============================================================================== | //============================================================================== | ||||
| PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(PaulstretchpluginAudioProcessor& p) | PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(PaulstretchpluginAudioProcessor& p) | ||||
| : AudioProcessorEditor(&p), | : AudioProcessorEditor(&p), | ||||
| m_wavecomponent(p.m_afm,p.m_thumb.get()), | |||||
| m_wavecomponent(p.m_afm,p.m_thumb.get(), p.getStretchSource()), | |||||
| processor(p), m_perfmeter(&p), | processor(p), m_perfmeter(&p), | ||||
| m_wavefilter_tab(p.m_cur_tab_index), | m_wavefilter_tab(p.m_cur_tab_index), | ||||
| m_free_filter_component(&p) | m_free_filter_component(&p) | ||||
| @@ -568,7 +568,8 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() | |||||
| } | } | ||||
| WaveformComponent::WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb) | |||||
| WaveformComponent::WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb, StretchAudioSource* sas) | |||||
| : m_sas(sas) | |||||
| { | { | ||||
| TimeSelectionChangedCallback = [](Range<double>, int) {}; | TimeSelectionChangedCallback = [](Range<double>, int) {}; | ||||
| #ifdef JUCE_MODULE_AVAILABLE_juce_opengl | #ifdef JUCE_MODULE_AVAILABLE_juce_opengl | ||||
| @@ -700,7 +701,12 @@ void WaveformComponent::paint(Graphics & g) | |||||
| g.setColour(Colours::white); | g.setColour(Colours::white); | ||||
| if (CursorPosCallback) | if (CursorPosCallback) | ||||
| { | { | ||||
| g.fillRect(normalizedToViewX<int>(CursorPosCallback()), m_topmargin, 1, getHeight() - m_topmargin); | |||||
| 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; | |||||
| g.fillRect(normalizedToViewX<int>(curpos), m_topmargin, 1, getHeight() - m_topmargin); | |||||
| g.drawText(String(curpos), 1, 30, 200,30, Justification::left); | |||||
| //g.fillRect(normalizedToViewX<int>(CursorPosCallback()), m_topmargin, 1, getHeight() - m_topmargin); | |||||
| } | } | ||||
| if (m_rec_pos >= 0.0) | if (m_rec_pos >= 0.0) | ||||
| { | { | ||||
| @@ -714,6 +720,11 @@ void WaveformComponent::paint(Graphics & g) | |||||
| void WaveformComponent::timerCallback() | void WaveformComponent::timerCallback() | ||||
| { | { | ||||
| if (m_sas->getLastSourcePosition() != m_last_source_pos) | |||||
| { | |||||
| m_last_source_pos = m_sas->getLastSourcePosition(); | |||||
| m_last_source_pos_update_time = Time::getMillisecondCounterHiRes(); | |||||
| } | |||||
| repaint(); | repaint(); | ||||
| } | } | ||||
| @@ -128,7 +128,7 @@ public: | |||||
| class WaveformComponent : public Component, public ChangeListener, public Timer | class WaveformComponent : public Component, public ChangeListener, public Timer | ||||
| { | { | ||||
| public: | public: | ||||
| WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb); | |||||
| WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb, StretchAudioSource* sas); | |||||
| ~WaveformComponent(); | ~WaveformComponent(); | ||||
| void changeListenerCallback(ChangeBroadcaster* cb) override; | void changeListenerCallback(ChangeBroadcaster* cb) override; | ||||
| void paint(Graphics& g) override; | void paint(Graphics& g) override; | ||||
| @@ -171,7 +171,10 @@ private: | |||||
| double m_sr = 0.0; | double m_sr = 0.0; | ||||
| int m_fft_size = 0; | int m_fft_size = 0; | ||||
| double m_last_startpos = 0.0; | double m_last_startpos = 0.0; | ||||
| int64_t m_last_source_pos = -1; | |||||
| double m_last_source_pos_update_time = 0.0; | |||||
| Image m_waveimage; | Image m_waveimage; | ||||
| StretchAudioSource* m_sas = nullptr; | |||||
| #ifdef JUCE_MODULE_AVAILABLE_juce_opengl | #ifdef JUCE_MODULE_AVAILABLE_juce_opengl | ||||
| OpenGLContext m_ogl; | OpenGLContext m_ogl; | ||||
| bool m_use_opengl = false; | bool m_use_opengl = false; | ||||