From 11e61f8cfd36b883db462d3fc8f781d6df8eb5a6 Mon Sep 17 00:00:00 2001 From: xenakios Date: Fri, 11 May 2018 16:45:34 +0300 Subject: [PATCH] Attempt to draw the points in the audio file where the FFTs are taken but of course it doesn't work like this because of the looping --- Source/PS_Source/StretchSource.h | 1 + Source/PluginEditor.cpp | 26 ++++++++++++++++++++++++++ Source/PluginEditor.h | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/Source/PS_Source/StretchSource.h b/Source/PS_Source/StretchSource.h index 0989d5c..b9830ab 100644 --- a/Source/PS_Source/StretchSource.h +++ b/Source/PS_Source/StretchSource.h @@ -106,6 +106,7 @@ public: void setPreviewDry(bool b); bool isPreviewingDry() const; int m_param_change_count = 0; + double getLastSeekPos() const { return m_seekpos; } CriticalSection* getMutex() { return &m_cs; } private: CircularBuffer m_stretchoutringbuf{ 1024 * 1024 }; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index fdf44f4..1a6f766 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -421,6 +421,8 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id) m_wavecomponent.setRecordingPosition(processor.getRecordingPositionPercent()); } else m_wavecomponent.setRecordingPosition(-1.0); + m_wavecomponent.setAudioInfo(processor.getSampleRateChecked(), processor.getStretchSource()->getLastSeekPos(), + processor.getStretchSource()->getFFTSize()); String infotext; if (processor.m_show_technical_info) { @@ -653,6 +655,8 @@ void WaveformComponent::paint(Graphics & g) thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 0.0f, (float)getWidth()); g.drawLine(tickxcor, 0.0, tickxcor, (float)m_topmargin, 1.0f); } + + bool m_use_cached_image = true; if (m_use_cached_image == true) { @@ -676,6 +680,18 @@ void WaveformComponent::paint(Graphics & g) m_thumbnail->drawChannels(g, { 0,m_topmargin,getWidth(),getHeight() - m_topmargin }, thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 1.0f); } + if (m_sr > 0.0 && m_fft_size > 0 && m_time_sel_start>=0.0) + { + tick_interval = 1.0 / m_sr * m_fft_size; + /* + for (double secs = m_time_sel_start*thumblen; secs < m_time_sel_end*thumblen; secs += tick_interval) + { + float tickxcor = (float)jmap(fmod(secs, thumblen), + thumblen*m_view_range.getStart(), thumblen*m_view_range.getEnd(), 0.0f, (float)getWidth()); + g.drawLine(tickxcor, (float)m_topmargin, tickxcor, (float)50, 2.0f); + } + */ + } if (m_is_at_selection_drag_area) g.setColour(Colours::white.withAlpha(0.6f)); else @@ -753,7 +769,10 @@ void WaveformComponent::mouseDown(const MouseEvent & e) if (e.y < m_topmargin || e.mods.isCommandDown()) { if (SeekCallback) + { SeekCallback(pos); + m_last_startpos = pos; + } m_didseek = true; } else @@ -880,6 +899,13 @@ void WaveformComponent::mouseWheelMove(const MouseEvent & e, const MouseWheelDet */ } +void WaveformComponent::setAudioInfo(double sr, double seekpos, int fftsize) +{ + m_sr = sr; + m_fft_size = fftsize; + m_last_startpos = seekpos; +} + Range WaveformComponent::getTimeSelection() { if (m_time_sel_start >= 0.0 && m_time_sel_end>m_time_sel_start + 0.001) diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 8690883..1db189b 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -142,6 +142,7 @@ public: void mouseMove(const MouseEvent& e) override; void mouseDoubleClick(const MouseEvent& e) override; void mouseWheelMove(const MouseEvent& e, const MouseWheelDetails& wd) override; + void setAudioInfo(double sr, double seekpos, int fftsize); Range getTimeSelection(); void setTimeSelection(Range rng); void setFileCachedRange(std::pair, Range> rng); @@ -165,6 +166,9 @@ private: int getTimeSelectionEdge(int x, int y); std::pair, Range> m_file_cached; bool m_image_dirty = false; + double m_sr = 0.0; + int m_fft_size = 0; + double m_last_startpos = 0.0; Image m_waveimage; #ifdef JUCE_MODULE_AVAILABLE_juce_opengl OpenGLContext m_ogl;