diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index d4f1e8f..7cb74d3 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -360,8 +360,9 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() menu.addItem(6, "Dump preset to clipboard", true, false); #endif menu.addItem(7, "Show technical info", true, processor.m_show_technical_info); - menu.addItem(8, "Offline render...", - processor.m_offline_render_state == 200 || processor.m_offline_render_state == -1, false); + if (processor.m_offline_render_state==-1 || processor.m_offline_render_state == 200) + menu.addItem(8, "Offline render...", true, false); + else menu.addItem(9, "Cancel render", true, false); int r = menu.show(); if (r >= 200 && r < 210) { @@ -423,6 +424,10 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu() { processor.offlineRender(File("C:\\MusicAudio\\sourcesamples\\paultesmaus\\plugin_offline_test\\out.wav")); } + if (r == 9) + { + processor.m_offline_render_cancel_requested = true; + } } WaveformComponent::WaveformComponent(AudioFormatManager* afm, AudioThumbnail* thumb) diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 6915e3f..8250411 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -453,12 +453,15 @@ String PaulstretchpluginAudioProcessor::offlineRender(File outputfile) auto rendertask = [ss,writer,blocksize,numoutchans, outsr, this]() { AudioBuffer renderbuffer(numoutchans, blocksize); - int64_t outlen = 50 * outsr; + int64_t outlen = 250 * outsr; int64_t outcounter = 0; AudioSourceChannelInfo asci(renderbuffer); m_offline_render_state = 0; + m_offline_render_cancel_requested = false; while (outcounter < outlen) { + if (m_offline_render_cancel_requested == true) + break; ss->getNextAudioBlock(asci); writer->writeFromAudioSampleBuffer(renderbuffer, 0, blocksize); outcounter += blocksize; diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 8aae594..f2ec440 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -163,6 +163,7 @@ public: void setStateFromTree(ValueTree tree); String offlineRender(File outputfile); std::atomic m_offline_render_state{ -1 }; + std::atomic m_offline_render_cancel_requested{ false }; bool m_state_dirty = false; std::unique_ptr m_thumb; bool m_show_technical_info = false;