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