Preliminary work to play the sound source unprocessed
This commit is contained in:
		@@ -23,7 +23,7 @@ StretchAudioSource::~StretchAudioSource()
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void StretchAudioSource::prepareToPlay(int /*samplesPerBlockExpected*/, double sampleRate)
 | 
					void StretchAudioSource::prepareToPlay(int samplesPerBlockExpected, double sampleRate)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_outsr = sampleRate;
 | 
						m_outsr = sampleRate;
 | 
				
			||||||
	m_vol_smoother.reset(sampleRate, 0.5);
 | 
						m_vol_smoother.reset(sampleRate, 0.5);
 | 
				
			||||||
@@ -34,7 +34,7 @@ void StretchAudioSource::prepareToPlay(int /*samplesPerBlockExpected*/, double s
 | 
				
			|||||||
	m_stream_end_reached = false;
 | 
						m_stream_end_reached = false;
 | 
				
			||||||
	m_firstbuffer = true;
 | 
						m_firstbuffer = true;
 | 
				
			||||||
	m_output_has_begun = false;
 | 
						m_output_has_begun = false;
 | 
				
			||||||
	
 | 
						m_drypreviewbuf.setSize(m_num_outchans, 65536);
 | 
				
			||||||
	initObjects();
 | 
						initObjects();
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -161,9 +161,36 @@ void StretchAudioSource::setLoopXFadeLength(double lenseconds)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void StretchAudioSource::setPreviewDry(bool b)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (b == m_preview_dry)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						if (m_cs.tryEnter())
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							m_preview_dry = b;
 | 
				
			||||||
 | 
							++m_param_change_count;
 | 
				
			||||||
 | 
							m_cs.exit();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool StretchAudioSource::isPreviewingDry() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return m_preview_dry;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & bufferToFill)
 | 
					void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & bufferToFill)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ScopedLock locker(m_cs);
 | 
						ScopedLock locker(m_cs);
 | 
				
			||||||
 | 
						double maingain = Decibels::decibelsToGain(m_main_volume);
 | 
				
			||||||
 | 
						if (m_preview_dry == true && m_inputfile!=nullptr && m_inputfile->info.nsamples>0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							m_inputfile->setXFadeLenSeconds(m_loopxfadelen);
 | 
				
			||||||
 | 
							m_inputfile->readNextBlock(m_drypreviewbuf, bufferToFill.numSamples, m_num_outchans);
 | 
				
			||||||
 | 
							for (int i = 0; i < m_num_outchans; ++i)
 | 
				
			||||||
 | 
								bufferToFill.buffer->copyFrom(i, bufferToFill.startSample, m_drypreviewbuf, i, 0, bufferToFill.numSamples);
 | 
				
			||||||
 | 
							bufferToFill.buffer->applyGain(bufferToFill.startSample, bufferToFill.numSamples, maingain);
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if (m_pause_state == 2)
 | 
						if (m_pause_state == 2)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		bufferToFill.buffer->clear(bufferToFill.startSample,bufferToFill.numSamples);
 | 
							bufferToFill.buffer->clear(bufferToFill.startSample,bufferToFill.numSamples);
 | 
				
			||||||
@@ -181,7 +208,7 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer
 | 
				
			|||||||
			e->set_freezing(m_freezing);
 | 
								e->set_freezing(m_freezing);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
	double maingain = Decibels::decibelsToGain(m_main_volume);
 | 
						
 | 
				
			||||||
	if (m_vol_smoother.getTargetValue() != maingain)
 | 
						if (m_vol_smoother.getTargetValue() != maingain)
 | 
				
			||||||
		m_vol_smoother.setValue(maingain);
 | 
							m_vol_smoother.setValue(maingain);
 | 
				
			||||||
	FloatVectorOperations::disableDenormalisedNumberSupport();
 | 
						FloatVectorOperations::disableDenormalisedNumberSupport();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -99,6 +99,8 @@ public:
 | 
				
			|||||||
	double getMainVolume() const { return m_main_volume; }
 | 
						double getMainVolume() const { return m_main_volume; }
 | 
				
			||||||
	void setLoopXFadeLength(double lenseconds);
 | 
						void setLoopXFadeLength(double lenseconds);
 | 
				
			||||||
	double getLoopXFadeLengtj() const { return m_loopxfadelen; }
 | 
						double getLoopXFadeLengtj() const { return m_loopxfadelen; }
 | 
				
			||||||
 | 
						void setPreviewDry(bool b);
 | 
				
			||||||
 | 
						bool isPreviewingDry() const;
 | 
				
			||||||
	int m_param_change_count = 0;
 | 
						int m_param_change_count = 0;
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	CircularBuffer<float> m_stretchoutringbuf{ 1024 * 1024 };
 | 
						CircularBuffer<float> m_stretchoutringbuf{ 1024 * 1024 };
 | 
				
			||||||
@@ -153,4 +155,6 @@ private:
 | 
				
			|||||||
		File requested_file;
 | 
							File requested_file;
 | 
				
			||||||
	} m_xfadetask;
 | 
						} m_xfadetask;
 | 
				
			||||||
	int m_pause_fade_counter = 0;
 | 
						int m_pause_fade_counter = 0;
 | 
				
			||||||
 | 
						bool m_preview_dry = false;
 | 
				
			||||||
 | 
						AudioBuffer<float> m_drypreviewbuf;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -151,6 +151,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
 | 
				
			|||||||
	setPreBufferAmount(2);
 | 
						setPreBufferAmount(2);
 | 
				
			||||||
    startTimer(1, 50);
 | 
					    startTimer(1, 50);
 | 
				
			||||||
	m_show_technical_info = m_propsfile->m_props_file->getBoolValue("showtechnicalinfo", false);
 | 
						m_show_technical_info = m_propsfile->m_props_file->getBoolValue("showtechnicalinfo", false);
 | 
				
			||||||
 | 
						m_stretch_source->setPreviewDry(true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
 | 
					PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user