Initial work to change octave mixer spectral module to a more generic ratio mixer module that has more shifters and allows changing the shift ratios. Also added a separate tab page in the GUI for it.
This commit is contained in:
@ -112,8 +112,10 @@ void ProcessedStretch::process_spectrum(REALTYPE *freq)
|
||||
spectrum_do_freq_shift(pars,nfreq,samplerate,m_infreq.data(), freq);
|
||||
if (e.m_index == 3 && *e.m_enabled == true)
|
||||
spectrum_do_pitch_shift(pars,nfreq,m_infreq.data(), freq, pow(2.0f, pars.pitch_shift.cents / 1200.0f));
|
||||
//if (e.m_index == 4 && *e.m_enabled == true)
|
||||
// spectrum_do_octave(pars,nfreq,samplerate, m_sumfreq, m_tmpfreq1, m_infreq.data(), freq);
|
||||
if (e.m_index == 4 && *e.m_enabled == true)
|
||||
spectrum_do_octave(pars,nfreq,samplerate, m_sumfreq, m_tmpfreq1, m_infreq.data(), freq);
|
||||
spectrum_do_ratiomix(pars,nfreq,samplerate, m_sumfreq, m_tmpfreq1, m_infreq.data(), freq);
|
||||
if (e.m_index == 5 && *e.m_enabled == true)
|
||||
spectrum_spread(nfreq,samplerate,m_tmpfreq1,m_infreq.data(), freq, pars.spread.bandwidth);
|
||||
if (e.m_index == 6 && *e.m_enabled == true)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Stretch.h"
|
||||
#include <array>
|
||||
#include "../jcdp_envelope.h"
|
||||
|
||||
struct ProcessParameters
|
||||
@ -28,6 +29,8 @@ struct ProcessParameters
|
||||
{
|
||||
pitch_shift.cents=0;
|
||||
|
||||
ratiomix.ratios = { 0.25,0.5,1.0,2.0,3.0,4.0,0.0,0.0 };
|
||||
|
||||
octave.om2=octave.om1=octave.o1=octave.o15=octave.o2=0.0f;
|
||||
octave.o0=1.0f;
|
||||
|
||||
@ -58,9 +61,17 @@ struct ProcessParameters
|
||||
int cents;
|
||||
}pitch_shift;
|
||||
|
||||
|
||||
struct{
|
||||
REALTYPE om2,om1,o0,o1,o15,o2;
|
||||
}octave;
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
std::array<double, 8> ratios;
|
||||
std::array<double, 8> ratiolevels;
|
||||
} ratiomix;
|
||||
|
||||
struct{
|
||||
int Hz;
|
||||
@ -152,7 +163,9 @@ struct ProcessParameters
|
||||
filter.hdamp == other.filter.hdamp &&
|
||||
filter.high == other.filter.high &&
|
||||
filter.low == other.filter.low &&
|
||||
filter.stop == other.filter.stop;
|
||||
filter.stop == other.filter.stop &&
|
||||
ratiomix.ratiolevels == other.ratiomix.ratiolevels &&
|
||||
ratiomix.ratios == other.ratiomix.ratios;
|
||||
}
|
||||
};
|
||||
|
||||
@ -393,6 +406,30 @@ inline void spectrum_do_octave(const ProcessParameters& pars, int nfreq, double
|
||||
for (int i = 0; i<nfreq; i++) freq2[i] = sumfreq[i] / sum;
|
||||
};
|
||||
|
||||
inline void spectrum_do_ratiomix(const ProcessParameters& pars, int nfreq, double /*samplerate*/,
|
||||
std::vector<REALTYPE>& sumfreq,
|
||||
std::vector<REALTYPE>& tmpfreq1,
|
||||
REALTYPE *freq1, REALTYPE *freq2)
|
||||
{
|
||||
spectrum_zero(nfreq, sumfreq.data());
|
||||
double ratiolevelsum = 0.01;
|
||||
for (int i = 0; i < pars.ratiomix.ratios.size(); ++i)
|
||||
{
|
||||
double ratiolevel = pars.ratiomix.ratiolevels[i];
|
||||
double ratio = pars.ratiomix.ratios[i];
|
||||
ratiolevelsum += ratiolevel;
|
||||
if (ratiolevel > 1e-3 && ratio > 0.0)
|
||||
{
|
||||
spectrum_do_pitch_shift(pars, nfreq, freq1, tmpfreq1.data(), ratio);
|
||||
spectrum_add(nfreq, sumfreq.data(), tmpfreq1.data(), ratiolevel);
|
||||
}
|
||||
}
|
||||
if (ratiolevelsum<0.5f)
|
||||
ratiolevelsum = 0.5f;
|
||||
for (int i = 0; i<nfreq; i++)
|
||||
freq2[i] = sumfreq[i] / ratiolevelsum;
|
||||
};
|
||||
|
||||
inline void spectrum_do_filter(const ProcessParameters& pars, int nfreq, double samplerate, REALTYPE *freq1, REALTYPE *freq2) {
|
||||
REALTYPE low = 0, high = 0;
|
||||
if (pars.filter.low<pars.filter.high) {//sort the low/high freqs
|
||||
|
@ -27,6 +27,12 @@ using floatvector = std::vector<REALTYPE>;
|
||||
using float2dvector = std::vector<std::vector<float>>;
|
||||
using float3dvector = std::vector<std::vector<std::vector<float>>>;
|
||||
|
||||
template<typename T>
|
||||
using uptrvec = std::vector<std::unique_ptr<T>>;
|
||||
|
||||
template<typename T>
|
||||
using sptrvec = std::vector<std::shared_ptr<T>>;
|
||||
|
||||
template<typename T>
|
||||
inline std::unique_ptr<T> unique_from_raw(T* ptr)
|
||||
{
|
||||
|
Reference in New Issue
Block a user