Something seriously wrong in the offline rendering...

This commit is contained in:
xenakios 2019-01-20 20:21:29 +02:00
parent b0c8388b6b
commit cf85f992c8

View File

@ -537,19 +537,24 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
if (outsr < 10.0) if (outsr < 10.0)
outsr = processor->getStretchSource()->getInfileSamplerate(); outsr = processor->getStretchSource()->getInfileSamplerate();
Logger::writeToLog(outputfiletouse.getFullPathName() + " " + String(outsr) + " " + String(renderpars.outputformat)); Logger::writeToLog(outputfiletouse.getFullPathName() + " " + String(outsr) + " " + String(renderpars.outputformat));
return {};
int blocksize{ 2048 }; int blocksize{ 2048 };
int numoutchans = *processor->getIntParameter(cpi_num_outchans); int numoutchans = *processor->getIntParameter(cpi_num_outchans);
processor->setPlayConfigDetails(0, numoutchans, outsr, blocksize);
processor->prepareToPlay(renderpars.outsr, blocksize); processor->prepareToPlay(renderpars.outsr, blocksize);
double t0 = *processor->getFloatParameter(cpi_soundstart); double t0 = *processor->getFloatParameter(cpi_soundstart);
double t1 = *processor->getFloatParameter(cpi_soundend); double t1 = *processor->getFloatParameter(cpi_soundend);
sanitizeTimeRange(t0, t1); sanitizeTimeRange(t0, t1);
auto rendertask = [processor,outputfiletouse, renderpars,blocksize,numoutchans, outsr, this]()
{
WavAudioFormat wavformat; WavAudioFormat wavformat;
FileOutputStream* outstream = outputfiletouse.createOutputStream(); FileOutputStream* outstream = outputfiletouse.createOutputStream();
if (outstream == nullptr) if (outstream == nullptr)
return "Could not create output file"; {
jassert(false);
}
int oformattouse{ 16 }; int oformattouse{ 16 };
bool clipoutput{ false }; bool clipoutput{ false };
if (renderpars.outputformat == 1) if (renderpars.outputformat == 1)
@ -561,21 +566,22 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
oformattouse = 32; oformattouse = 32;
clipoutput = true; clipoutput = true;
} }
auto writer = wavformat.createWriterFor(outstream, getSampleRateChecked(), numoutchans, auto writer{ unique_from_raw(wavformat.createWriterFor(outstream, getSampleRateChecked(), numoutchans,
oformattouse, StringPairArray(), 0); oformattouse, StringPairArray(), 0)) };
if (writer == nullptr) if (writer == nullptr)
{ {
delete outstream; delete outstream;
return "Could not create WAV writer"; jassert(false);
} }
auto rendertask = [processor,writer,blocksize,numoutchans, outsr, this]() AudioBuffer<float> renderbuffer{ numoutchans, blocksize };
{
AudioBuffer<float> renderbuffer(numoutchans, blocksize);
MidiBuffer dummymidi; MidiBuffer dummymidi;
int64_t outlen = 10 * outsr; auto sc = processor->getStretchSource();
int64_t outcounter = 0; double outlensecs = sc->getInfileLengthSeconds()*sc->getRate();
int64_t outlen = outlensecs * outsr;
int64_t outcounter{ 0 };
m_offline_render_state = 0; m_offline_render_state = 0;
m_offline_render_cancel_requested = false; m_offline_render_cancel_requested = false;
processor->setNonRealtime(true);
while (outcounter < outlen) while (outcounter < outlen)
{ {
if (m_offline_render_cancel_requested == true) if (m_offline_render_cancel_requested == true)
@ -586,7 +592,7 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
m_offline_render_state = 100.0 / outlen * outcounter; m_offline_render_state = 100.0 / outlen * outcounter;
} }
m_offline_render_state = 200; m_offline_render_state = 200;
delete writer; Logger::writeToLog("Rendered ok!");
}; };
std::thread th(rendertask); std::thread th(rendertask);
th.detach(); th.detach();
@ -797,6 +803,8 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
m_stretch_source->setFreezing(getParameter(cpi_freeze)); m_stretch_source->setFreezing(getParameter(cpi_freeze));
m_stretch_source->setPaused(getParameter(cpi_pause_enabled)); m_stretch_source->setPaused(getParameter(cpi_pause_enabled));
if (m_midinote_control == true)
{
MidiBuffer::Iterator midi_it(midiMessages); MidiBuffer::Iterator midi_it(midiMessages);
MidiMessage midi_msg; MidiMessage midi_msg;
int midi_msg_pos; int midi_msg_pos;
@ -818,6 +826,7 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
} }
} }
}
if (m_midinote_control == true && m_midinote_to_use >= 0) if (m_midinote_control == true && m_midinote_to_use >= 0)
{ {
int note_offset = m_midinote_to_use - 60; int note_offset = m_midinote_to_use - 60;