Added free filter envelope random transform
This commit is contained in:
		@@ -253,6 +253,11 @@ void StretchAudioSource::getNextAudioBlock(const AudioSourceChannelInfo & buffer
 | 
			
		||||
			{
 | 
			
		||||
				readed = m_inputfile->readNextBlock(m_file_inbuf, readsize, m_num_outchans);
 | 
			
		||||
			}
 | 
			
		||||
			if (m_rand_count % (int)m_free_filter_envelope->m_transform_y_random_rate == 0)
 | 
			
		||||
			{
 | 
			
		||||
				m_free_filter_envelope->updateRandomState();
 | 
			
		||||
			}
 | 
			
		||||
			++m_rand_count;
 | 
			
		||||
			auto inbufptrs = m_file_inbuf.getArrayOfWritePointers();
 | 
			
		||||
			REALTYPE onset_max = std::numeric_limits<REALTYPE>::min();
 | 
			
		||||
#ifdef USE_PPL_TO_PROCESS_STRETCHERS
 | 
			
		||||
 
 | 
			
		||||
@@ -131,7 +131,7 @@ private:
 | 
			
		||||
	
 | 
			
		||||
	int m_pause_state = 0;
 | 
			
		||||
	Range<double> m_playrange{ 0.0,1.0 };
 | 
			
		||||
	
 | 
			
		||||
	int64_t m_rand_count = 0;
 | 
			
		||||
	bool m_stream_end_reached = false;
 | 
			
		||||
	int64_t m_output_silence_counter = 0;
 | 
			
		||||
	File m_curfile;
 | 
			
		||||
 
 | 
			
		||||
@@ -284,6 +284,14 @@ void PaulstretchpluginAudioProcessorEditor::resized()
 | 
			
		||||
	m_parcomps[cpi_freefilter_scaley]->setBounds(xoffs, yoffs, div - 1, 24);
 | 
			
		||||
	xoffs += div;
 | 
			
		||||
	m_parcomps[cpi_freefilter_tilty]->setBounds(xoffs, yoffs, div - 1, 24);
 | 
			
		||||
	xoffs = 1;
 | 
			
		||||
	yoffs += 25;
 | 
			
		||||
	div = w / 3;
 | 
			
		||||
	m_parcomps[cpi_freefilter_randomy_numbands]->setBounds(xoffs, yoffs, div - 1, 24);
 | 
			
		||||
	xoffs += div;
 | 
			
		||||
	m_parcomps[cpi_freefilter_randomy_rate]->setBounds(xoffs, yoffs, div - 1, 24);
 | 
			
		||||
	xoffs += div;
 | 
			
		||||
	m_parcomps[cpi_freefilter_randomy_amount]->setBounds(xoffs, yoffs, div - 1, 24);
 | 
			
		||||
	yoffs += 25;
 | 
			
		||||
	int remain_h = getHeight() - 1 - yoffs;
 | 
			
		||||
	m_spec_order_ed.setBounds(1, yoffs, getWidth() - 2, remain_h / 5 * 1);
 | 
			
		||||
 
 | 
			
		||||
@@ -154,6 +154,9 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
 | 
			
		||||
	addParameter(new AudioParameterFloat("freefilter_shifty_0", "Free filter shift Y", -1.0f, 1.0f, 0.0f)); // 35
 | 
			
		||||
	addParameter(new AudioParameterFloat("freefilter_scaley_0", "Free filter scale Y", -1.0f, 1.0f, 1.0f)); // 36
 | 
			
		||||
	addParameter(new AudioParameterFloat("freefilter_tilty_0", "Free filter tilt Y", -1.0f, 1.0f, 0.0f)); // 37
 | 
			
		||||
	addParameter(new AudioParameterInt("freefilter_randomybands0", "Random bands", 2, 128, 16)); // 38
 | 
			
		||||
	addParameter(new AudioParameterInt("freefilter_randomyrate0", "Random rate", 1, 32, 2)); // 39
 | 
			
		||||
	addParameter(new AudioParameterFloat("freefilter_randomyamount0", "Random amount", 0.0, 1.0, 0.0)); // 40
 | 
			
		||||
	auto& pars = getParameters();
 | 
			
		||||
	for (const auto& p : pars)
 | 
			
		||||
		m_reset_pars.push_back(p->getValue());
 | 
			
		||||
@@ -634,6 +637,9 @@ void PaulstretchpluginAudioProcessor::processBlock (AudioSampleBuffer& buffer, M
 | 
			
		||||
	m_free_filter_envelope->m_transform_y_shift = *getFloatParameter(cpi_freefilter_shifty);
 | 
			
		||||
	m_free_filter_envelope->m_transform_y_scale = *getFloatParameter(cpi_freefilter_scaley);
 | 
			
		||||
	m_free_filter_envelope->m_transform_y_tilt = *getFloatParameter(cpi_freefilter_tilty);
 | 
			
		||||
	m_free_filter_envelope->m_transform_y_random_bands = *getIntParameter(cpi_freefilter_randomy_numbands);
 | 
			
		||||
	m_free_filter_envelope->m_transform_y_random_rate = *getIntParameter(cpi_freefilter_randomy_rate);
 | 
			
		||||
	m_free_filter_envelope->m_transform_y_random_amount = *getFloatParameter(cpi_freefilter_randomy_amount);
 | 
			
		||||
 | 
			
		||||
	m_stretch_source->setMainVolume(*getFloatParameter(cpi_main_volume));
 | 
			
		||||
	m_stretch_source->setRate(*getFloatParameter(cpi_stretchamount));
 | 
			
		||||
 
 | 
			
		||||
@@ -64,6 +64,9 @@ const int cpi_freefilter_shiftx = 34;
 | 
			
		||||
const int cpi_freefilter_shifty = 35;
 | 
			
		||||
const int cpi_freefilter_scaley = 36;
 | 
			
		||||
const int cpi_freefilter_tilty = 37;
 | 
			
		||||
const int cpi_freefilter_randomy_numbands = 38;
 | 
			
		||||
const int cpi_freefilter_randomy_rate = 39;
 | 
			
		||||
const int cpi_freefilter_randomy_amount = 40;
 | 
			
		||||
 | 
			
		||||
class MyPropertiesFile
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,7 @@ along with CDP front-end.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <algorithm>
 | 
			
		||||
#include <random>
 | 
			
		||||
#include "../JuceLibraryCode/JuceHeader.h"
 | 
			
		||||
#include "PS_Source/globals.h"
 | 
			
		||||
 | 
			
		||||
@@ -193,7 +194,10 @@ inline double interpolate_foo(double atime,double t0, double v0, double t1, doub
 | 
			
		||||
class breakpoint_envelope
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    breakpoint_envelope() : m_name("Untitled") {}
 | 
			
		||||
    breakpoint_envelope() : m_name("Untitled") 
 | 
			
		||||
	{
 | 
			
		||||
		m_randbuf.resize(1024);
 | 
			
		||||
	}
 | 
			
		||||
    breakpoint_envelope(String name, double minv=0.0, double maxv=1.0)
 | 
			
		||||
        : m_minvalue(minv), m_maxvalue(maxv), m_name(name)
 | 
			
		||||
    {
 | 
			
		||||
@@ -202,6 +206,7 @@ public:
 | 
			
		||||
        m_defvalue=0.5;
 | 
			
		||||
        m_updateopinprogress=false;
 | 
			
		||||
        m_value_grid={0.0,0.25,0.5,0.75,1.0};
 | 
			
		||||
		m_randbuf.resize(1024);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -567,6 +572,9 @@ public:
 | 
			
		||||
    double m_transform_y_sinus = 0.0;
 | 
			
		||||
    double m_transform_y_sinus_freq = 8.0;
 | 
			
		||||
    double m_transform_y_tilt = 0.0;
 | 
			
		||||
	double m_transform_y_random_amount = 0.2;
 | 
			
		||||
	double m_transform_y_random_rate = 2.0;
 | 
			
		||||
	int m_transform_y_random_bands = 32;
 | 
			
		||||
	bool m_transform_wrap_x = false;
 | 
			
		||||
	double m_min_pt_value = 0.0;
 | 
			
		||||
	double m_max_pt_value = 0.0;
 | 
			
		||||
@@ -589,12 +597,19 @@ public:
 | 
			
		||||
            sin(2*3.141592653*(x-m_transform_x_shift)*m_transform_y_sinus_freq);
 | 
			
		||||
        double tiltline = m_transform_y_tilt-(2.0*m_transform_y_tilt*x);
 | 
			
		||||
        double tilted = shifted+tiltline;
 | 
			
		||||
        return jlimit(0.0,1.0,tilted);
 | 
			
		||||
		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;
 | 
			
		||||
		}
 | 
			
		||||
		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_scale!=1.0 || m_transform_y_sinus!=0.0 || m_transform_y_tilt!=0.0 || m_transform_y_random_amount!=0.0;
 | 
			
		||||
	}
 | 
			
		||||
	void updateMinMaxValues()
 | 
			
		||||
	{
 | 
			
		||||
@@ -608,6 +623,13 @@ public:
 | 
			
		||||
		m_minvalue = minv;
 | 
			
		||||
		m_maxvalue = maxv;
 | 
			
		||||
	}
 | 
			
		||||
	void updateRandomState()
 | 
			
		||||
	{
 | 
			
		||||
		//Logger::writeToLog("updating envelope random state");
 | 
			
		||||
		std::uniform_real_distribution<double> dist(0.0,1.0);
 | 
			
		||||
		for (int i = 0; i < m_transform_y_random_bands+1; ++i)
 | 
			
		||||
			m_randbuf[i] = dist(m_randgen);
 | 
			
		||||
	}
 | 
			
		||||
private:
 | 
			
		||||
    nodes_t m_nodes;
 | 
			
		||||
    double m_playoffset=0.0;
 | 
			
		||||
@@ -625,6 +647,8 @@ private:
 | 
			
		||||
    nodes_t m_old_nodes;
 | 
			
		||||
    nodes_t m_repeater_nodes;
 | 
			
		||||
    grid_t m_value_grid;
 | 
			
		||||
	std::mt19937 m_randgen;
 | 
			
		||||
	std::vector<double> m_randbuf;
 | 
			
		||||
	JUCE_LEAK_DETECTOR(breakpoint_envelope)
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user