diff --git a/Source/PS_Source/Stretch.cpp b/Source/PS_Source/Stretch.cpp index be1aacf..8b6cad2 100644 --- a/Source/PS_Source/Stretch.cpp +++ b/Source/PS_Source/Stretch.cpp @@ -38,7 +38,7 @@ FFT::FFT(int nsamples_, bool no_inverse) window.data[i]=0.707f; window.type=W_RECTANGULAR; - + phases.resize(nsamples); data.resize(nsamples,true); bool allow_long_planning = false; // g_propsfile->getBoolValue("fftw_allow_long_planning", false); //double t0 = Time::getMillisecondCounterHiRes(); @@ -92,9 +92,15 @@ void FFT::smp2freq() void FFT::freq2smp() { REALTYPE inv_2p15_2pi=1.0f/16384.0f*(float)c_PI; - for (int i=1;i smp;//size of samples/2 std::vector freq;//size of samples + std::vector phases; + int nsamples=0; + + void setPhaseRefreshRate(int rate) + { + m_phaserefreshrate = rate; + } + private: fftwf_plan planfftw,planifftw; FFTWBuffer data; - - + int m_phaserefreshcounter = 0; + int m_phaserefreshrate = 1; + void updatePhases(); struct{ std::vector data; FFTWindow type; @@ -165,7 +174,11 @@ class Stretch freezing=new_freezing; }; bool isFreezing() { return freezing; } - + void setPhaseRefreshRate(int rate) + { + jassert(fft != nullptr); + fft->setPhaseRefreshRate(rate); + } std::vector out_buf;//pot sa pun o variabila "max_out_bufsize" si asta sa fie marimea lui out_buf si pe out_bufsize sa il folosesc ca marime adaptiva int get_nsamples(REALTYPE current_pos_percents);//how many samples are required diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index 899b09c..d34c833 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -277,6 +277,23 @@ void StretchAudioSource::setSpectralOrderPreset(int id) } } +void StretchAudioSource::setPhaseRefreshRate(int rate) +{ + for (auto& e : m_stretchers) + e->setPhaseRefreshRate(rate); + return; + if (rate == m_phase_refresh_rate) + return; + if (m_cs.tryEnter()) + { + for (auto& e : m_stretchers) + e->setPhaseRefreshRate(rate); + m_phase_refresh_rate = rate; + ++m_param_change_count; + m_cs.exit(); + } +} + void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & bufferToFill) { ScopedLock locker(m_cs); @@ -347,6 +364,7 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer m_free_filter_envelope->updateRandomState(); } ++m_rand_count; + auto inbufptrs = m_file_inbuf.getArrayOfWritePointers(); REALTYPE onset_max = std::numeric_limits::min(); #ifdef USE_PPL_TO_PROCESS_STRETCHERS diff --git a/Source/PS_Source/StretchSource.h b/Source/PS_Source/StretchSource.h index 59bf453..95a0f5a 100644 --- a/Source/PS_Source/StretchSource.h +++ b/Source/PS_Source/StretchSource.h @@ -114,6 +114,8 @@ public: int64_t getLastSourcePosition() const { return m_last_filepos; } int m_prebuffersize = 0; void setSpectralOrderPreset(int id); + int getPhaseRefreshRate() const { return m_phase_refresh_rate; } + void setPhaseRefreshRate(int rate); private: CircularBuffer m_stretchoutringbuf{ 1024 * 1024 }; AudioBuffer m_file_inbuf; @@ -142,6 +144,7 @@ private: int m_pause_state = 0; Range m_playrange{ 0.0,1.0 }; int64_t m_rand_count = 0; + int m_phase_refresh_rate = 1; bool m_stream_end_reached = false; int64_t m_output_silence_counter = 0; File m_curfile; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 7f39eda..9ff1ebc 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -184,6 +184,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor() addParameter(new AudioParameterFloat("dryplayrate0", "Dry playrate", NormalisableRange(0.1f, 8.0f, dprate_convertFrom0To1Func, dprate_convertTo0To1Func), 1.0f)); // 62 + addParameter(new AudioParameterInt("phaserefreshrate0", "Phase randomization rate", 1, 32, 32)); // 63 auto& pars = getParameters(); for (const auto& p : pars) m_reset_pars.push_back(p->getValue()); @@ -737,6 +738,8 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M m_free_filter_envelope->m_transform_y_random_rate = *getIntParameter(cpi_freefilter_randomy_rate); m_free_filter_envelope->m_transform_y_random_amount = *getFloatParameter(cpi_freefilter_randomy_amount); + m_stretch_source->setPhaseRefreshRate(*getIntParameter(cpi_phase_refresh_rate)); + //m_stretch_source->setSpectralModulesEnabled(m_sm_enab_pars); if (m_stretch_source->isLoopEnabled() != *getBoolParameter(cpi_looping_enabled)) diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index ab3d4cd..d4ab888 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -88,6 +88,7 @@ const int cpi_octaves_ratio7 = 59; const int cpi_looping_enabled = 60; const int cpi_rewind = 61; const int cpi_dryplayrate = 62; +const int cpi_phase_refresh_rate = 63; class MyThreadPool : public ThreadPool {