Do offline render in a thread, show render progress etc
This commit is contained in:
parent
46a74c2c51
commit
ba067f7d4a
@ -274,7 +274,9 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
|
|||||||
if (processor.m_playposinfo.isPlaying)
|
if (processor.m_playposinfo.isPlaying)
|
||||||
infotext += " "+String(processor.m_playposinfo.timeInSeconds,1);
|
infotext += " "+String(processor.m_playposinfo.timeInSeconds,1);
|
||||||
if (processor.m_show_technical_info)
|
if (processor.m_show_technical_info)
|
||||||
infotext += " " + String(m_wavecomponent.m_image_init_count) + " " + String(m_wavecomponent.m_image_update_count);
|
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)+"%";
|
||||||
m_info_label.setText(infotext, dontSendNotification);
|
m_info_label.setText(infotext, dontSendNotification);
|
||||||
m_perfmeter.repaint();
|
m_perfmeter.repaint();
|
||||||
}
|
}
|
||||||
@ -358,7 +360,8 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
|
|||||||
menu.addItem(6, "Dump preset to clipboard", true, false);
|
menu.addItem(6, "Dump preset to clipboard", true, false);
|
||||||
#endif
|
#endif
|
||||||
menu.addItem(7, "Show technical info", true, processor.m_show_technical_info);
|
menu.addItem(7, "Show technical info", true, processor.m_show_technical_info);
|
||||||
menu.addItem(8, "Offline render...", true, false);
|
menu.addItem(8, "Offline render...",
|
||||||
|
processor.m_offline_render_state == 200 || processor.m_offline_render_state == -1, false);
|
||||||
int r = menu.show();
|
int r = menu.show();
|
||||||
if (r >= 200 && r < 210)
|
if (r >= 200 && r < 210)
|
||||||
{
|
{
|
||||||
|
@ -417,8 +417,7 @@ String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
|
|||||||
int numoutchans = *getIntParameter(cpi_num_outchans);
|
int numoutchans = *getIntParameter(cpi_num_outchans);
|
||||||
auto ss = std::make_shared<StretchAudioSource>(numoutchans,m_afm);
|
auto ss = std::make_shared<StretchAudioSource>(numoutchans,m_afm);
|
||||||
int blocksize = 2048;
|
int blocksize = 2048;
|
||||||
int64_t outlen = 10 * getSampleRateChecked();
|
|
||||||
int64_t outcounter = 0;
|
|
||||||
ss->setAudioFile(m_current_file);
|
ss->setAudioFile(m_current_file);
|
||||||
ProcessParameters renderpars;
|
ProcessParameters renderpars;
|
||||||
updateStretchParametersFromPluginParameters(renderpars);
|
updateStretchParametersFromPluginParameters(renderpars);
|
||||||
@ -438,9 +437,9 @@ String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
|
|||||||
ss->setPaused(getParameter(cpi_pause_enabled));
|
ss->setPaused(getParameter(cpi_pause_enabled));
|
||||||
ss->setSpectrumProcessOrder(m_stretch_source->getSpectrumProcessOrder());
|
ss->setSpectrumProcessOrder(m_stretch_source->getSpectrumProcessOrder());
|
||||||
ss->setFFTSize(m_fft_size_to_use);
|
ss->setFFTSize(m_fft_size_to_use);
|
||||||
ss->prepareToPlay(blocksize, getSampleRateChecked());
|
ss->setMainVolume(*getFloatParameter(cpi_main_volume));
|
||||||
AudioBuffer<float> renderbuffer(numoutchans, blocksize);
|
double outsr = getSampleRateChecked();
|
||||||
|
ss->prepareToPlay(blocksize, outsr);
|
||||||
WavAudioFormat wavformat;
|
WavAudioFormat wavformat;
|
||||||
FileOutputStream* outstream = outputfiletouse.createOutputStream();
|
FileOutputStream* outstream = outputfiletouse.createOutputStream();
|
||||||
if (outstream == nullptr)
|
if (outstream == nullptr)
|
||||||
@ -451,15 +450,25 @@ String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
|
|||||||
delete outstream;
|
delete outstream;
|
||||||
return "Could not create WAV writer";
|
return "Could not create WAV writer";
|
||||||
}
|
}
|
||||||
AudioSourceChannelInfo asci(renderbuffer);
|
auto rendertask = [ss,writer,blocksize,numoutchans, outsr, this]()
|
||||||
while (outcounter < outlen)
|
|
||||||
{
|
{
|
||||||
ss->setMainVolume(*getFloatParameter(cpi_main_volume));
|
AudioBuffer<float> renderbuffer(numoutchans, blocksize);
|
||||||
ss->getNextAudioBlock(asci);
|
int64_t outlen = 50 * outsr;
|
||||||
writer->writeFromAudioSampleBuffer(renderbuffer,0,blocksize);
|
int64_t outcounter = 0;
|
||||||
outcounter += blocksize;
|
AudioSourceChannelInfo asci(renderbuffer);
|
||||||
}
|
m_offline_render_state = 0;
|
||||||
delete writer;
|
while (outcounter < outlen)
|
||||||
|
{
|
||||||
|
ss->getNextAudioBlock(asci);
|
||||||
|
writer->writeFromAudioSampleBuffer(renderbuffer, 0, blocksize);
|
||||||
|
outcounter += blocksize;
|
||||||
|
m_offline_render_state = 100.0 / outlen * outcounter;
|
||||||
|
}
|
||||||
|
m_offline_render_state = 200;
|
||||||
|
delete writer;
|
||||||
|
};
|
||||||
|
std::thread th(rendertask);
|
||||||
|
th.detach();
|
||||||
return "Rendered OK";
|
return "Rendered OK";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +162,7 @@ public:
|
|||||||
ValueTree getStateTree(bool ignoreoptions, bool ignorefile);
|
ValueTree getStateTree(bool ignoreoptions, bool ignorefile);
|
||||||
void setStateFromTree(ValueTree tree);
|
void setStateFromTree(ValueTree tree);
|
||||||
String offlineRender(File outputfile);
|
String offlineRender(File outputfile);
|
||||||
|
std::atomic<int> m_offline_render_state{ -1 };
|
||||||
bool m_state_dirty = false;
|
bool m_state_dirty = false;
|
||||||
std::unique_ptr<AudioThumbnail> m_thumb;
|
std::unique_ptr<AudioThumbnail> m_thumb;
|
||||||
bool m_show_technical_info = false;
|
bool m_show_technical_info = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user