Add envelope transform feature
This commit is contained in:
parent
0f70453c3a
commit
ff35bce695
@ -426,7 +426,7 @@ inline void spectrum_do_free_filter(shared_envelope& env, int nfreq, double samp
|
|||||||
if (binhz >= 30.0)
|
if (binhz >= 30.0)
|
||||||
{
|
{
|
||||||
double norm = 0.150542*log(0.0333333*binhz);
|
double norm = 0.150542*log(0.0333333*binhz);
|
||||||
double db = jmap<double>(env->GetInterpolatedNodeValue(norm), 0.0, 1.0, -36.0, 12.0);
|
double db = jmap<double>(env->getTransformedValue(norm), 0.0, 1.0, -36.0, 12.0);
|
||||||
freq2[i] = freq1[i] * Decibels::decibelsToGain(db);
|
freq2[i] = freq1[i] * Decibels::decibelsToGain(db);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -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);
|
m_bubble.showAt({ x,y,100,20 }, temp , 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EnvelopeComponent::paint(Graphics& g)
|
void EnvelopeComponent::paint(Graphics& g)
|
||||||
{
|
{
|
||||||
if (!EnvelopeUnderlayDraw)
|
if (!EnvelopeUnderlayDraw)
|
||||||
@ -105,6 +104,20 @@ void EnvelopeComponent::paint(Graphics& g)
|
|||||||
g.drawLine((float)i, foo_y0, (float)i + 1, foo_y1, linethickness);
|
g.drawLine((float)i, foo_y0, (float)i + 1, foo_y1, linethickness);
|
||||||
y0 = y1;
|
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<double>(y0, m_view_start_value, m_view_end_value, 0.0, getHeight());
|
||||||
|
double foo_y1 = (double)getHeight() - jmap<double>(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)
|
for (int i = 0; i < m_envelope->GetNumNodes(); ++i)
|
||||||
{
|
{
|
||||||
const envelope_node& pt = m_envelope->GetNodeAtIndex(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)
|
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_node_to_drag = -1;
|
||||||
//m_envelope->ClearAllNodes();
|
//m_envelope->ClearAllNodes();
|
||||||
|
@ -559,6 +559,21 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
String m_script;
|
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:
|
private:
|
||||||
nodes_t m_nodes;
|
nodes_t m_nodes;
|
||||||
double m_playoffset=0.0;
|
double m_playoffset=0.0;
|
||||||
|
Loading…
Reference in New Issue
Block a user