| @@ -302,3 +302,5 @@ inline void sanitizeTimeRange(double& t0, double& t1) | |||||
| if (t1 - t0 < 0.001) | if (t1 - t0 < 0.001) | ||||
| t1 = t0 + 0.001; | t1 = t0 + 0.001; | ||||
| } | } | ||||
| inline double fractpart(double x) { return x - (int)x; }; | |||||
| @@ -89,7 +89,8 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau | |||||
| if (i == cpi_pitchshift) | if (i == cpi_pitchshift) | ||||
| group_id = 3; | group_id = 3; | ||||
| if (i == cpi_freefilter_scaley || i == cpi_freefilter_shiftx || i == cpi_freefilter_shifty || | 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; | group_id = 8; | ||||
| m_parcomps.back()->m_group_id = group_id; | m_parcomps.back()->m_group_id = group_id; | ||||
| addAndMakeVisible(m_parcomps.back().get()); | addAndMakeVisible(m_parcomps.back().get()); | ||||
| @@ -220,6 +220,8 @@ ValueTree PaulstretchpluginAudioProcessor::getStateTree(bool ignoreoptions, bool | |||||
| storeToTreeProperties(paramtree, nullptr, getIntParameter(cpi_numharmonics)); | storeToTreeProperties(paramtree, nullptr, getIntParameter(cpi_numharmonics)); | ||||
| storeToTreeProperties(paramtree, nullptr, m_outchansparam); | storeToTreeProperties(paramtree, nullptr, m_outchansparam); | ||||
| storeToTreeProperties(paramtree, nullptr, m_inchansparam); | 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)); | storeToTreeProperties(paramtree, nullptr, getBoolParameter(cpi_bypass_stretch)); | ||||
| if (m_current_file != File() && ignorefile == false) | if (m_current_file != File() && ignorefile == false) | ||||
| { | { | ||||
| @@ -277,6 +279,8 @@ void PaulstretchpluginAudioProcessor::setStateFromTree(ValueTree tree) | |||||
| getFromTreeProperties(tree, m_outchansparam); | getFromTreeProperties(tree, m_outchansparam); | ||||
| getFromTreeProperties(tree, m_inchansparam); | getFromTreeProperties(tree, m_inchansparam); | ||||
| getFromTreeProperties(tree, getBoolParameter(cpi_bypass_stretch)); | 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); | int prebufamt = tree.getProperty("prebufamount", 2); | ||||
| if (prebufamt == -1) | if (prebufamt == -1) | ||||
| @@ -231,6 +231,7 @@ void EnvelopeComponent::mouseDown(const MouseEvent & ev) | |||||
| menu.addItem(1, "Reset"); | menu.addItem(1, "Reset"); | ||||
| menu.addItem(2, "Invert"); | menu.addItem(2, "Invert"); | ||||
| menu.addItem(3, "Wrap envelope X transform", true, m_envelope->m_transform_wrap_x); | 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(); | int r = menu.show(); | ||||
| if (r == 1) | if (r == 1) | ||||
| { | { | ||||
| @@ -250,6 +251,10 @@ void EnvelopeComponent::mouseDown(const MouseEvent & ev) | |||||
| { | { | ||||
| toggleBool(m_envelope->m_transform_wrap_x); | toggleBool(m_envelope->m_transform_wrap_x); | ||||
| } | } | ||||
| if (r == 4) | |||||
| { | |||||
| toggleBool(m_envelope->m_transform_y_random_linear_interpolation); | |||||
| } | |||||
| repaint(); | repaint(); | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -226,6 +226,7 @@ public: | |||||
| result.addChild(pt_tree, -1, nullptr); | result.addChild(pt_tree, -1, nullptr); | ||||
| } | } | ||||
| result.setProperty("wrapxtransform", m_transform_wrap_x, nullptr); | result.setProperty("wrapxtransform", m_transform_wrap_x, nullptr); | ||||
| result.setProperty("yrandlerp", m_transform_y_random_linear_interpolation, nullptr); | |||||
| return result; | return result; | ||||
| } | } | ||||
| void restoreState(ValueTree state) | void restoreState(ValueTree state) | ||||
| @@ -233,6 +234,7 @@ public: | |||||
| if (state.isValid()==false) | if (state.isValid()==false) | ||||
| return; | return; | ||||
| m_transform_wrap_x = state.getProperty("wrapxtransform", false); | m_transform_wrap_x = state.getProperty("wrapxtransform", false); | ||||
| m_transform_y_random_linear_interpolation = state.getProperty("yrandlerp", false); | |||||
| int numnodes = state.getNumChildren(); | int numnodes = state.getNumChildren(); | ||||
| if (numnodes > 0) | if (numnodes > 0) | ||||
| { | { | ||||
| @@ -574,6 +576,7 @@ public: | |||||
| double m_transform_y_tilt = 0.0; | double m_transform_y_tilt = 0.0; | ||||
| double m_transform_y_random_amount = 0.2; | double m_transform_y_random_amount = 0.2; | ||||
| double m_transform_y_random_rate = 2.0; | double m_transform_y_random_rate = 2.0; | ||||
| bool m_transform_y_random_linear_interpolation = false; | |||||
| int m_transform_y_random_bands = 32; | int m_transform_y_random_bands = 32; | ||||
| bool m_transform_wrap_x = false; | bool m_transform_wrap_x = false; | ||||
| double m_min_pt_value = 0.0; | double m_min_pt_value = 0.0; | ||||
| @@ -599,17 +602,31 @@ public: | |||||
| double tilted = shifted+tiltline; | double tilted = shifted+tiltline; | ||||
| if (m_transform_y_random_amount > 0.0) | 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); | return jlimit(0.0,1.0,tilted); | ||||
| } | } | ||||
| bool isTransformed() const | 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 || 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() | void updateMinMaxValues() | ||||
| { | { | ||||