Add method to get sanitized samplerate as getSampleRate might return 0.0 when called from outside audio processing method. Comment out Spectral visualizer instance in editor.
This commit is contained in:
parent
9e7b37afba
commit
7ea18cc805
@ -117,7 +117,7 @@ void PaulstretchpluginAudioProcessorEditor::timerCallback(int id)
|
|||||||
auto bufptr = processor.getStretchSource()->getSourceAudioBuffer();
|
auto bufptr = processor.getStretchSource()->getSourceAudioBuffer();
|
||||||
if (bufptr!=nullptr)
|
if (bufptr!=nullptr)
|
||||||
m_wavecomponent.setAudioBuffer(bufptr,
|
m_wavecomponent.setAudioBuffer(bufptr,
|
||||||
processor.getSampleRate(), bufptr->getNumSamples());
|
processor.getSampleRateChecked(), bufptr->getNumSamples());
|
||||||
}
|
}
|
||||||
m_wavecomponent.setTimeSelection(processor.getTimeSelection());
|
m_wavecomponent.setTimeSelection(processor.getTimeSelection());
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
PaulstretchpluginAudioProcessor& processor;
|
PaulstretchpluginAudioProcessor& processor;
|
||||||
std::vector<std::shared_ptr<ParameterComponent>> m_parcomps;
|
std::vector<std::shared_ptr<ParameterComponent>> m_parcomps;
|
||||||
SpectralVisualizer m_specvis;
|
//SpectralVisualizer m_specvis;
|
||||||
|
|
||||||
TextButton m_import_button;
|
TextButton m_import_button;
|
||||||
Label m_info_label;
|
Label m_info_label;
|
||||||
|
@ -189,7 +189,8 @@ bool PaulstretchpluginAudioProcessor::isMidiEffect() const
|
|||||||
|
|
||||||
double PaulstretchpluginAudioProcessor::getTailLengthSeconds() const
|
double PaulstretchpluginAudioProcessor::getTailLengthSeconds() const
|
||||||
{
|
{
|
||||||
return (double)m_bufamounts[m_prebuffer_amount]/getSampleRate();
|
return 0.0;
|
||||||
|
//return (double)m_bufamounts[m_prebuffer_amount]/getSampleRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PaulstretchpluginAudioProcessor::getNumPrograms()
|
int PaulstretchpluginAudioProcessor::getNumPrograms()
|
||||||
@ -248,12 +249,19 @@ void PaulstretchpluginAudioProcessor::startplay(Range<double> playrange, int num
|
|||||||
m_stretch_source->setProcessParameters(&m_ppar);
|
m_stretch_source->setProcessParameters(&m_ppar);
|
||||||
m_last_outpos_pos = 0.0;
|
m_last_outpos_pos = 0.0;
|
||||||
m_last_in_pos = playrange.getStart()*m_stretch_source->getInfileLengthSeconds();
|
m_last_in_pos = playrange.getStart()*m_stretch_source->getInfileLengthSeconds();
|
||||||
m_buffering_source->prepareToPlay(maxBlockSize, getSampleRate());
|
m_buffering_source->prepareToPlay(maxBlockSize, getSampleRateChecked());
|
||||||
};
|
}
|
||||||
|
double PaulstretchpluginAudioProcessor::getSampleRateChecked()
|
||||||
|
{
|
||||||
|
if (m_cur_sr < 1.0)
|
||||||
|
return 44100.0;
|
||||||
|
return m_cur_sr;
|
||||||
|
}
|
||||||
|
|
||||||
void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int samplesPerBlock)
|
||||||
{
|
{
|
||||||
ScopedLock locker(m_cs);
|
ScopedLock locker(m_cs);
|
||||||
|
m_cur_sr = sampleRate;
|
||||||
m_curmaxblocksize = samplesPerBlock;
|
m_curmaxblocksize = samplesPerBlock;
|
||||||
int numoutchans = *m_outchansparam;
|
int numoutchans = *m_outchansparam;
|
||||||
if (numoutchans != m_cur_num_out_chans)
|
if (numoutchans != m_cur_num_out_chans)
|
||||||
@ -262,9 +270,9 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
|
|||||||
{
|
{
|
||||||
int len = jlimit(100,m_recbuffer.getNumSamples(), m_rec_pos);
|
int len = jlimit(100,m_recbuffer.getNumSamples(), m_rec_pos);
|
||||||
m_stretch_source->setAudioBufferAsInputSource(&m_recbuffer,
|
m_stretch_source->setAudioBufferAsInputSource(&m_recbuffer,
|
||||||
getSampleRate(),
|
getSampleRateChecked(),
|
||||||
len);
|
len);
|
||||||
callGUI(this,[this,len](auto ed) { ed->setAudioBuffer(&m_recbuffer, getSampleRate(), len); },false);
|
callGUI(this,[this,len](auto ed) { ed->setAudioBuffer(&m_recbuffer, getSampleRateChecked(), len); },false);
|
||||||
}
|
}
|
||||||
if (m_ready_to_play == false)
|
if (m_ready_to_play == false)
|
||||||
{
|
{
|
||||||
@ -332,6 +340,9 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
|
|||||||
{
|
{
|
||||||
ScopedLock locker(m_cs);
|
ScopedLock locker(m_cs);
|
||||||
ScopedNoDenormals noDenormals;
|
ScopedNoDenormals noDenormals;
|
||||||
|
double srtemp = getSampleRate();
|
||||||
|
if (srtemp != m_cur_sr)
|
||||||
|
m_cur_sr = srtemp;
|
||||||
const int totalNumInputChannels = getTotalNumInputChannels();
|
const int totalNumInputChannels = getTotalNumInputChannels();
|
||||||
const int totalNumOutputChannels = getTotalNumOutputChannels();
|
const int totalNumOutputChannels = getTotalNumOutputChannels();
|
||||||
|
|
||||||
@ -476,17 +487,17 @@ void PaulstretchpluginAudioProcessor::setStateInformation (const void* data, int
|
|||||||
void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b)
|
void PaulstretchpluginAudioProcessor::setRecordingEnabled(bool b)
|
||||||
{
|
{
|
||||||
ScopedLock locker(m_cs);
|
ScopedLock locker(m_cs);
|
||||||
int lenbufframes = getSampleRate()*m_max_reclen;
|
int lenbufframes = getSampleRateChecked()*m_max_reclen;
|
||||||
if (b == true)
|
if (b == true)
|
||||||
{
|
{
|
||||||
m_using_memory_buffer = true;
|
m_using_memory_buffer = true;
|
||||||
m_current_file = File();
|
m_current_file = File();
|
||||||
m_recbuffer.setSize(2, m_max_reclen*getSampleRate()+4096,false,false,true);
|
m_recbuffer.setSize(2, m_max_reclen*getSampleRateChecked()+4096,false,false,true);
|
||||||
m_recbuffer.clear();
|
m_recbuffer.clear();
|
||||||
m_rec_pos = 0;
|
m_rec_pos = 0;
|
||||||
callGUI(this,[this,lenbufframes](PaulstretchpluginAudioProcessorEditor* ed)
|
callGUI(this,[this,lenbufframes](PaulstretchpluginAudioProcessorEditor* ed)
|
||||||
{
|
{
|
||||||
ed->beginAddingAudioBlocks(2, getSampleRate(), lenbufframes);
|
ed->beginAddingAudioBlocks(2, getSampleRateChecked(), lenbufframes);
|
||||||
},false);
|
},false);
|
||||||
m_is_recording = true;
|
m_is_recording = true;
|
||||||
}
|
}
|
||||||
@ -583,7 +594,7 @@ void PaulstretchpluginAudioProcessor::timerCallback(int id)
|
|||||||
void PaulstretchpluginAudioProcessor::finishRecording(int lenrecording)
|
void PaulstretchpluginAudioProcessor::finishRecording(int lenrecording)
|
||||||
{
|
{
|
||||||
m_is_recording = false;
|
m_is_recording = false;
|
||||||
m_stretch_source->setAudioBufferAsInputSource(&m_recbuffer, getSampleRate(), lenrecording);
|
m_stretch_source->setAudioBufferAsInputSource(&m_recbuffer, getSampleRateChecked(), lenrecording);
|
||||||
m_stretch_source->setPlayRange({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) }, true);
|
m_stretch_source->setPlayRange({ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) }, true);
|
||||||
auto ed = dynamic_cast<PaulstretchpluginAudioProcessorEditor*>(getActiveEditor());
|
auto ed = dynamic_cast<PaulstretchpluginAudioProcessorEditor*>(getActiveEditor());
|
||||||
if (ed)
|
if (ed)
|
||||||
|
@ -98,6 +98,7 @@ public:
|
|||||||
StretchAudioSource* getStretchSource() { return m_stretch_source.get(); }
|
StretchAudioSource* getStretchSource() { return m_stretch_source.get(); }
|
||||||
double getPreBufferingPercent();
|
double getPreBufferingPercent();
|
||||||
void timerCallback(int id) override;
|
void timerCallback(int id) override;
|
||||||
|
double getSampleRateChecked();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
@ -130,6 +131,8 @@ private:
|
|||||||
SharedResourcePointer<MyThumbCache> m_thumbcache;
|
SharedResourcePointer<MyThumbCache> m_thumbcache;
|
||||||
AudioParameterInt* m_outchansparam = nullptr;
|
AudioParameterInt* m_outchansparam = nullptr;
|
||||||
int m_curmaxblocksize = 0;
|
int m_curmaxblocksize = 0;
|
||||||
|
double m_cur_sr = 0.0;
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user