Support resampled playrate changes for non stretched playback
This commit is contained in:
		@@ -269,6 +269,23 @@ bool StretchAudioSource::isPreviewingDry() const
 | 
				
			|||||||
	return m_preview_dry;
 | 
						return m_preview_dry;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void StretchAudioSource::setDryPlayrate(double rate)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (rate == m_dryplayrate)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						if (m_cs.tryEnter())
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							m_dryplayrate = rate;
 | 
				
			||||||
 | 
							++m_param_change_count;
 | 
				
			||||||
 | 
							m_cs.exit();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					double StretchAudioSource::getDryPlayrate() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return m_dryplayrate;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & bufferToFill)
 | 
					void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & bufferToFill)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ScopedLock locker(m_cs);
 | 
						ScopedLock locker(m_cs);
 | 
				
			||||||
@@ -568,7 +585,7 @@ void StretchAudioSource::playDrySound(const AudioSourceChannelInfo & bufferToFil
 | 
				
			|||||||
	double maingain = Decibels::decibelsToGain(m_main_volume);
 | 
						double maingain = Decibels::decibelsToGain(m_main_volume);
 | 
				
			||||||
	m_inputfile->setXFadeLenSeconds(m_loopxfadelen);
 | 
						m_inputfile->setXFadeLenSeconds(m_loopxfadelen);
 | 
				
			||||||
	double* rsinbuf = nullptr;
 | 
						double* rsinbuf = nullptr;
 | 
				
			||||||
	m_resampler->SetRates(m_inputfile->info.samplerate, m_outsr);
 | 
						m_resampler->SetRates(m_inputfile->info.samplerate*m_dryplayrate, m_outsr);
 | 
				
			||||||
	int wanted = m_resampler->ResamplePrepare(bufferToFill.numSamples, m_num_outchans, &rsinbuf);
 | 
						int wanted = m_resampler->ResamplePrepare(bufferToFill.numSamples, m_num_outchans, &rsinbuf);
 | 
				
			||||||
	m_inputfile->readNextBlock(m_drypreviewbuf, wanted, m_num_outchans);
 | 
						m_inputfile->readNextBlock(m_drypreviewbuf, wanted, m_num_outchans);
 | 
				
			||||||
	for (int i = 0; i < wanted; ++i)
 | 
						for (int i = 0; i < wanted; ++i)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -104,6 +104,8 @@ public:
 | 
				
			|||||||
	double getLoopXFadeLengtj() const { return m_loopxfadelen; }
 | 
						double getLoopXFadeLengtj() const { return m_loopxfadelen; }
 | 
				
			||||||
	void setPreviewDry(bool b);
 | 
						void setPreviewDry(bool b);
 | 
				
			||||||
	bool isPreviewingDry() const;
 | 
						bool isPreviewingDry() const;
 | 
				
			||||||
 | 
						void setDryPlayrate(double rate);
 | 
				
			||||||
 | 
						double getDryPlayrate() const;
 | 
				
			||||||
	int m_param_change_count = 0;
 | 
						int m_param_change_count = 0;
 | 
				
			||||||
	double getLastSeekPos() const { return m_seekpos; }
 | 
						double getLastSeekPos() const { return m_seekpos; }
 | 
				
			||||||
	CriticalSection* getMutex() { return &m_cs; }
 | 
						CriticalSection* getMutex() { return &m_cs; }
 | 
				
			||||||
@@ -163,6 +165,7 @@ private:
 | 
				
			|||||||
	} m_xfadetask;
 | 
						} m_xfadetask;
 | 
				
			||||||
	int m_pause_fade_counter = 0;
 | 
						int m_pause_fade_counter = 0;
 | 
				
			||||||
	bool m_preview_dry = false;
 | 
						bool m_preview_dry = false;
 | 
				
			||||||
 | 
						double m_dryplayrate = 1.0;
 | 
				
			||||||
	AudioBuffer<float> m_drypreviewbuf;
 | 
						AudioBuffer<float> m_drypreviewbuf;
 | 
				
			||||||
	void playDrySound(const AudioSourceChannelInfo & bufferToFill);
 | 
						void playDrySound(const AudioSourceChannelInfo & bufferToFill);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -119,7 +119,7 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau
 | 
				
			|||||||
			m_parcomps.push_back(nullptr);
 | 
								m_parcomps.push_back(nullptr);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						//m_parcomps[cpi_dryplayrate]->getSlider()->setSkewFactorFromMidPoint(1.0);
 | 
				
			||||||
	//addAndMakeVisible(&m_specvis);
 | 
						//addAndMakeVisible(&m_specvis);
 | 
				
			||||||
	m_wave_container->addAndMakeVisible(&m_zs);
 | 
						m_wave_container->addAndMakeVisible(&m_zs);
 | 
				
			||||||
	m_zs.RangeChanged = [this](Range<double> r)
 | 
						m_zs.RangeChanged = [this](Range<double> r)
 | 
				
			||||||
