diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index 5f72163..04b0384 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -129,6 +129,20 @@ void StretchAudioSource::setAudioBufferAsInputSource(AudioBuffer* buf, in setPlayRange({ 0.0,1.0 }, true); } +void StretchAudioSource::setMainVolume(double decibels) +{ + std::lock_guard locker(m_mutex); + m_main_volume = jlimit(-144.0, 12.0, decibels); + ++m_param_change_count; +} + +void StretchAudioSource::setLoopXFadeLength(double lenseconds) +{ + std::lock_guard locker(m_mutex); + m_loopxfadelen = jlimit(0.0, 1.0, lenseconds); + ++m_param_change_count; +} + void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & bufferToFill) { // for realtime play, this is assumed to be used with BufferingAudioSource, so mutex locking should not be too bad... @@ -145,7 +159,7 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer e->set_freezing(m_freezing); } - double maingain = Decibels::decibelsToGain((double)val_MainVolume.getValue()); + double maingain = Decibels::decibelsToGain(m_main_volume); if (m_vol_smoother.getTargetValue() != maingain) m_vol_smoother.setValue(maingain); FloatVectorOperations::disableDenormalisedNumberSupport(); @@ -158,7 +172,7 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer return; if (m_inputfile->info.nsamples == 0) return; - m_inputfile->setXFadeLenSeconds(val_XFadeLen.getValue()); + m_inputfile->setXFadeLenSeconds(m_loopxfadelen); double silencethreshold = Decibels::decibelsToGain(-70.0); bool tempfirst = true; @@ -633,8 +647,8 @@ void MultiStretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & b m_blocksize = bufferToFill.numSamples; if (m_is_in_switch == false) { - getActiveStretchSource()->val_MainVolume.setValue(val_MainVolume.getValue()); - getActiveStretchSource()->val_XFadeLen.setValue(val_XFadeLen.getValue()); + getActiveStretchSource()->setMainVolume(val_MainVolume.getValue()); + getActiveStretchSource()->setLoopXFadeLength(val_XFadeLen.getValue()); getActiveStretchSource()->setFreezing(m_freezing); getActiveStretchSource()->getNextAudioBlock(bufferToFill); @@ -648,10 +662,10 @@ void MultiStretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & b } AudioSourceChannelInfo ascinfo1(m_processbuffers[0]); AudioSourceChannelInfo ascinfo2(m_processbuffers[1]); - m_stretchsources[0]->val_MainVolume.setValue(val_MainVolume.getValue()); - m_stretchsources[1]->val_MainVolume.setValue(val_MainVolume.getValue()); - m_stretchsources[0]->val_XFadeLen.setValue(val_XFadeLen.getValue()); - m_stretchsources[1]->val_XFadeLen.setValue(val_XFadeLen.getValue()); + m_stretchsources[0]->setMainVolume(val_MainVolume.getValue()); + m_stretchsources[1]->setMainVolume(val_MainVolume.getValue()); + m_stretchsources[0]->setLoopXFadeLength(val_XFadeLen.getValue()); + m_stretchsources[1]->setLoopXFadeLength(val_XFadeLen.getValue()); m_stretchsources[0]->setFreezing(m_freezing); m_stretchsources[1]->setFreezing(m_freezing); m_stretchsources[1]->setFFTWindowingType(m_stretchsources[0]->getFFTWindowingType()); diff --git a/Source/PS_Source/StretchSource.h b/Source/PS_Source/StretchSource.h index 6fe9963..e44d5f3 100644 --- a/Source/PS_Source/StretchSource.h +++ b/Source/PS_Source/StretchSource.h @@ -82,8 +82,7 @@ public: void setFFTWindowingType(int windowtype); int getFFTWindowingType() { return m_fft_window_type; } std::pair,Range> getFileCachedRangesNormalized(); - Value val_MainVolume; - Value val_XFadeLen; + ValueTree getStateTree(); void setStateTree(ValueTree state); void setClippingEnabled(bool b) { m_clip_output = b; } @@ -91,6 +90,10 @@ public: void setLoopingEnabled(bool b); void setMaxLoops(int64_t numloops) { m_maxloops = numloops; } void setAudioBufferAsInputSource(AudioBuffer* buf, int sr, int len); + void setMainVolume(double decibels); + double getMainVolume() const { return m_main_volume; } + void setLoopXFadeLength(double lenseconds); + double getLoopXFadeLengtj() const { return m_loopxfadelen; } int m_param_change_count = 0; private: CircularBuffer m_stretchoutringbuf{ 1024 * 1024 }; @@ -107,6 +110,8 @@ private: double m_outsr = 44100.0; int m_process_fftsize = 0; int m_fft_window_type = -1; + double m_main_volume = 0.0; + double m_loopxfadelen = 0.0; ProcessParameters m_ppar; BinauralBeatsParameters m_bbpar; double m_playrate = 1.0; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 5ca5007..854a409 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -79,7 +79,7 @@ void PaulstretchpluginAudioProcessorEditor::resized() for (int i = 0; i < m_parcomps.size(); ++i) { - m_parcomps[i]->setBounds(1, 30 + i * 25, 598, 24); + m_parcomps[i]->setBounds(1, 30 + i * 25, getWidth()-2, 24); } int yoffs = m_parcomps.back()->getBottom() + 1; m_wavecomponent.setBounds(1, yoffs, getWidth()-2, getHeight()-1-yoffs); diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index c79cdd4..46747ab 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -12,8 +12,10 @@ #include "PluginEditor.h" #include +#ifdef WIN32 #undef min #undef max +#endif std::set g_activeprocessors; @@ -92,6 +94,8 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor() addParameter(new AudioParameterFloat("playrange_end0", "Sound end", 0.0f, 1.0f, 1.0f)); // 6 addParameter(new AudioParameterBool("freeze0", "Freeze", false)); // 7 addParameter(new AudioParameterFloat("spread0", "Frequency spread", 0.0f, 1.0f, 0.0f)); // 8 + addParameter(new AudioParameterFloat("compress0", "Compress", 0.0f, 1.0f, 0.0f)); // 9 + addParameter(new AudioParameterFloat("loopxfadelen0", "Loop xfade length", 0.0f, 1.0f, 0.0f)); // 10 } PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor() @@ -145,7 +149,7 @@ bool PaulstretchpluginAudioProcessor::isMidiEffect() const double PaulstretchpluginAudioProcessor::getTailLengthSeconds() const { - return 0.0; + return (double)m_bufamounts[m_prebuffer_amount]/getSampleRate(); } int PaulstretchpluginAudioProcessor::getNumPrograms() @@ -306,14 +310,16 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M } jassert(m_buffering_source != nullptr); jassert(m_bufferingthread.isThreadRunning()); - m_stretch_source->val_MainVolume = (float)*getFloatParameter(0); + m_stretch_source->setMainVolume(*getFloatParameter(0)); m_stretch_source->setRate(*getFloatParameter(1)); - m_stretch_source->val_XFadeLen = 0.1; + setFFTSize(*getFloatParameter(2)); m_ppar.pitch_shift.cents = *getFloatParameter(3) * 100.0; m_ppar.freq_shift.Hz = *getFloatParameter(4); m_ppar.spread.enabled = *getFloatParameter(8) > 0.0f; m_ppar.spread.bandwidth = *getFloatParameter(8); + m_ppar.compressor.power = *getFloatParameter(9); + m_stretch_source->setLoopXFadeLength(*getFloatParameter(10)); double t0 = *getFloatParameter(5); double t1 = *getFloatParameter(6); if (t0 > t1) diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 34b77f6..25094d6 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -73,7 +73,7 @@ private: bool m_ready_to_play = false; AudioBuffer m_recbuffer; - double m_max_reclen = 5; + double m_max_reclen = 10.0; bool m_is_recording = false; int m_rec_pos = 0; void finishRecording(int lenrecorded);