Add option for loading imported file with plugin's state. Use a small loop xfade amount as default.

This commit is contained in:
xenakios 2017-12-26 20:24:10 +02:00
parent 29e46bd008
commit 21b06b8353
3 changed files with 17 additions and 6 deletions

View File

@ -280,6 +280,7 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
{ {
PopupMenu menu; PopupMenu menu;
menu.addItem(4, "Reset parameters", true, false); menu.addItem(4, "Reset parameters", true, false);
menu.addItem(5, "Load file with plugin state", true, processor.m_load_file_with_state);
menu.addItem(1, "Play when host transport running", true, processor.m_play_when_host_plays); menu.addItem(1, "Play when host transport running", true, processor.m_play_when_host_plays);
menu.addItem(2, "Capture when host transport running", true, processor.m_capture_when_host_plays); menu.addItem(2, "Capture when host transport running", true, processor.m_capture_when_host_plays);
@ -307,6 +308,10 @@ void PaulstretchpluginAudioProcessorEditor::showSettingsMenu()
{ {
processor.resetParameters(); processor.resetParameters();
} }
if (r == 5)
{
processor.m_load_file_with_state = !processor.m_load_file_with_state;
}
if (r == 3) if (r == 3)
{ {
String fftlib = fftwf_version; String fftlib = fftwf_version;

View File

@ -111,7 +111,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
addParameter(new AudioParameterBool("freeze0", "Freeze", false)); // 7 addParameter(new AudioParameterBool("freeze0", "Freeze", false)); // 7
addParameter(new AudioParameterFloat("spread0", "Frequency spread", 0.0f, 1.0f, 0.0f)); // 8 addParameter(new AudioParameterFloat("spread0", "Frequency spread", 0.0f, 1.0f, 0.0f)); // 8
addParameter(new AudioParameterFloat("compress0", "Compress", 0.0f, 1.0f, 0.0f)); // 9 addParameter(new AudioParameterFloat("compress0", "Compress", 0.0f, 1.0f, 0.0f)); // 9
addParameter(new AudioParameterFloat("loopxfadelen0", "Loop xfade length", 0.0f, 1.0f, 0.0f)); // 10 addParameter(new AudioParameterFloat("loopxfadelen0", "Loop xfade length", 0.0f, 1.0f, 0.01f)); // 10
auto numhar_convertFrom0To1Func = [](float rangemin, float rangemax, float value) auto numhar_convertFrom0To1Func = [](float rangemin, float rangemax, float value)
{ {
return jmap<float>(value, 0.0f, 1.0f, 101.0f, 1.0f); return jmap<float>(value, 0.0f, 1.0f, 101.0f, 1.0f);
@ -544,6 +544,7 @@ void PaulstretchpluginAudioProcessor::getStateInformation (MemoryBlock& destData
paramtree.setProperty("prebufamount", m_prebuffer_amount, nullptr); paramtree.setProperty("prebufamount", m_prebuffer_amount, nullptr);
else else
paramtree.setProperty("prebufamount", -1, nullptr); paramtree.setProperty("prebufamount", -1, nullptr);
paramtree.setProperty("loadfilewithstate", m_load_file_with_state, nullptr);
MemoryOutputStream stream(destData,true); MemoryOutputStream stream(destData,true);
paramtree.writeToStream(stream); paramtree.writeToStream(stream);
} }
@ -555,6 +556,7 @@ void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int
{ {
{ {
ScopedLock locker(m_cs); ScopedLock locker(m_cs);
m_load_file_with_state = tree.getProperty("loadfilewithstate", true);
if (tree.hasProperty("numspectralstages")) if (tree.hasProperty("numspectralstages"))
{ {
std::vector<int> order; std::vector<int> order;
@ -583,6 +585,8 @@ void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int
m_use_backgroundbuffering = false; m_use_backgroundbuffering = false;
else else
setPreBufferAmount(prebufamt); setPreBufferAmount(prebufamt);
if (m_load_file_with_state == true)
{
String fn = tree.getProperty("importedfile"); String fn = tree.getProperty("importedfile");
if (fn.isEmpty() == false) if (fn.isEmpty() == false)
{ {
@ -590,6 +594,7 @@ void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int
setAudioFile(f); setAudioFile(f);
} }
} }
}
} }
void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b) void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b)

View File

@ -144,6 +144,7 @@ public:
void resetParameters(); void resetParameters();
void setPreBufferAmount(int x); void setPreBufferAmount(int x);
int getPreBufferAmount(); int getPreBufferAmount();
bool m_load_file_with_state = true;
private: private: