From c5e4f78d0f4255c20cabcecee3b813099be23498 Mon Sep 17 00:00:00 2001 From: xenakios Date: Fri, 1 Jun 2018 16:31:31 +0300 Subject: [PATCH] Add option to mute audio when capturing --- Source/PluginEditor.cpp | 6 +++++- Source/PluginProcessor.cpp | 4 +++- Source/PluginProcessor.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index a2d0020..e93611b 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -520,7 +520,7 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() menu.addItem(5, "Load file with plugin state", true, processor.m_load_file_with_state); menu.addItem(1, "Play when host transport running", true, processor.m_play_when_host_plays); menu.addItem(2, "Capture when host transport running", true, processor.m_capture_when_host_plays); - + menu.addItem(8, "Mute audio while capturing", true, processor.m_mute_while_capturing); int capturelen = *processor.getFloatParameter(cpi_max_capture_len); PopupMenu capturelenmenu; std::vector capturelens{ 2,5,10,30,60,120 }; @@ -547,6 +547,10 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() { toggleBool(processor.m_capture_when_host_plays); } + if (r == 8) + { + toggleBool(processor.m_mute_while_capturing); + } if (r == 4) { processor.resetParameters(); diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 7afdb3c..b7d2005 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -662,6 +662,8 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M copyAudioBufferWrappingPosition(buffer, m_recbuffer, m_rec_pos, recbuflenframes); m_thumb->addBlock(m_rec_pos, buffer, 0, buffer.getNumSamples()); m_rec_pos = (m_rec_pos + buffer.getNumSamples()) % recbuflenframes; + if (m_mute_while_capturing == true) + buffer.clear(); return; } jassert(m_buffering_source != nullptr); @@ -728,7 +730,7 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M { m_buffering_source->getNextAudioBlock(aif); } - if (getParameter(cpi_passthrough) > 0.5f) + if (m_is_recording == false && getParameter(cpi_passthrough) > 0.5f) { for (int i = 0; i < totalNumInputChannels; ++i) { diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 2e2a703..df9c845 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -188,6 +188,7 @@ public: AudioPlayHead::CurrentPositionInfo m_playposinfo; bool m_play_when_host_plays = false; bool m_capture_when_host_plays = false; + bool m_mute_while_capturing = false; bool m_use_backgroundbuffering = true; void resetParameters(); void setPreBufferAmount(int x);