From 45dccb830d65e796e324d6184d813445f95cd1fe Mon Sep 17 00:00:00 2001 From: xenakios Date: Fri, 15 Dec 2017 06:17:11 +0200 Subject: [PATCH] Workaround a bug in Juce/MacOS file dialog stuff. Show error messages in GUI. --- Source/PluginEditor.cpp | 13 ++++++++++--- Source/PluginEditor.h | 2 +- Source/PluginProcessor.cpp | 7 ++++++- Source/PluginProcessor.h | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index c00a5f0..4e82e54 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -103,7 +103,7 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id) m_wavecomponent.setRecordingPosition(processor.getRecordingPositionPercent()); } else m_wavecomponent.setRecordingPosition(-1.0); - String infotext = String(processor.getPreBufferingPercent(), 1) + " " + String(processor.getStretchSource()->m_param_change_count); + String infotext = String(processor.getPreBufferingPercent(), 1) + " " + String(processor.getStretchSource()->m_param_change_count)+" "+m_last_err; m_info_label.setText(infotext, dontSendNotification); } if (id == 2) @@ -161,10 +161,17 @@ void PaulstretchpluginAudioProcessorEditor::chooseFile() #endif FileChooser myChooser("Please select audio file...", initialloc, - "*.wav"); + "*.wav",true); if (myChooser.browseForFileToOpen()) { - processor.setAudioFile(myChooser.getResult()); + File resu = myChooser.getResult(); + String pathname = resu.getFullPathName(); + if (pathname.startsWith("/localhost")) + { + pathname = pathname.substring(10); + resu = File(pathname); + } + m_last_err = processor.setAudioFile(resu); if (processor.getAudioFile() != File()) { m_wavecomponent.setAudioFile(processor.getAudioFile()); diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index e889dda..bc8b0fe 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -330,7 +330,7 @@ private: Label m_info_label; SpectralChainEditor m_spec_order_ed; void chooseFile(); - + String m_last_err; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor) }; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 9d631d9..7698407 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -478,7 +478,11 @@ double PaulstretchpluginAudioProcessor::getRecordingPositionPercent() String PaulstretchpluginAudioProcessor::setAudioFile(File f) { - auto ai = unique_from_raw(m_afm->createReaderFor(f)); + //if (f==File()) + // return String(); + //if (f==m_current_file && f.getLastModificationTime()==m_current_file_date) + // return String(); + auto ai = unique_from_raw(m_afm->createReaderFor(f)); if (ai != nullptr) { if (ai->numChannels > 32) @@ -494,6 +498,7 @@ String PaulstretchpluginAudioProcessor::setAudioFile(File f) ScopedLock locker(m_cs); m_stretch_source->setAudioFile(f); m_current_file = f; + m_current_file_date = m_current_file.getLastModificationTime(); m_using_memory_buffer = false; return String(); //MessageManager::callAsync([cb, file]() { cb(String()); }); diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 42ab56f..92aa66c 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -111,7 +111,7 @@ private: int m_cur_num_out_chans = 2; CriticalSection m_cs; File m_current_file; - + Time m_current_file_date; TimeSliceThread m_bufferingthread; std::unique_ptr m_stretch_source;