Stand alone build offline render finally works a bit. Output duration is wrong.
This commit is contained in:
parent
ae8a5e44c8
commit
71c78bf4c3
@ -57,8 +57,8 @@ inline AudioParameterFloat* make_floatpar(String id, String name, float minv, fl
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
|
||||
: m_bufferingthread("pspluginprebufferthread")
|
||||
PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor(bool is_stand_alone_offline)
|
||||
: m_is_stand_alone_offline(is_stand_alone_offline), m_bufferingthread("pspluginprebufferthread")
|
||||
{
|
||||
m_filechoose_callback = [this](const FileChooser& chooser)
|
||||
{
|
||||
@ -88,6 +88,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
|
||||
m_recbuffer.clear();
|
||||
if (m_afm->getNumKnownFormats()==0)
|
||||
m_afm->registerBasicFormats();
|
||||
if (m_is_stand_alone_offline == false)
|
||||
m_thumb = std::make_unique<AudioThumbnail>(512, *m_afm, *m_thumbcache);
|
||||
|
||||
m_sm_enab_pars[0] = new AudioParameterBool("enab_specmodule0", "Enable harmonics", false);
|
||||
@ -214,6 +215,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
|
||||
PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
|
||||
{
|
||||
//Logger::writeToLog("PaulX AudioProcessor destroyed");
|
||||
if (m_thumb)
|
||||
m_thumb->removeAllChangeListeners();
|
||||
m_thumb = nullptr;
|
||||
m_bufferingthread.stopThread(1000);
|
||||
@ -547,8 +549,8 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
|
||||
{
|
||||
File outputfiletouse = renderpars.outputfile.getNonexistentSibling();
|
||||
ValueTree state{ getStateTree(false, false) };
|
||||
auto processor = std::make_shared<PaulstretchpluginAudioProcessor>();
|
||||
|
||||
auto processor = std::make_shared<PaulstretchpluginAudioProcessor>(true);
|
||||
processor->setNonRealtime(true);
|
||||
processor->setStateFromTree(state);
|
||||
double outsr{ renderpars.outsr };
|
||||
if (outsr < 10.0)
|
||||
@ -556,8 +558,8 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
|
||||
Logger::writeToLog(outputfiletouse.getFullPathName() + " " + String(outsr) + " " + String(renderpars.outputformat));
|
||||
int blocksize{ 1024 };
|
||||
int numoutchans = *processor->getIntParameter(cpi_num_outchans);
|
||||
processor->setPlayConfigDetails(0, numoutchans, outsr, blocksize);
|
||||
processor->prepareToPlay(renderpars.outsr, blocksize);
|
||||
processor->setPlayConfigDetails(2, numoutchans, outsr, blocksize);
|
||||
processor->prepareToPlay(outsr, blocksize);
|
||||
|
||||
double t0 = *processor->getFloatParameter(cpi_soundstart);
|
||||
double t1 = *processor->getFloatParameter(cpi_soundend);
|
||||
@ -583,7 +585,7 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
|
||||
oformattouse = 32;
|
||||
clipoutput = true;
|
||||
}
|
||||
auto writer{ unique_from_raw(wavformat.createWriterFor(outstream, getSampleRateChecked(), numoutchans,
|
||||
auto writer{ unique_from_raw(wavformat.createWriterFor(outstream, outsr, numoutchans,
|
||||
oformattouse, StringPairArray(), 0)) };
|
||||
if (writer == nullptr)
|
||||
{
|
||||
@ -593,23 +595,25 @@ String PaulstretchpluginAudioProcessor::offlineRender(OfflineRenderParams render
|
||||
AudioBuffer<float> renderbuffer{ numoutchans, blocksize };
|
||||
MidiBuffer dummymidi;
|
||||
auto sc = processor->getStretchSource();
|
||||
double outlensecs = sc->getInfileLengthSeconds()*sc->getRate();
|
||||
int64_t outlen = outlensecs * outsr;
|
||||
//double outlensecs = sc->getInfileLengthSeconds()*sc->getRate();
|
||||
double outlensecs = sc->getOutputDurationSecondsForRange(sc->getPlayRange(),sc->getFFTSize());
|
||||
int64_t outlenframes = outlensecs * outsr;
|
||||
int64_t outcounter{ 0 };
|
||||
m_offline_render_state = 0;
|
||||
m_offline_render_cancel_requested = false;
|
||||
processor->setNonRealtime(true);
|
||||
while (outcounter < outlen)
|
||||
|
||||
while (outcounter < outlenframes)
|
||||
{
|
||||
if (m_offline_render_cancel_requested == true)
|
||||
break;
|
||||
processor->processBlock(renderbuffer, dummymidi);
|
||||
writer->writeFromAudioSampleBuffer(renderbuffer, 0, blocksize);
|
||||
outcounter += blocksize;
|
||||
m_offline_render_state = 100.0 / outlen * outcounter;
|
||||
m_offline_render_state = 100.0 / outlenframes * outcounter;
|
||||
}
|
||||
m_offline_render_state = 200;
|
||||
Logger::writeToLog("Rendered ok!");
|
||||
|
||||
};
|
||||
std::thread th(rendertask);
|
||||
th.detach();
|
||||
@ -664,8 +668,7 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
|
||||
|
||||
void PaulstretchpluginAudioProcessor::releaseResources()
|
||||
{
|
||||
//m_control->stopplay();
|
||||
//m_ready_to_play = false;
|
||||
|
||||
}
|
||||
|
||||
#ifndef JucePlugin_PreferredChannelConfigurations
|
||||
@ -976,6 +979,7 @@ String PaulstretchpluginAudioProcessor::setAudioFile(File f)
|
||||
{
|
||||
return "Too high bit depth in file " + f.getFullPathName();
|
||||
}
|
||||
if (m_thumb)
|
||||
m_thumb->setSource(new FileInputSource(f));
|
||||
ScopedLock locker(m_cs);
|
||||
m_stretch_source->setAudioFile(f);
|
||||
|
@ -138,7 +138,7 @@ class PaulstretchpluginAudioProcessor : public AudioProcessor,
|
||||
{
|
||||
public:
|
||||
using EditorType = PaulstretchpluginAudioProcessorEditor;
|
||||
PaulstretchpluginAudioProcessor();
|
||||
PaulstretchpluginAudioProcessor(bool is_stand_alone_offline=false);
|
||||
~PaulstretchpluginAudioProcessor();
|
||||
|
||||
//==============================================================================
|
||||
@ -290,7 +290,7 @@ private:
|
||||
SharedResourcePointer<MyThreadPool> m_threadpool;
|
||||
int m_midinote_to_use = -1;
|
||||
ADSR m_adsr;
|
||||
|
||||
bool m_is_stand_alone_offline = false;
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user