Browse Source

Preliminary work to play the sound source unprocessed

tags/1.0.2
xenakios 7 years ago
parent
commit
e6a7d26d27
3 changed files with 35 additions and 3 deletions
  1. +30
    -3
      Source/PS_Source/StretchSource.cpp
  2. +4
    -0
      Source/PS_Source/StretchSource.h
  3. +1
    -0
      Source/PluginProcessor.cpp

+ 30
- 3
Source/PS_Source/StretchSource.cpp View File

@@ -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();


+ 4
- 0
Source/PS_Source/StretchSource.h View File

@@ -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;
}; };

+ 1
- 0
Source/PluginProcessor.cpp View File

@@ -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()


Loading…
Cancel
Save