Sha256: efab95560b3546a40141e4a0e76f5b8726173a965bb6f5e7e5753d5e85b0c6dc

Contents?: true

Size: 1.56 KB

Versions: 17

Compression:

Stored size: 1.56 KB

Contents

#include "beeps/filter.h"


#include "signalsmith-stretch.h"
#include "signals.h"


namespace Beeps
{


	struct TimeStretch::Data
	{

		signalsmith::stretch::SignalsmithStretch<float> stretch;

		float scale = 1;

	};// TimeStretch::Data


	TimeStretch::TimeStretch (Processor* input)
	:	Super(input)
	{
		set_buffering_seconds(1);
	}

	TimeStretch::~TimeStretch ()
	{
	}

	void
	TimeStretch::reset ()
	{
		Super::reset();

		self->stretch.reset();
	}

	void
	TimeStretch::set_scale (float scale)
	{
		if (scale <= 0)
			argument_error(__FILE__, __LINE__, "'scale' must be greater than 0");

		self->scale = scale;

		set_updated();
	}

	float
	TimeStretch::scale () const
	{
		return self->scale;
	}

	void
	TimeStretch::filter (Context* context, Signals* signals, uint* offset)
	{
		if (self->scale == 1)
			return Super::filter(context, signals, offset);

		uint nsamples  = signals->capacity();
		Signals source = Signals_create(
			nsamples / self->scale, signals->nchannels(), signals->sample_rate());

		Super::filter(context, &source, offset);

		SignalSamples<float> input(source);
		SignalSamples<float> output(
			source.nsamples() < source.capacity()
				?	source.nsamples() * self->scale
				:	nsamples,
			signals->nchannels());

		self->stretch.presetDefault(signals->nchannels(), signals->sample_rate());
		self->stretch.process(
			 input.channels(),  input.nsamples(),
			output.channels(), output.nsamples());

		Signals_write_samples(signals, output);
	}

	TimeStretch::operator bool () const
	{
		if (!Super::operator bool()) return false;
		return self->scale > 0;
	}


}// Beeps

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
beeps-0.3 src/time_stretch.cpp
beeps-0.2.1 src/time_stretch.cpp
beeps-0.2 src/time_stretch.cpp
beeps-0.1.46 src/time_stretch.cpp
beeps-0.1.45 src/time_stretch.cpp
beeps-0.1.44 src/time_stretch.cpp
beeps-0.1.43 src/time_stretch.cpp
beeps-0.1.42 src/time_stretch.cpp
beeps-0.1.41 src/time_stretch.cpp
beeps-0.1.40 src/time_stretch.cpp
beeps-0.1.39 src/time_stretch.cpp
beeps-0.1.38 src/time_stretch.cpp
beeps-0.1.37 src/time_stretch.cpp
beeps-0.1.36 src/time_stretch.cpp
beeps-0.1.35 src/time_stretch.cpp
beeps-0.1.34 src/time_stretch.cpp
beeps-0.1.33 src/time_stretch.cpp