Add harmonics processing parameters. Add harmonics processing visualization etc

This commit is contained in:
xenakios 2017-12-03 23:47:28 +02:00
parent 75be994714
commit b4502ba442
5 changed files with 18 additions and 4 deletions

View File

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

View File

@ -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<nfreq; i++) freq2[i] = freq1[i];
};
inline void spectrum_spread(int nfreq, double samplerate,
std::vector<REALTYPE>& tmpfreq1,
REALTYPE *freq1, REALTYPE *freq2, REALTYPE spread_bandwidth) {

View File

@ -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:

View File

@ -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<double>(binfreq, 0.0, samplerate / 2.0, 0.0, getWidth());
double ycor = getHeight()- jmap<double>(m_freqs1[i], 0.0, nfreqs/64, 0.0, getHeight());
double ycor = getHeight()- jmap<double>(m_freqs2[i], 0.0, nfreqs/128, 0.0, getHeight());
ycor = jlimit<double>(0.0, getHeight(), ycor);
g.drawLine(xcor, getHeight(), xcor, ycor, 1.0);
}

View File

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