Added scaling transform for envelope

This commit is contained in:
xenakios 2018-02-28 00:32:18 +02:00
parent ff35bce695
commit c6c2855a56
3 changed files with 12 additions and 2 deletions

View File

@ -82,6 +82,7 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
m_playposinfo.timeInSeconds = 0.0;
m_free_filter_envelope = std::make_shared<breakpoint_envelope>();
m_free_filter_envelope->SetName("Free filter");
m_free_filter_envelope->AddNode({ 0.0,0.75 });
m_free_filter_envelope->AddNode({ 1.0,0.75 });
m_free_filter_envelope->set_reset_nodes(m_free_filter_envelope->get_all_nodes());

View File

@ -321,6 +321,10 @@ bool EnvelopeComponent::keyPressed(const KeyPress & ev)
m_envelope->m_transform_y_shift += 0.01;
if (ev == 'D')
m_envelope->m_transform_y_shift -= 0.01;
if (ev == 'R')
m_envelope->m_transform_y_scale += 0.05;
if (ev == 'F')
m_envelope->m_transform_y_scale -= 0.05;
repaint();
if (ev == KeyPress::deleteKey)

View File

@ -561,6 +561,7 @@ public:
String m_script;
double m_transform_x_shift = 0.0;
double m_transform_y_shift = 0.0;
double m_transform_y_scale = 1.0;
inline double getTransformedValue(double x)
{
if (isTransformed() == false)
@ -568,11 +569,15 @@ public:
double temp = fmod(x - m_transform_x_shift, 1.0);
if (temp < 0.0)
temp += 1.0;
return jlimit(0.0,1.0,GetInterpolatedNodeValue(temp) + m_transform_y_shift);
double v = GetInterpolatedNodeValue(temp);
double diff = 0.5 - v;
double scaled = 0.5 - m_transform_y_scale * diff;
double shifted = scaled + m_transform_y_shift;
return jlimit(0.0,1.0,shifted);
}
bool isTransformed() const
{
return m_transform_x_shift != 0.0 || m_transform_y_shift != 0.0;
return m_transform_x_shift != 0.0 || m_transform_y_shift != 0.0 || m_transform_y_scale!=1.0;
}
private:
nodes_t m_nodes;