Added linear interpolation option for envelope random transform, fixes etc

This commit is contained in:
xenakios 2018-03-03 17:55:02 +02:00
parent c391a2c0af
commit d813794ea9
5 changed files with 35 additions and 6 deletions

View File

@ -302,3 +302,5 @@ inline void sanitizeTimeRange(double& t0, double& t1)
if (t1 - t0 < 0.001)
t1 = t0 + 0.001;
}
inline double fractpart(double x) { return x - (int)x; };

View File

@ -89,7 +89,8 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau
if (i == cpi_pitchshift)
group_id = 3;
if (i == cpi_freefilter_scaley || i == cpi_freefilter_shiftx || i == cpi_freefilter_shifty ||
i == cpi_freefilter_tilty)
i == cpi_freefilter_tilty || i == cpi_freefilter_randomy_amount || i == cpi_freefilter_randomy_numbands
|| i == cpi_freefilter_randomy_rate)
group_id = 8;
m_parcomps.back()->m_group_id = group_id;
addAndMakeVisible(m_parcomps.back().get());

View File

@ -220,6 +220,8 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool
storeToTreeProperties(paramtree, nullptr, getIntParameter(cpi_numharmonics));
storeToTreeProperties(paramtree, nullptr, m_outchansparam);
storeToTreeProperties(paramtree, nullptr, m_inchansparam);
storeToTreeProperties(paramtree, nullptr, getIntParameter(cpi_freefilter_randomy_numbands));
storeToTreeProperties(paramtree, nullptr, getIntParameter(cpi_freefilter_randomy_rate));
storeToTreeProperties(paramtree, nullptr, getBoolParameter(cpi_bypass_stretch));
if (m_current_file != File() && ignorefile == false)
{
@ -277,6 +279,8 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree)
getFromTreeProperties(tree, m_outchansparam);
getFromTreeProperties(tree, m_inchansparam);
getFromTreeProperties(tree, getBoolParameter(cpi_bypass_stretch));
getFromTreeProperties(tree, getIntParameter(cpi_freefilter_randomy_numbands));
getFromTreeProperties(tree, getIntParameter(cpi_freefilter_randomy_rate));
}
int prebufamt = tree.getProperty("prebufamount", 2);
if (prebufamt == -1)

View File

@ -231,6 +231,7 @@ void EnvelopeComponent::mouseDown(const MouseEvent & ev)
menu.addItem(1, "Reset");
menu.addItem(2, "Invert");
menu.addItem(3, "Wrap envelope X transform", true, m_envelope->m_transform_wrap_x);
menu.addItem(4, "Envelope Y random linear interpolation", true, m_envelope->m_transform_y_random_linear_interpolation);
int r = menu.show();
if (r == 1)
{
@ -250,6 +251,10 @@ void EnvelopeComponent::mouseDown(const MouseEvent & ev)
{
toggleBool(m_envelope->m_transform_wrap_x);
}
if (r == 4)
{
toggleBool(m_envelope->m_transform_y_random_linear_interpolation);
}
repaint();
return;
}

View File

@ -226,6 +226,7 @@ public:
result.addChild(pt_tree, -1, nullptr);
}
result.setProperty("wrapxtransform", m_transform_wrap_x, nullptr);
result.setProperty("yrandlerp", m_transform_y_random_linear_interpolation, nullptr);
return result;
}
void restoreState(ValueTree state)
@ -233,6 +234,7 @@ public:
if (state.isValid()==false)
return;
m_transform_wrap_x = state.getProperty("wrapxtransform", false);
m_transform_y_random_linear_interpolation = state.getProperty("yrandlerp", false);
int numnodes = state.getNumChildren();
if (numnodes > 0)
{
@ -574,6 +576,7 @@ public:
double m_transform_y_tilt = 0.0;
double m_transform_y_random_amount = 0.2;
double m_transform_y_random_rate = 2.0;
bool m_transform_y_random_linear_interpolation = false;
int m_transform_y_random_bands = 32;
bool m_transform_wrap_x = false;
double m_min_pt_value = 0.0;
@ -599,17 +602,31 @@ public:
double tilted = shifted+tiltline;
if (m_transform_y_random_amount > 0.0)
{
int tableindex = jlimit<int>(0,m_randbuf.size()-1, floor(x * (m_transform_y_random_bands)));
double randamt = jmap(m_randbuf[tableindex], 0.0, 1.0, -m_transform_y_random_amount, m_transform_y_random_amount);
tilted += randamt;
if (m_transform_y_random_linear_interpolation == false)
{
int tableindex = jlimit<int>(0, m_randbuf.size() - 1, floor(x * (m_transform_y_random_bands)));
double randamt = jmap(m_randbuf[tableindex], 0.0, 1.0, -m_transform_y_random_amount, m_transform_y_random_amount);
tilted += randamt;
}
else
{
double fracindex = x * m_transform_y_random_bands;
int tableindex0 = jlimit<int>(0, m_randbuf.size() - 1, floor(fracindex));
int tableindex1 = tableindex0 + 1;
double y0 = m_randbuf[tableindex0];
double y1 = m_randbuf[tableindex1];
double interpolated = y0 + (y1 - y0)*fractpart(fracindex);
double randamt = jmap(interpolated, 0.0, 1.0, -m_transform_y_random_amount, m_transform_y_random_amount);
tilted += randamt;
}
}
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_tilt!=0.0 || m_transform_y_random_amount!=0.0;
|| m_transform_y_scale!=1.0 || m_transform_y_sinus!=0.0 || m_transform_y_tilt!=0.0
|| m_transform_y_random_amount>0.0;
}
void updateMinMaxValues()
{