From 8bf3225b83e794911b9aff99708ac137dde35c8c Mon Sep 17 00:00:00 2001 From: xenakios Date: Wed, 17 Jan 2018 21:53:26 +0200 Subject: [PATCH] Restore ability to set capture buffer lengthm now via settings menu. Use AudioProcessor owned thumbnail for live input captured audio. Still need to clean up some of the old messy code that is now commented out. --- Source/PluginEditor.cpp | 13 +++++++++++++ Source/PluginProcessor.cpp | 9 ++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 0a989c8..03d3990 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -98,6 +98,8 @@ void PaulstretchpluginAudioProcessorEditor::resized() int yoffs = 30; int div = w / 4; m_parcomps[cpi_capture_enabled]->setBounds(xoffs, yoffs, div-1, 24); + //xoffs += div; + //m_parcomps[cpi_max_capture_len]->setBounds(xoffs, yoffs, div - 1, 24); xoffs += div; m_parcomps[cpi_passthrough]->setBounds(xoffs, yoffs, div - 1, 24); xoffs += div; @@ -317,11 +319,22 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() bufferingmenu.addItem(104,"Very large",true,curbufamount == 4); bufferingmenu.addItem(105,"Huge",true,curbufamount == 5); menu.addSubMenu("Prebuffering", bufferingmenu); + int capturelen = *processor.getFloatParameter(cpi_max_capture_len); + PopupMenu capturelenmenu; + std::vector capturelens{ 2,5,10,30,60,120 }; + for (int i=0;i= 200 && r < 210) + { + int caplen = capturelens[r - 200]; + *processor.getFloatParameter(cpi_max_capture_len) = (float)caplen; + } if (r == 1) { processor.m_play_when_host_plays = !processor.m_play_when_host_plays; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index c8ae7c4..fa1be3b 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -441,7 +441,8 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl m_stretch_source->setAudioBufferAsInputSource(&m_recbuffer, getSampleRateChecked(), len); - callGUI(this,[this,len](auto ed) { ed->setAudioBuffer(&m_recbuffer, getSampleRateChecked(), len); },false); + m_thumb->reset(m_recbuffer.getNumChannels(), sampleRate, len); + //callGUI(this,[this,len](auto ed) { ed->setAudioBuffer(&m_recbuffer, getSampleRateChecked(), len); },false); } if (m_prebuffering_inited == false) { @@ -535,10 +536,13 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M return; int recbuflenframes = m_max_reclen * getSampleRate(); copyAudioBufferWrappingPosition(buffer, m_recbuffer, m_rec_pos, recbuflenframes); + m_thumb->addBlock(m_rec_pos, buffer, 0, buffer.getNumSamples()); + /* callGUI(this,[this, &buffer](PaulstretchpluginAudioProcessorEditor*ed) { ed->addAudioBlock(buffer, getSampleRate(), m_rec_pos); }, false); + */ m_rec_pos = (m_rec_pos + buffer.getNumSamples()) % recbuflenframes; return; } @@ -657,10 +661,13 @@ void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b) m_recbuffer.setSize(2, m_max_reclen*getSampleRateChecked()+4096,false,false,true); m_recbuffer.clear(); m_rec_pos = 0; + /* callGUI(this,[this,lenbufframes](PaulstretchpluginAudioProcessorEditor* ed) { ed->beginAddingAudioBlocks(2, getSampleRateChecked(), lenbufframes); },false); + */ + m_thumb->reset(m_recbuffer.getNumChannels(), getSampleRateChecked(), lenbufframes); m_is_recording = true; } else