diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index f34b51c..a522e16 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -292,6 +292,10 @@ void PaulstretchpluginAudioProcessorEditor::executeModalMenuAction(int menuid, i { toggleBool(processor.m_load_file_with_state); } + if (r == 9) + { + toggleBool(processor.m_save_captured_audio); + } if (r == 3) { showAbout(); @@ -470,6 +474,8 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id) infotext += " " + String(m_wavecomponent.m_image_init_count) + " " + String(m_wavecomponent.m_image_update_count)+ " "; if (processor.m_offline_render_state >= 0 && processor.m_offline_render_state <= 100) infotext += String(processor.m_offline_render_state)+"%"; + if (processor.m_capture_save_state == 1) + infotext += "Saving captured audio..."; m_info_label.setText(infotext, dontSendNotification); } @@ -559,6 +565,7 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() m_settings_menu.addItem(1, "Play when host transport running", true, processor.m_play_when_host_plays); m_settings_menu.addItem(2, "Capture when host transport running", true, processor.m_capture_when_host_plays); m_settings_menu.addItem(8, "Mute audio while capturing", true, processor.m_mute_while_capturing); + m_settings_menu.addItem(9, "Save captured audio to disk", true, processor.m_save_captured_audio); int capturelen = *processor.getFloatParameter(cpi_max_capture_len); PopupMenu capturelenmenu; diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index e8da358..8275f73 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -319,6 +319,7 @@ public: void chooseFile(); void showRenderDialog(); void executeModalMenuAction(int menuid, int actionid); + private: PaulstretchpluginAudioProcessor& processor; uptrvec m_parcomps; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 9ff1ebc..11d2611 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -260,8 +260,9 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool else paramtree.setProperty("prebufamount", -1, nullptr); paramtree.setProperty("loadfilewithstate", m_load_file_with_state, nullptr); - storeToTreeProperties(paramtree, nullptr, "playwhenhostrunning", m_play_when_host_plays, "capturewhenhostrunning", m_capture_when_host_plays); - storeToTreeProperties(paramtree, nullptr, "mutewhilecapturing", m_mute_while_capturing); + storeToTreeProperties(paramtree, nullptr, "playwhenhostrunning", m_play_when_host_plays, + "capturewhenhostrunning", m_capture_when_host_plays,"savecapturedaudio",m_save_captured_audio, + "mutewhilecapturing",m_mute_while_capturing); } storeToTreeProperties(paramtree, nullptr, "tabaindex", m_cur_tab_index); storeToTreeProperties(paramtree, nullptr, "waveviewrange", m_wave_view_range); @@ -280,7 +281,8 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree) m_free_filter_envelope->restoreState(freefilterstate); m_load_file_with_state = tree.getProperty("loadfilewithstate", true); getFromTreeProperties(tree, "playwhenhostrunning", m_play_when_host_plays, - "capturewhenhostrunning", m_capture_when_host_plays,"mutewhilecapturing",m_mute_while_capturing); + "capturewhenhostrunning", m_capture_when_host_plays,"mutewhilecapturing",m_mute_while_capturing, + "savecapturedaudio",m_save_captured_audio); getFromTreeProperties(tree, "tabaindex", m_cur_tab_index); if (tree.hasProperty("numspectralstagesb")) { @@ -495,6 +497,7 @@ void PaulstretchpluginAudioProcessor::saveCaptureBuffer() outfile.create(); if (outfile.existsAsFile()) { + m_capture_save_state = 1; auto outstream = outfile.createOutputStream(); auto writer = unique_from_raw(wavformat.createWriterFor(outstream, getSampleRateChecked(), inchans, 32, {}, 0)); @@ -515,6 +518,7 @@ void PaulstretchpluginAudioProcessor::saveCaptureBuffer() } else Logger::writeToLog("Could not create output file"); + m_capture_save_state = 0; }; m_threadpool->addJob(task); } @@ -990,7 +994,10 @@ void PaulstretchpluginAudioProcessor::finishRecording(int lenrecording) m_stretch_source->setAudioBufferAsInputSource(&m_recbuffer, getSampleRateChecked(), lenrecording); *getFloatParameter(cpi_soundstart) = 0.0f; *getFloatParameter(cpi_soundend) = jlimit(0.01, 1.0, 1.0 / lenrecording * m_rec_count); - saveCaptureBuffer(); + if (m_save_captured_audio == true) + { + saveCaptureBuffer(); + } } AudioProcessor* JUCE_CALLTYPE createPluginFilter() diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index d4ab888..8d517e0 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -205,6 +205,7 @@ public: String offlineRender(File outputfile); std::atomic m_offline_render_state{ -1 }; std::atomic m_offline_render_cancel_requested{ false }; + std::atomic m_capture_save_state{ 0 }; bool m_state_dirty = false; std::unique_ptr m_thumb; bool m_show_technical_info = false; @@ -225,6 +226,7 @@ public: float opt) override; int m_cur_tab_index = 0; bool m_is_recording = false; + bool m_save_captured_audio = true; private: bool m_prebuffering_inited = false; AudioBuffer m_recbuffer;