Finally added enabled buttons for the spectral steps.
This commit is contained in:
parent
48b9434fba
commit
84164da2d7
@ -109,21 +109,21 @@ void ProcessedStretch::process_spectrum(REALTYPE *freq)
|
||||
for (auto& e : m_spectrum_processes)
|
||||
{
|
||||
spectrum_copy(nfreq, freq, infreq.data());
|
||||
if (e == 0 && pars.harmonics.enabled)
|
||||
if (e.m_index == 0 && e.m_enabled == true)
|
||||
spectrum_do_harmonics(pars, tmpfreq1, nfreq, samplerate, infreq.data(), freq);
|
||||
if (e == 1 && pars.tonal_vs_noise.enabled)
|
||||
if (e.m_index == 1 && e.m_enabled == true)
|
||||
spectrum_do_tonal_vs_noise(pars,nfreq,samplerate,tmpfreq1, infreq.data(), freq);
|
||||
if (e == 2 && pars.freq_shift.enabled)
|
||||
if (e.m_index == 2 && e.m_enabled == true)
|
||||
spectrum_do_freq_shift(pars,nfreq,samplerate,infreq.data(), freq);
|
||||
if (e == 3 && pars.pitch_shift.enabled)
|
||||
if (e.m_index == 3 && e.m_enabled == true)
|
||||
spectrum_do_pitch_shift(pars,nfreq,infreq.data(), freq, pow(2.0f, pars.pitch_shift.cents / 1200.0f));
|
||||
if (e == 4 && pars.octave.enabled)
|
||||
if (e.m_index == 4 && e.m_enabled == true)
|
||||
spectrum_do_octave(pars,nfreq,samplerate, sumfreq, tmpfreq1, infreq.data(), freq);
|
||||
if (e == 5 && pars.spread.enabled)
|
||||
if (e.m_index == 5 && e.m_enabled == true)
|
||||
spectrum_spread(nfreq,samplerate,tmpfreq1,infreq.data(), freq, pars.spread.bandwidth);
|
||||
if (e == 6 && pars.filter.enabled)
|
||||
if (e.m_index == 6 && e.m_enabled == true)
|
||||
spectrum_do_filter(pars,nfreq,samplerate,infreq.data(), freq);
|
||||
if (e == 7 && pars.compressor.enabled)
|
||||
if (e.m_index == 7 && e.m_enabled == true)
|
||||
spectrum_do_compressor(pars,nfreq, infreq.data(), freq);
|
||||
}
|
||||
|
||||
@ -197,16 +197,3 @@ void ProcessedStretch::update_free_filter()
|
||||
*/
|
||||
};
|
||||
|
||||
std::vector<SpectrumProcess> make_spectrum_processes()
|
||||
{
|
||||
std::vector<SpectrumProcess> m_spectrum_processes;
|
||||
m_spectrum_processes.emplace_back("Harmonics",0);
|
||||
m_spectrum_processes.emplace_back("Tonal vs Noise",1);
|
||||
m_spectrum_processes.emplace_back("Frequency shift",2);
|
||||
m_spectrum_processes.emplace_back("Pitch shift",3);
|
||||
m_spectrum_processes.emplace_back("Octaves mix",4);
|
||||
m_spectrum_processes.emplace_back("Spread",5);
|
||||
m_spectrum_processes.emplace_back("Filter",6);
|
||||
m_spectrum_processes.emplace_back("Compressor",7);
|
||||
return m_spectrum_processes;
|
||||
}
|
||||
|
@ -440,16 +440,12 @@ inline void spectrum_do_filter(const ProcessParameters& pars, int nfreq, double
|
||||
class SpectrumProcess
|
||||
{
|
||||
public:
|
||||
SpectrumProcess() {}
|
||||
SpectrumProcess(String name, int index) :
|
||||
m_name(name), m_index(index) {}
|
||||
String m_name;
|
||||
SpectrumProcess() {}
|
||||
SpectrumProcess(int index, bool enabled) : m_index(index), m_enabled(enabled) {}
|
||||
int m_index = -1;
|
||||
private:
|
||||
bool m_enabled = true;
|
||||
};
|
||||
|
||||
std::vector<SpectrumProcess> make_spectrum_processes();
|
||||
|
||||
class ProcessedStretch final : public Stretch
|
||||
{
|
||||
public:
|
||||
@ -458,7 +454,7 @@ public:
|
||||
ProcessedStretch(REALTYPE rap_,int in_bufsize_,FFTWindow w=W_HAMMING,bool bypass_=false,REALTYPE samplerate_=44100.0f,int stereo_mode=0);
|
||||
~ProcessedStretch();
|
||||
void set_parameters(ProcessParameters *ppar);
|
||||
std::vector<int> m_spectrum_processes;
|
||||
std::vector<SpectrumProcess> m_spectrum_processes;
|
||||
void setBufferSize(int sz) override;
|
||||
private:
|
||||
REALTYPE get_stretch_multiplier(REALTYPE pos_percents) override;
|
||||
|
@ -12,7 +12,7 @@ StretchAudioSource::StretchAudioSource(int initialnumoutchans, AudioFormatManage
|
||||
m_resampler = std::make_unique<WDL_Resampler>();
|
||||
m_resampler_outbuf.resize(1024*1024);
|
||||
m_inputfile = std::make_unique<AInputS>(m_afm);
|
||||
m_specproc_order = { 0,1,2,3,4,5,6,7 };
|
||||
m_specproc_order = { {0,false} , { 1, false} ,{2,true},{3,true},{4,true},{5,true},{6,true},{7,true} };
|
||||
setNumOutChannels(initialnumoutchans);
|
||||
m_xfadetask.buffer.setSize(8, 65536);
|
||||
m_xfadetask.buffer.clear();
|
||||
@ -58,12 +58,12 @@ bool StretchAudioSource::isResampling()
|
||||
return (int)m_outsr!=m_inputfile->info.samplerate;
|
||||
}
|
||||
|
||||
std::vector<int> StretchAudioSource::getSpectrumProcessOrder()
|
||||
std::vector<SpectrumProcess> StretchAudioSource::getSpectrumProcessOrder()
|
||||
{
|
||||
return m_specproc_order;
|
||||
}
|
||||
|
||||
void StretchAudioSource::setSpectrumProcessOrder(std::vector<int> order)
|
||||
void StretchAudioSource::setSpectrumProcessOrder(std::vector<SpectrumProcess> order)
|
||||
{
|
||||
ScopedLock locker(m_cs);
|
||||
m_specproc_order = order;
|
||||
@ -920,12 +920,12 @@ bool MultiStretchAudioSource::isResampling()
|
||||
return getActiveStretchSource()->isResampling();
|
||||
}
|
||||
|
||||
std::vector<int> MultiStretchAudioSource::getSpectrumProcessOrder()
|
||||
std::vector<SpectrumProcess> MultiStretchAudioSource::getSpectrumProcessOrder()
|
||||
{
|
||||
return getActiveStretchSource()->getSpectrumProcessOrder();
|
||||
}
|
||||
|
||||
void MultiStretchAudioSource::setSpectrumProcessOrder(std::vector<int> order)
|
||||
void MultiStretchAudioSource::setSpectrumProcessOrder(std::vector<SpectrumProcess> order)
|
||||
{
|
||||
getActiveStretchSource()->setSpectrumProcessOrder(order);
|
||||
}
|
||||
|
@ -82,8 +82,8 @@ public:
|
||||
bool isLoopEnabled();
|
||||
bool hasReachedEnd();
|
||||
bool isResampling();
|
||||
std::vector<int> getSpectrumProcessOrder();
|
||||
void setSpectrumProcessOrder(std::vector<int> order);
|
||||
std::vector<SpectrumProcess> getSpectrumProcessOrder();
|
||||
void setSpectrumProcessOrder(std::vector<SpectrumProcess> order);
|
||||
void setFFTWindowingType(int windowtype);
|
||||
int getFFTWindowingType() { return m_fft_window_type; }
|
||||
std::pair<Range<double>,Range<double>> getFileCachedRangesNormalized();
|
||||
@ -135,7 +135,7 @@ private:
|
||||
std::unique_ptr<WDL_Resampler> m_resampler;
|
||||
std::vector<double> m_resampler_outbuf;
|
||||
CriticalSection m_cs;
|
||||
std::vector<int> m_specproc_order;
|
||||
std::vector<SpectrumProcess> m_specproc_order;
|
||||
bool m_stop_play_requested = false;
|
||||
double m_freeze_pos = 0.0;
|
||||
int64_t m_output_counter = 0;
|
||||
@ -199,8 +199,8 @@ public:
|
||||
void setLoopingEnabled(bool b);
|
||||
bool hasReachedEnd();
|
||||
bool isResampling();
|
||||
std::vector<int> getSpectrumProcessOrder();
|
||||
void setSpectrumProcessOrder(std::vector<int> order);
|
||||
std::vector<SpectrumProcess> getSpectrumProcessOrder();
|
||||
void setSpectrumProcessOrder(std::vector<SpectrumProcess> order);
|
||||
void setFFTWindowingType(int windowtype);
|
||||
std::pair<Range<double>, Range<double>> getFileCachedRangesNormalized();
|
||||
void setFreezing(bool b) { m_freezing = b; }
|
||||
|
@ -720,6 +720,17 @@ void SpectralChainEditor::mouseDown(const MouseEvent & ev)
|
||||
int box_w = getWidth() / m_order.size();
|
||||
int box_h = getHeight();
|
||||
m_cur_index = ev.x / box_w;
|
||||
if (m_cur_index >= 0)
|
||||
{
|
||||
juce::Rectangle<int> r(box_w*m_cur_index, 1, 10, 10);
|
||||
if (r.contains(ev.x, ev.y))
|
||||
{
|
||||
m_order[m_cur_index].m_enabled = !m_order[m_cur_index].m_enabled;
|
||||
m_src->setSpectrumProcessOrder(m_order);
|
||||
repaint();
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_drag_x = -1;
|
||||
repaint();
|
||||
}
|
||||
@ -753,21 +764,21 @@ void SpectralChainEditor::mouseUp(const MouseEvent & ev)
|
||||
void SpectralChainEditor::drawBox(Graphics & g, int index, int x, int y, int w, int h)
|
||||
{
|
||||
String txt;
|
||||
if (m_order[index] == 0)
|
||||
if (m_order[index].m_index == 0)
|
||||
txt = "Harmonics";
|
||||
if (m_order[index] == 1)
|
||||
if (m_order[index].m_index == 1)
|
||||
txt = "Tonal vs Noise";
|
||||
if (m_order[index] == 2)
|
||||
if (m_order[index].m_index == 2)
|
||||
txt = "Frequency shift";
|
||||
if (m_order[index] == 3)
|
||||
if (m_order[index].m_index == 3)
|
||||
txt = "Pitch shift";
|
||||
if (m_order[index] == 4)
|
||||
if (m_order[index].m_index == 4)
|
||||
txt = "Octaves";
|
||||
if (m_order[index] == 5)
|
||||
if (m_order[index].m_index == 5)
|
||||
txt = "Spread";
|
||||
if (m_order[index] == 6)
|
||||
if (m_order[index].m_index == 6)
|
||||
txt = "Filter";
|
||||
if (m_order[index] == 7)
|
||||
if (m_order[index].m_index == 7)
|
||||
txt = "Compressor";
|
||||
if (index == m_cur_index)
|
||||
{
|
||||
@ -778,6 +789,14 @@ void SpectralChainEditor::drawBox(Graphics & g, int index, int x, int y, int w,
|
||||
g.setColour(Colours::white);
|
||||
g.drawRect(x, y, w, h);
|
||||
g.drawFittedText(txt, x,y,w,h, Justification::centred, 3);
|
||||
g.setColour(Colours::gold);
|
||||
g.drawRect(x + 2, y + 2, 10, 10);
|
||||
if (m_order[index].m_enabled == true)
|
||||
{
|
||||
g.drawLine(x+2, y+2, x+12, y+12);
|
||||
g.drawLine(x+2, y+12, x+12, y+2);
|
||||
}
|
||||
g.setColour(Colours::white);
|
||||
}
|
||||
|
||||
ParameterComponent::ParameterComponent(AudioProcessorParameter * par, bool notifyOnlyOnRelease) : m_par(par)
|
||||
|
@ -139,7 +139,7 @@ private:
|
||||
bool m_did_drag = false;
|
||||
int m_cur_index = -1;
|
||||
int m_drag_x = 0;
|
||||
std::vector<int> m_order;
|
||||
std::vector<SpectrumProcess> m_order;
|
||||
void drawBox(Graphics& g, int index, int x, int y, int w, int h);
|
||||
};
|
||||
|
||||
|
@ -239,7 +239,8 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool
|
||||
paramtree.setProperty("numspectralstages", (int)specorder.size(), nullptr);
|
||||
for (int i = 0; i < specorder.size(); ++i)
|
||||
{
|
||||
paramtree.setProperty("specorder" + String(i), specorder[i], nullptr);
|
||||
paramtree.setProperty("specorder" + String(i), specorder[i].m_index, nullptr);
|
||||
paramtree.setProperty("specstepenabled" + String(i), specorder[i].m_enabled, nullptr);
|
||||
}
|
||||
if (ignoreoptions == false)
|
||||
{
|
||||
@ -261,11 +262,12 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree)
|
||||
m_load_file_with_state = tree.getProperty("loadfilewithstate", true);
|
||||
if (tree.hasProperty("numspectralstages"))
|
||||
{
|
||||
std::vector<int> order;
|
||||
std::vector<SpectrumProcess> order;
|
||||
int ordersize = tree.getProperty("numspectralstages");
|
||||
for (int i = 0; i < ordersize; ++i)
|
||||
{
|
||||
order.push_back((int)tree.getProperty("specorder" + String(i)));
|
||||
bool step_enabled = tree.getProperty("specstepenabled" + String(i));
|
||||
order.push_back({ (int)tree.getProperty("specorder" + String(i)), step_enabled });
|
||||
}
|
||||
m_stretch_source->setSpectrumProcessOrder(order);
|
||||
}
|
||||
@ -698,7 +700,9 @@ String PaulstretchpluginAudioProcessor::setAudioFile(File f)
|
||||
m_thumb->setSource(new FileInputSource(f));
|
||||
ScopedLock locker(m_cs);
|
||||
m_stretch_source->setAudioFile(f);
|
||||
m_stretch_source->seekPercent(*getFloatParameter(cpi_soundstart));
|
||||
//Range<double> currange{ *getFloatParameter(cpi_soundstart),*getFloatParameter(cpi_soundend) };
|
||||
//if (currange.contains(m_stretch_source->getInfilePositionPercent())==false)
|
||||
m_stretch_source->seekPercent(*getFloatParameter(cpi_soundstart));
|
||||
m_current_file = f;
|
||||
m_current_file_date = m_current_file.getLastModificationTime();
|
||||
m_using_memory_buffer = false;
|
||||
|
Loading…
Reference in New Issue
Block a user