Rewriting of the offline rendering code
This commit is contained in:
parent
d4bab26693
commit
c1901c0528
@ -465,34 +465,16 @@ void PaulstretchpluginAudioProcessor::updateStretchParametersFromPluginParameter
|
|||||||
String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
|
String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
|
||||||
{
|
{
|
||||||
File outputfiletouse = outputfile.getNonexistentSibling();
|
File outputfiletouse = outputfile.getNonexistentSibling();
|
||||||
int numoutchans = *getIntParameter(cpi_num_outchans);
|
ValueTree state = getStateTree(false, false);
|
||||||
auto ss = std::make_shared<StretchAudioSource>(numoutchans,m_afm,m_sm_enab_pars);
|
auto processor = std::make_shared<PaulstretchpluginAudioProcessor>();
|
||||||
shared_envelope free_env = m_free_filter_envelope->duplicate();
|
processor->setStateFromTree(state);
|
||||||
ss->setFreeFilterEnvelope(free_env);
|
|
||||||
int blocksize = 2048;
|
int blocksize = 2048;
|
||||||
|
int numoutchans = *processor->getIntParameter(cpi_num_outchans);
|
||||||
ss->setAudioFile(m_current_file);
|
processor->prepareToPlay(44100.0, blocksize);
|
||||||
ProcessParameters renderpars;
|
double t0 = *processor->getFloatParameter(cpi_soundstart);
|
||||||
updateStretchParametersFromPluginParameters(renderpars);
|
double t1 = *processor->getFloatParameter(cpi_soundend);
|
||||||
ss->setProcessParameters(&renderpars);
|
|
||||||
double t0 = *getFloatParameter(cpi_soundstart);
|
|
||||||
double t1 = *getFloatParameter(cpi_soundend);
|
|
||||||
sanitizeTimeRange(t0, t1);
|
sanitizeTimeRange(t0, t1);
|
||||||
ss->setRate(*getFloatParameter(cpi_stretchamount));
|
double outsr = processor->getSampleRateChecked();
|
||||||
ss->setPlayRange({ t0,t1 });
|
|
||||||
ss->setLoopingEnabled(true);
|
|
||||||
ss->setNumOutChannels(numoutchans);
|
|
||||||
ss->setFFTWindowingType(1);
|
|
||||||
//ss->setPreviewDry(true);
|
|
||||||
ss->setOnsetDetection(*getFloatParameter(cpi_onsetdetection));
|
|
||||||
ss->setLoopXFadeLength(*getFloatParameter(cpi_loopxfadelen));
|
|
||||||
ss->setFreezing(getParameter(cpi_freeze));
|
|
||||||
ss->setPaused(getParameter(cpi_pause_enabled));
|
|
||||||
ss->setSpectrumProcessOrder(m_stretch_source->getSpectrumProcessOrder());
|
|
||||||
ss->setFFTSize(m_fft_size_to_use);
|
|
||||||
ss->setMainVolume(*getFloatParameter(cpi_main_volume));
|
|
||||||
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)
|
||||||
@ -503,9 +485,10 @@ String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
|
|||||||
delete outstream;
|
delete outstream;
|
||||||
return "Could not create WAV writer";
|
return "Could not create WAV writer";
|
||||||
}
|
}
|
||||||
auto rendertask = [ss,writer,blocksize,numoutchans, outsr, this]()
|
auto rendertask = [processor,writer,blocksize,numoutchans, outsr, this]()
|
||||||
{
|
{
|
||||||
AudioBuffer<float> renderbuffer(numoutchans, blocksize);
|
AudioBuffer<float> renderbuffer(numoutchans, blocksize);
|
||||||
|
MidiBuffer dummymidi;
|
||||||
int64_t outlen = 10 * outsr;
|
int64_t outlen = 10 * outsr;
|
||||||
int64_t outcounter = 0;
|
int64_t outcounter = 0;
|
||||||
AudioSourceChannelInfo asci(renderbuffer);
|
AudioSourceChannelInfo asci(renderbuffer);
|
||||||
@ -515,7 +498,7 @@ String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
|
|||||||
{
|
{
|
||||||
if (m_offline_render_cancel_requested == true)
|
if (m_offline_render_cancel_requested == true)
|
||||||
break;
|
break;
|
||||||
ss->getNextAudioBlock(asci);
|
processor->processBlock(renderbuffer, dummymidi);
|
||||||
writer->writeFromAudioSampleBuffer(renderbuffer, 0, blocksize);
|
writer->writeFromAudioSampleBuffer(renderbuffer, 0, blocksize);
|
||||||
outcounter += blocksize;
|
outcounter += blocksize;
|
||||||
m_offline_render_state = 100.0 / outlen * outcounter;
|
m_offline_render_state = 100.0 / outlen * outcounter;
|
||||||
|
Loading…
Reference in New Issue
Block a user