Browse Source

Save and restore plugin state. Port input file skipbuffer bug fix from standalone app.

tags/v100_p5
xenakios 7 years ago
parent
commit
4620ba818e
3 changed files with 47 additions and 10 deletions
  1. +5
    -3
      Source/PS_Source/Input/InputS.h
  2. +41
    -6
      Source/PluginProcessor.cpp
  3. +1
    -1
      Source/PluginProcessor.h

+ 5
- 3
Source/PS_Source/Input/InputS.h View File

@@ -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;


+ 41
- 6
Source/PluginProcessor.cpp View File

@@ -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();
}



+ 1
- 1
Source/PluginProcessor.h View File

@@ -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…
Cancel
Save