From 93cebcdcd2784e937bce86e87d6e15bc47a1b8a6 Mon Sep 17 00:00:00 2001 From: xenakios Date: Sun, 11 Nov 2018 14:46:25 +0200 Subject: [PATCH] Initial work to allow having some spectral module order presets --- Source/PS_Source/StretchSource.cpp | 18 ++++++++++++++++++ Source/PS_Source/StretchSource.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/Source/PS_Source/StretchSource.cpp b/Source/PS_Source/StretchSource.cpp index ae7a67b..899b09c 100644 --- a/Source/PS_Source/StretchSource.cpp +++ b/Source/PS_Source/StretchSource.cpp @@ -26,6 +26,12 @@ www.gnu.org/licenses #undef max #endif +std::vector g_specorderpresets[3] = { + {SPT_Harmonics,SPT_PitchShift,SPT_FreqShift,SPT_Spread,SPT_TonalVsNoise,SPT_Filter,SPT_FreeFilter,SPT_RatioMix,SPT_Compressor}, + {SPT_PitchShift,SPT_Harmonics,SPT_FreqShift,SPT_Spread,SPT_TonalVsNoise,SPT_Filter,SPT_FreeFilter,SPT_RatioMix,SPT_Compressor}, + {SPT_RatioMix,SPT_PitchShift,SPT_Harmonics,SPT_FreqShift,SPT_Spread,SPT_TonalVsNoise,SPT_Filter,SPT_FreeFilter,SPT_Compressor} +}; + StretchAudioSource::StretchAudioSource(int initialnumoutchans, AudioFormatManager* afm, std::array& enab_pars) : m_afm(afm) @@ -259,6 +265,18 @@ double StretchAudioSource::getDryPlayrate() const return m_dryplayrate; } +void StretchAudioSource::setSpectralOrderPreset(int id) +{ + if (id == m_current_spec_order_preset) + return; + if (m_cs.tryEnter()) + { + m_current_spec_order_preset = id; + ++m_param_change_count; + m_cs.exit(); + } +} + void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & bufferToFill) { ScopedLock locker(m_cs); diff --git a/Source/PS_Source/StretchSource.h b/Source/PS_Source/StretchSource.h index f607b93..59bf453 100644 --- a/Source/PS_Source/StretchSource.h +++ b/Source/PS_Source/StretchSource.h @@ -113,6 +113,7 @@ public: CriticalSection* getMutex() { return &m_cs; } int64_t getLastSourcePosition() const { return m_last_filepos; } int m_prebuffersize = 0; + void setSpectralOrderPreset(int id); private: CircularBuffer m_stretchoutringbuf{ 1024 * 1024 }; AudioBuffer m_file_inbuf; @@ -173,4 +174,5 @@ private: AudioBuffer m_drypreviewbuf; int64_t m_last_filepos = 0; void playDrySound(const AudioSourceChannelInfo & bufferToFill); + int m_current_spec_order_preset = -1; };