@@ -375,6 +375,9 @@ void PaulstretchpluginAudioProcessorEditor::resized()
 | 
				
			|||||||
	xoffs += div;
 | 
						xoffs += div;
 | 
				
			||||||
	m_parcomps[cpi_soundend]->setBounds(xoffs, yoffs, div - 1, 24);
 | 
						m_parcomps[cpi_soundend]->setBounds(xoffs, yoffs, div - 1, 24);
 | 
				
			||||||
	yoffs += 25;
 | 
						yoffs += 25;
 | 
				
			||||||
 | 
						xoffs = 1;
 | 
				
			||||||
 | 
						m_parcomps[cpi_dryplayrate]->setBounds(xoffs, yoffs, getWidth() - 2, 24);
 | 
				
			||||||
 | 
						yoffs += 25;
 | 
				
			||||||
	int remain_h = getHeight() - 1 - yoffs;
 | 
						int remain_h = getHeight() - 1 - yoffs;
 | 
				
			||||||
	m_spec_order_ed.setBounds(1, yoffs, getWidth() - 2, remain_h / 9 * 1);
 | 
						m_spec_order_ed.setBounds(1, yoffs, getWidth() - 2, remain_h / 9 * 1);
 | 
				
			||||||
	m_wavefilter_tab.setBounds(1, m_spec_order_ed.getBottom() + 1, getWidth() - 2, remain_h / 9 * 8);
 | 
						m_wavefilter_tab.setBounds(1, m_spec_order_ed.getBottom() + 1, getWidth() - 2, remain_h / 9 * 8);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,6 +90,7 @@ public:
 | 
				
			|||||||
	void updateComponent();
 | 
						void updateComponent();
 | 
				
			||||||
	void setHighLighted(bool b);
 | 
						void setHighLighted(bool b);
 | 
				
			||||||
	int m_group_id = -1;
 | 
						int m_group_id = -1;
 | 
				
			||||||
 | 
						Slider* getSlider() { return m_slider.get(); }
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	Label m_label;
 | 
						Label m_label;
 | 
				
			||||||
	AudioProcessorParameter* m_par = nullptr;
 | 
						AudioProcessorParameter* m_par = nullptr;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -169,7 +169,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	addParameter(new AudioParameterBool("loop_enabled0", "Loop", true)); // 60
 | 
						addParameter(new AudioParameterBool("loop_enabled0", "Loop", true)); // 60
 | 
				
			||||||
	addParameter(new AudioParameterBool("rewind0", "Rewind", false)); // 61
 | 
						addParameter(new AudioParameterBool("rewind0", "Rewind", false)); // 61
 | 
				
			||||||
 | 
						addParameter(new AudioParameterFloat("dryplayrate0", "Dry playrate", 0.1, 8.0, 1.0)); // 62
 | 
				
			||||||
	auto& pars = getParameters();
 | 
						auto& pars = getParameters();
 | 
				
			||||||
	for (const auto& p : pars)
 | 
						for (const auto& p : pars)
 | 
				
			||||||
		m_reset_pars.push_back(p->getValue());
 | 
							m_reset_pars.push_back(p->getValue());
 | 
				
			||||||
@@ -697,6 +697,7 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
 | 
				
			|||||||
	m_stretch_source->setMainVolume(*getFloatParameter(cpi_main_volume));
 | 
						m_stretch_source->setMainVolume(*getFloatParameter(cpi_main_volume));
 | 
				
			||||||
	m_stretch_source->setRate(*getFloatParameter(cpi_stretchamount));
 | 
						m_stretch_source->setRate(*getFloatParameter(cpi_stretchamount));
 | 
				
			||||||
	m_stretch_source->setPreviewDry(*getBoolParameter(cpi_bypass_stretch));
 | 
						m_stretch_source->setPreviewDry(*getBoolParameter(cpi_bypass_stretch));
 | 
				
			||||||
 | 
						m_stretch_source->setDryPlayrate(*getFloatParameter(cpi_dryplayrate));
 | 
				
			||||||
	setFFTSize(*getFloatParameter(cpi_fftsize));
 | 
						setFFTSize(*getFloatParameter(cpi_fftsize));
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	updateStretchParametersFromPluginParameters(m_ppar);
 | 
						updateStretchParametersFromPluginParameters(m_ppar);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,6 +86,7 @@ const int cpi_octaves_ratio6 = 58;
 | 
				
			|||||||
const int cpi_octaves_ratio7 = 59;
 | 
					const int cpi_octaves_ratio7 = 59;
 | 
				
			||||||
const int cpi_looping_enabled = 60;
 | 
					const int cpi_looping_enabled = 60;
 | 
				
			||||||
const int cpi_rewind = 61;
 | 
					const int cpi_rewind = 61;
 | 
				
			||||||
 | 
					const int cpi_dryplayrate = 62;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MyPropertiesFile
 | 
					class MyPropertiesFile
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user