From b4c3b026e103087679877c36d45b710b3d464d0f Mon Sep 17 00:00:00 2001 From: xenakios Date: Wed, 28 Feb 2018 05:38:19 +0200 Subject: [PATCH] Added tilt transform for envelopes --- Source/envelope_component.cpp | 6 +++++- Source/jcdp_envelope.h | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/envelope_component.cpp b/Source/envelope_component.cpp index 4e8ee44..72b7206 100644 --- a/Source/envelope_component.cpp +++ b/Source/envelope_component.cpp @@ -335,7 +335,11 @@ bool EnvelopeComponent::keyPressed(const KeyPress & ev) r = f(m_envelope->m_transform_y_sinus,0.01); if (ev == 'G') r = f(m_envelope->m_transform_y_sinus,-0.01); - if (r==true) + if (ev == 'Y') + r = f(m_envelope->m_transform_y_tilt,0.02); + if (ev == 'H') + r = f(m_envelope->m_transform_y_tilt,-0.02); + if (r==true) { repaint(); return true; diff --git a/Source/jcdp_envelope.h b/Source/jcdp_envelope.h index ba9ada8..c9d32a1 100644 --- a/Source/jcdp_envelope.h +++ b/Source/jcdp_envelope.h @@ -563,6 +563,7 @@ public: double m_transform_y_shift = 0.0; double m_transform_y_scale = 1.0; double m_transform_y_sinus = 0.0; + double m_transform_y_tilt = 0.0; inline double getTransformedValue(double x) { if (isTransformed() == false) @@ -574,12 +575,14 @@ public: double diff = 0.5 - v; double scaled = 0.5 - m_transform_y_scale * diff; double shifted = scaled + m_transform_y_shift + m_transform_y_sinus*sin(2*3.141592653*(x-m_transform_x_shift)*8.0); - return jlimit(0.0,1.0,shifted); + double tiltline = 0.5+m_transform_y_tilt*x; + double tilted = shifted+tiltline; + return jlimit(0.0,1.0,tilted); } bool isTransformed() const { return m_transform_x_shift != 0.0 || m_transform_y_shift != 0.0 - || m_transform_y_scale!=1.0 || m_transform_y_sinus!=0.0; + || m_transform_y_scale!=1.0 || m_transform_y_sinus!=0.0 || m_transform_y_tilt!=0.0; } private: nodes_t m_nodes;