From b4502ba442b6b59c957106a4476b29f4235513a7 Mon Sep 17 00:00:00 2001 From: xenakios Date: Sun, 3 Dec 2017 23:47:28 +0200 Subject: [PATCH] Add harmonics processing parameters. Add harmonics processing visualization etc --- Source/PS_Source/ProcessedStretch.cpp | 4 ++-- Source/PS_Source/ProcessedStretch.h | 6 ++++++ Source/PS_Source/Stretch.h | 2 +- Source/PluginEditor.cpp | 5 ++++- Source/PluginProcessor.cpp | 5 +++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Source/PS_Source/ProcessedStretch.cpp b/Source/PS_Source/ProcessedStretch.cpp index 3a26779..e4f4d4c 100644 --- a/Source/PS_Source/ProcessedStretch.cpp +++ b/Source/PS_Source/ProcessedStretch.cpp @@ -104,9 +104,9 @@ void ProcessedStretch::process_spectrum(REALTYPE *freq) { for (auto& e : m_spectrum_processes) { - copy(freq, infreq.data()); + spectrum_copy(nfreq, freq, infreq.data()); if (e == 0 && pars.harmonics.enabled) - do_harmonics(infreq.data(), freq); + spectrum_do_harmonics(pars, tmpfreq1, nfreq, samplerate, infreq.data(), freq); if (e == 1 && pars.tonal_vs_noise.enabled) do_tonal_vs_noise(infreq.data(), freq); if (e == 2 && pars.freq_shift.enabled) diff --git a/Source/PS_Source/ProcessedStretch.h b/Source/PS_Source/ProcessedStretch.h index 1ed4360..6269bbd 100644 --- a/Source/PS_Source/ProcessedStretch.h +++ b/Source/PS_Source/ProcessedStretch.h @@ -188,6 +188,12 @@ inline REALTYPE profile(REALTYPE fi, REALTYPE bwi) { }; +inline void spectrum_copy(int nfreq, REALTYPE* freq1, REALTYPE* freq2) +{ + for (int i = 0; i& tmpfreq1, REALTYPE *freq1, REALTYPE *freq2, REALTYPE spread_bandwidth) { diff --git a/Source/PS_Source/Stretch.h b/Source/PS_Source/Stretch.h index 4ac90b9..80e87fe 100644 --- a/Source/PS_Source/Stretch.h +++ b/Source/PS_Source/Stretch.h @@ -192,7 +192,7 @@ class Stretch virtual void process_spectrum(REALTYPE *){}; virtual REALTYPE get_stretch_multiplier(REALTYPE pos_percents); - REALTYPE samplerate; + REALTYPE samplerate=0.0f; private: diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 520092d..69f4ecd 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -488,6 +488,9 @@ void SpectralVisualizer::setState(const ProcessParameters & pars, int nfreqs, do spectrum_do_freq_shift(pars, nfreqs, samplerate, m_freqs2.data(), m_freqs1.data()); spectrum_do_compressor(pars, nfreqs, m_freqs1.data(), m_freqs2.data()); spectrum_spread(nfreqs, samplerate, m_freqs3, m_freqs2.data(), m_freqs1.data(), pars.spread.bandwidth); + if (pars.harmonics.enabled) + spectrum_do_harmonics(pars, m_freqs3, nfreqs, samplerate, m_freqs1.data(), m_freqs2.data()); + else spectrum_copy(nfreqs, m_freqs1.data(), m_freqs2.data()); Graphics g(m_img); g.fillAll(Colours::black); g.setColour(Colours::white); @@ -495,7 +498,7 @@ void SpectralVisualizer::setState(const ProcessParameters & pars, int nfreqs, do { double binfreq = (samplerate / 2 / nfreqs)*i; double xcor = jmap(binfreq, 0.0, samplerate / 2.0, 0.0, getWidth()); - double ycor = getHeight()- jmap(m_freqs1[i], 0.0, nfreqs/64, 0.0, getHeight()); + double ycor = getHeight()- jmap(m_freqs2[i], 0.0, nfreqs/128, 0.0, getHeight()); ycor = jlimit(0.0, getHeight(), ycor); g.drawLine(xcor, getHeight(), xcor, ycor, 1.0); } diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 7d184fd..06357b6 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -97,6 +97,8 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor() 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 + addParameter(new AudioParameterFloat("numharmonics0", "Num harmonics", 0.0f, 100.0f, 0.0f)); // 11 + addParameter(new AudioParameterFloat("harmonicsfreq0", "Harmonics base freq", 1.0f, 5000.0f, 100.0f)); // 12 } PaulstretchpluginAudioProcessor::~PaulstretchpluginAudioProcessor() @@ -320,6 +322,9 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M m_ppar.spread.enabled = *getFloatParameter(8) > 0.0f; m_ppar.spread.bandwidth = *getFloatParameter(8); m_ppar.compressor.power = *getFloatParameter(9); + m_ppar.harmonics.enabled = *getFloatParameter(11)>=1.0; + m_ppar.harmonics.nharmonics = *getFloatParameter(11); + m_ppar.harmonics.freq = *getFloatParameter(12); m_stretch_source->setLoopXFadeLength(*getFloatParameter(10)); double t0 = *getFloatParameter(5); double t1 = *getFloatParameter(6);