Avoid setting the audio buffer more than once

This commit is contained in:
xenakios 2017-12-13 05:23:57 +02:00
parent e411a99f70
commit 3dc95b6f1d
2 changed files with 6 additions and 2 deletions

View File

@ -111,7 +111,7 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
{ {
m_wavecomponent.setAudioFile(processor.getAudioFile()); m_wavecomponent.setAudioFile(processor.getAudioFile());
} }
if (processor.getAudioFile()==File() && processor.isRecordingEnabled()==false) if (processor.getAudioFile()==File() && processor.isRecordingEnabled()==false && m_wavecomponent.isUsingAudioBuffer()==false)
{ {
auto bufptr = processor.getStretchSource()->getSourceAudioBuffer(); auto bufptr = processor.getStretchSource()->getSourceAudioBuffer();
if (bufptr!=nullptr) if (bufptr!=nullptr)
@ -293,6 +293,7 @@ void WaveformComponent::setAudioFile(File f)
m_thumb->reset(0, 0.0); m_thumb->reset(0, 0.0);
m_thumb->setSource(new FileInputSource(f)); m_thumb->setSource(new FileInputSource(f));
m_curfile = f; m_curfile = f;
m_using_audio_buffer = false;
} }
else else
{ {
@ -305,6 +306,7 @@ void WaveformComponent::setAudioFile(File f)
void WaveformComponent::setAudioBuffer(AudioBuffer<float>* buf, int samplerate, int len) void WaveformComponent::setAudioBuffer(AudioBuffer<float>* buf, int samplerate, int len)
{ {
jassert(buf!=nullptr); jassert(buf!=nullptr);
m_using_audio_buffer = true;
m_waveimage = Image(); m_waveimage = Image();
m_curfile = File(); m_curfile = File();
m_thumb->reset(buf->getNumChannels(), samplerate, len); m_thumb->reset(buf->getNumChannels(), samplerate, len);

View File

@ -182,6 +182,7 @@ public:
void paint(Graphics& g) override; void paint(Graphics& g) override;
void setAudioFile(File f); void setAudioFile(File f);
const File& getAudioFile() const { return m_curfile; } const File& getAudioFile() const { return m_curfile; }
bool isUsingAudioBuffer() const { return m_using_audio_buffer; }
void setAudioBuffer(AudioBuffer<float>* buf, int samplerate, int len); void setAudioBuffer(AudioBuffer<float>* buf, int samplerate, int len);
void beginAddingAudioBlocks(int channels, int samplerate, int totalllen); void beginAddingAudioBlocks(int channels, int samplerate, int totalllen);
void addAudioBlock(AudioBuffer<float>& buf, int samplerate, int pos); void addAudioBlock(AudioBuffer<float>& buf, int samplerate, int pos);
@ -235,6 +236,7 @@ private:
bool m_use_opengl = false; bool m_use_opengl = false;
double m_rec_pos = 0.0; double m_rec_pos = 0.0;
bool m_lock_timesel_set = false; bool m_lock_timesel_set = false;
bool m_using_audio_buffer = false;
}; };
class MyDynamicObject : public DynamicObject class MyDynamicObject : public DynamicObject