Made rewind a parameter. Attempts to fix the time range not being recalled properly in hosts because the time range parameters may be quickly changed when the plugin is initializing and doing the sound source smoothing fades. etc
This commit is contained in:
@ -330,6 +330,7 @@ public:
|
||||
void setActiveRange(Range<double> rng) override
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(m_mutex);
|
||||
|
||||
/*
|
||||
if (rng.contains(getCurrentPositionPercent()))
|
||||
{
|
||||
@ -338,7 +339,7 @@ public:
|
||||
}
|
||||
*/
|
||||
m_seekfade.requestedrange = rng;
|
||||
if (m_seekfade.state == 0)
|
||||
//if (m_seekfade.state == 0)
|
||||
{
|
||||
m_seekfade.counter = 0;
|
||||
m_seekfade.state = 1;
|
||||
|
@ -156,7 +156,7 @@ void StretchAudioSource::setAudioBufferAsInputSource(AudioBuffer<float>* buf, in
|
||||
|
||||
m_curfile = File();
|
||||
if (m_playrange.isEmpty())
|
||||
setPlayRange({ 0.0,1.0 }, true);
|
||||
setPlayRange({ 0.0,1.0 });
|
||||
++m_param_change_count;
|
||||
}
|
||||
|
||||
@ -684,6 +684,7 @@ void StretchAudioSource::seekPercent(double pos)
|
||||
{
|
||||
ScopedLock locker(m_cs);
|
||||
m_seekpos = pos;
|
||||
//m_firstbuffer = true;
|
||||
//m_resampler->Reset();
|
||||
m_inputfile->seek(pos);
|
||||
++m_param_change_count;
|
||||
@ -715,7 +716,7 @@ void StretchAudioSource::setOnsetDetection(double x)
|
||||
}
|
||||
}
|
||||
|
||||
void StretchAudioSource::setPlayRange(Range<double> playrange, bool isloop)
|
||||
void StretchAudioSource::setPlayRange(Range<double> playrange)
|
||||
{
|
||||
if (m_playrange.isEmpty() == false && playrange == m_playrange)
|
||||
return;
|
||||
@ -727,7 +728,7 @@ void StretchAudioSource::setPlayRange(Range<double> playrange, bool isloop)
|
||||
m_playrange = playrange;
|
||||
m_stream_end_reached = false;
|
||||
m_inputfile->setActiveRange(m_playrange);
|
||||
m_inputfile->setLoopEnabled(isloop);
|
||||
|
||||
//if (m_playrange.contains(m_seekpos) == false)
|
||||
// m_inputfile->seek(m_playrange.getStart());
|
||||
m_seekpos = m_playrange.getStart();
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
double getOutputDurationSecondsForRange(Range<double> range, int fftsize);
|
||||
|
||||
void setOnsetDetection(double x);
|
||||
void setPlayRange(Range<double> playrange, bool isloop);
|
||||
void setPlayRange(Range<double> playrange);
|
||||
Range<double> getPlayRange() { return m_playrange; }
|
||||
bool isLoopEnabled();
|
||||
bool hasReachedEnd();
|
||||
|
@ -67,7 +67,8 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau
|
||||
m_rewind_button.setButtonText("<<");
|
||||
m_rewind_button.onClick = [this]()
|
||||
{
|
||||
processor.getStretchSource()->seekPercent(processor.getStretchSource()->getPlayRange().getStart());
|
||||
*processor.getBoolParameter(cpi_rewind) = true;
|
||||
//processor.getStretchSource()->seekPercent(processor.getStretchSource()->getPlayRange().getStart());
|
||||
};
|
||||
|
||||
addAndMakeVisible(&m_info_label);
|
||||
|
@ -175,6 +175,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
|
||||
}
|
||||
|
||||
addParameter(new AudioParameterBool("loop_enabled0", "Loop", true)); // 60
|
||||
addParameter(new AudioParameterBool("rewind0", "Rewind", false)); // 61
|
||||
|
||||
auto& pars = getParameters();
|
||||
for (const auto& p : pars)
|
||||
@ -392,7 +393,7 @@ void PaulstretchpluginAudioProcessor::setFFTSize(double size)
|
||||
|
||||
void PaulstretchpluginAudioProcessor::startplay(Range<double> playrange, int numoutchans, int maxBlockSize, String& err)
|
||||
{
|
||||
m_stretch_source->setPlayRange(playrange, true);
|
||||
m_stretch_source->setPlayRange(playrange);
|
||||
m_stretch_source->setFreeFilterEnvelope(m_free_filter_envelope);
|
||||
int bufamt = m_bufamounts[m_prebuffer_amount];
|
||||
|
||||
@ -479,7 +480,7 @@ String PaulstretchpluginAudioProcessor::offlineRender(File outputfile)
|
||||
double t1 = *getFloatParameter(cpi_soundend);
|
||||
sanitizeTimeRange(t0, t1);
|
||||
ss->setRate(*getFloatParameter(cpi_stretchamount));
|
||||
ss->setPlayRange({ t0,t1 }, true);
|
||||
ss->setPlayRange({ t0,t1 });
|
||||
ss->setLoopingEnabled(true);
|
||||
ss->setNumOutChannels(numoutchans);
|
||||
ss->setFFTWindowingType(1);
|
||||
@ -542,6 +543,7 @@ void PaulstretchpluginAudioProcessor::prepareToPlay(double sampleRate, int sampl
|
||||
m_cur_sr = sampleRate;
|
||||
m_curmaxblocksize = samplesPerBlock;
|
||||
m_input_buffer.setSize(getMainBusNumInputChannels(), samplesPerBlock);
|
||||
*getBoolParameter(cpi_rewind) = false;
|
||||
int numoutchans = *m_outchansparam;
|
||||
if (numoutchans != m_cur_num_out_chans)
|
||||
m_prebuffering_inited = false;
|
||||
@ -663,6 +665,10 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
|
||||
}
|
||||
jassert(m_buffering_source != nullptr);
|
||||
jassert(m_bufferingthread.isThreadRunning());
|
||||
double t0 = *getFloatParameter(cpi_soundstart);
|
||||
double t1 = *getFloatParameter(cpi_soundend);
|
||||
sanitizeTimeRange(t0, t1);
|
||||
m_stretch_source->setPlayRange({ t0,t1 });
|
||||
if (m_last_host_playing == false && m_playposinfo.isPlaying)
|
||||
{
|
||||
m_stretch_source->seekPercent(*getFloatParameter(cpi_soundstart));
|
||||
@ -686,6 +692,16 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
|
||||
|
||||
if (m_stretch_source->isLoopEnabled() != *getBoolParameter(cpi_looping_enabled))
|
||||
m_stretch_source->setLoopingEnabled(*getBoolParameter(cpi_looping_enabled));
|
||||
bool rew = *getBoolParameter(cpi_rewind);
|
||||
if (rew !=m_lastrewind)
|
||||
{
|
||||
if (rew == true)
|
||||
{
|
||||
*getBoolParameter(cpi_rewind) = false;
|
||||
m_stretch_source->seekPercent(m_stretch_source->getPlayRange().getStart());
|
||||
}
|
||||
m_lastrewind = rew;
|
||||
}
|
||||
|
||||
m_stretch_source->setMainVolume(*getFloatParameter(cpi_main_volume));
|
||||
m_stretch_source->setRate(*getFloatParameter(cpi_stretchamount));
|
||||
@ -696,11 +712,9 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
|
||||
|
||||
m_stretch_source->setOnsetDetection(*getFloatParameter(cpi_onsetdetection));
|
||||
m_stretch_source->setLoopXFadeLength(*getFloatParameter(cpi_loopxfadelen));
|
||||
double t0 = *getFloatParameter(cpi_soundstart);
|
||||
double t1 = *getFloatParameter(cpi_soundend);
|
||||
sanitizeTimeRange(t0, t1);
|
||||
|
||||
m_stretch_source->setPlayRange({ t0,t1 }, true);
|
||||
|
||||
|
||||
|
||||
m_stretch_source->setFreezing(getParameter(cpi_freeze));
|
||||
m_stretch_source->setPaused(getParameter(cpi_pause_enabled));
|
||||
m_stretch_source->setProcessParameters(&m_ppar);
|
||||
@ -902,7 +916,7 @@ void PaulstretchpluginAudioProcessor::finishRecording(int lenrecording)
|
||||
{
|
||||
m_is_recording = false;
|
||||
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) });
|
||||
}
|
||||
|
||||
AudioProcessor* JUCE_CALLTYPE createPluginFilter()
|
||||
|
@ -88,6 +88,7 @@ const int cpi_octaves_ratio5 = 57;
|
||||
const int cpi_octaves_ratio6 = 58;
|
||||
const int cpi_octaves_ratio7 = 59;
|
||||
const int cpi_looping_enabled = 60;
|
||||
const int cpi_rewind = 61;
|
||||
|
||||
class MyPropertiesFile
|
||||
{
|
||||
@ -258,6 +259,7 @@ private:
|
||||
float m_cur_playrangeoffset = 0.0;
|
||||
void updateStretchParametersFromPluginParameters(ProcessParameters& pars);
|
||||
std::array<AudioParameterBool*, 9> m_sm_enab_pars;
|
||||
bool m_lastrewind = false;
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessor)
|
||||
};
|
||||
|
Reference in New Issue
Block a user