diff --git a/Source/PS_Source/ProcessedStretch.h b/Source/PS_Source/ProcessedStretch.h index f1cf95e..4307636 100644 --- a/Source/PS_Source/ProcessedStretch.h +++ b/Source/PS_Source/ProcessedStretch.h @@ -426,7 +426,7 @@ inline void spectrum_do_free_filter(shared_envelope& env, int nfreq, double samp if (binhz >= 30.0) { double norm = 0.150542*log(0.0333333*binhz); - double db = jmap(env->GetInterpolatedNodeValue(norm), 0.0, 1.0, -36.0, 12.0); + double db = jmap(env->getTransformedValue(norm), 0.0, 1.0, -36.0, 12.0); freq2[i] = freq1[i] * Decibels::decibelsToGain(db); } else diff --git a/Source/envelope_component.cpp b/Source/envelope_component.cpp index 8d80427..c8ed22c 100644 --- a/Source/envelope_component.cpp +++ b/Source/envelope_component.cpp @@ -53,7 +53,6 @@ void EnvelopeComponent::show_bubble(int x, int y, const envelope_node& node) m_bubble.showAt({ x,y,100,20 }, temp , 5000); } - void EnvelopeComponent::paint(Graphics& g) { if (!EnvelopeUnderlayDraw) @@ -105,6 +104,20 @@ void EnvelopeComponent::paint(Graphics& g) g.drawLine((float)i, foo_y0, (float)i + 1, foo_y1, linethickness); y0 = y1; } + if (m_envelope->isTransformed()) + { + g.setColour(Colours::aliceblue.darker()); + y0 = m_envelope->getTransformedValue(0.0); + for (int i = 1; i < getWidth(); ++i) + { + double env_x = 1.0 / getWidth()*i; + double y1 = m_envelope->getTransformedValue(env_x); + double foo_y0 = (double)getHeight() - jmap(y0, m_view_start_value, m_view_end_value, 0.0, getHeight()); + double foo_y1 = (double)getHeight() - jmap(y1, m_view_start_value, m_view_end_value, 0.0, getHeight()); + g.drawLine((float)i, foo_y0, (float)i + 1, foo_y1, linethickness); + y0 = y1; + } + } for (int i = 0; i < m_envelope->GetNumNodes(); ++i) { const envelope_node& pt = m_envelope->GetNodeAtIndex(i); @@ -298,7 +311,19 @@ void EnvelopeComponent::mouseUp(const MouseEvent &ev) bool EnvelopeComponent::keyPressed(const KeyPress & ev) { - if (ev == KeyPress::deleteKey && m_envelope!=nullptr) + if (m_envelope == nullptr) + return false; + if (ev == 'Q') + m_envelope->m_transform_x_shift -= 0.01; + if (ev == 'W') + m_envelope->m_transform_x_shift += 0.01; + if (ev == 'E') + m_envelope->m_transform_y_shift += 0.01; + if (ev == 'D') + m_envelope->m_transform_y_shift -= 0.01; + repaint(); + + if (ev == KeyPress::deleteKey) { m_node_to_drag = -1; //m_envelope->ClearAllNodes(); diff --git a/Source/jcdp_envelope.h b/Source/jcdp_envelope.h index 6a7364d..2c1bdbe 100644 --- a/Source/jcdp_envelope.h +++ b/Source/jcdp_envelope.h @@ -559,6 +559,21 @@ public: } String m_script; + double m_transform_x_shift = 0.0; + double m_transform_y_shift = 0.0; + inline double getTransformedValue(double x) + { + if (isTransformed() == false) + return x; + 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); + } + bool isTransformed() const + { + return m_transform_x_shift != 0.0 || m_transform_y_shift != 0.0; + } private: nodes_t m_nodes; double m_playoffset=0.0;