Save and restore plugin state. Port input file skipbuffer bug fix from standalone app.
This commit is contained in:
parent
f4c8d2891b
commit
4620ba818e
@ -28,7 +28,7 @@ public:
|
||||
InputS()
|
||||
{
|
||||
skipbufsize=1024;
|
||||
skipbuf.setSize(4, skipbufsize);
|
||||
skipbuf.setSize(1, skipbufsize);
|
||||
};
|
||||
|
||||
virtual ~InputS()
|
||||
@ -45,8 +45,8 @@ public:
|
||||
{
|
||||
int readsize=(nsmps<skipbufsize)?nsmps:skipbufsize;
|
||||
if (skipbuf.getNumSamples() < readsize)
|
||||
skipbuf.setSize(info.nchannels, readsize);
|
||||
readNextBlock(skipbuf,readsize,info.nchannels);
|
||||
skipbuf.setSize(1, readsize);
|
||||
readNextBlock(skipbuf,readsize,1);
|
||||
nsmps-=readsize;
|
||||
};
|
||||
};
|
||||
@ -79,11 +79,13 @@ public:
|
||||
{
|
||||
return m_currentsample >= info.nsamples*m_activerange.getEnd();
|
||||
}
|
||||
|
||||
protected:
|
||||
int64_t m_currentsample = 0;
|
||||
int m_silenceoutputted = 0;
|
||||
bool m_loop_enabled = false;
|
||||
Range<double> m_activerange{ 0.0,1.0 };
|
||||
|
||||
private:
|
||||
int skipbufsize;
|
||||
AudioBuffer<float> skipbuf;
|
||||
|
@ -127,7 +127,7 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
|
||||
}
|
||||
if (m_ready_to_play == false)
|
||||
{
|
||||
m_control->setFFTSize(0.2);
|
||||
m_control->setFFTSize(0.7);
|
||||
m_control->update_player_stretch();
|
||||
m_control->update_process_parameters();
|
||||
|
||||
@ -242,15 +242,47 @@ AudioProcessorEditor* PaulstretchpluginAudioProcessor::createEditor()
|
||||
//==============================================================================
|
||||
void PaulstretchpluginAudioProcessor::getStateInformation (MemoryBlock& destData)
|
||||
{
|
||||
// You should use this method to store your parameters in the memory block.
|
||||
// You could do that either as raw data, or use the XML or ValueTree classes
|
||||
// as intermediaries to make it easy to save and load complex data.
|
||||
ValueTree paramtree("paulstretch3pluginstate");
|
||||
for (int i=0;i<getNumParameters();++i)
|
||||
{
|
||||
auto par = getFloatParameter(i);
|
||||
paramtree.setProperty(par->paramID, (double)*par, nullptr);
|
||||
}
|
||||
if (m_current_file != File())
|
||||
{
|
||||
paramtree.setProperty("importedfile", m_current_file.getFullPathName(), nullptr);
|
||||
}
|
||||
MemoryOutputStream stream(destData,true);
|
||||
paramtree.writeToStream(stream);
|
||||
}
|
||||
|
||||
void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int sizeInBytes)
|
||||
{
|
||||
// You should use this method to restore your parameters from this memory block,
|
||||
// whose contents will have been created by the getStateInformation() call.
|
||||
ValueTree tree = ValueTree::readFromData(data, sizeInBytes);
|
||||
if (tree.isValid())
|
||||
{
|
||||
for (int i = 0; i<getNumParameters(); ++i)
|
||||
{
|
||||
auto par = getFloatParameter(i);
|
||||
double parval = tree.getProperty(par->paramID, (double)*par);
|
||||
*par = parval;
|
||||
}
|
||||
String fn = tree.getProperty("importedfile");
|
||||
if (fn.isEmpty() == false)
|
||||
{
|
||||
m_using_memory_buffer = false;
|
||||
File f(fn);
|
||||
setAudioFile(f);
|
||||
Timer::callAfterDelay(500, [this,f]()
|
||||
{
|
||||
callGUI([f](PaulstretchpluginAudioProcessorEditor* ed)
|
||||
{
|
||||
ed->setAudioFile(f);
|
||||
}, false);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b)
|
||||
@ -259,6 +291,8 @@ void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b)
|
||||
int lenbufframes = getSampleRate()*m_max_reclen;
|
||||
if (b == true)
|
||||
{
|
||||
m_using_memory_buffer = true;
|
||||
m_current_file = File();
|
||||
m_recbuffer.setSize(2, m_max_reclen*getSampleRate()+4096);
|
||||
m_recbuffer.clear();
|
||||
m_rec_pos = 0;
|
||||
@ -292,6 +326,7 @@ String PaulstretchpluginAudioProcessor::setAudioFile(File f)
|
||||
|
||||
});
|
||||
m_current_file = f;
|
||||
m_using_memory_buffer = false;
|
||||
return String();
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ private:
|
||||
bool m_is_recording = false;
|
||||
int m_rec_pos = 0;
|
||||
void finishRecording(int lenrecorded);
|
||||
bool m_using_memory_buffer = true;
|
||||
bool m_using_memory_buffer = false;
|
||||
int m_cur_num_out_chans = 2;
|
||||
std::mutex m_mutex;
|
||||
File m_current_file;
|
||||
|
Loading…
Reference in New Issue
Block a user