Sha256: 6dbda12c054effc66a6160b774b3ff0e7306f8fd87800e809da6d5b700f2e9c4

Contents?: true

Size: 1.32 KB

Versions: 19

Compression:

Stored size: 1.32 KB

Contents

#include "beeps/filter.h"


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


namespace Beeps
{


	struct PitchShift::Data
	{

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

		float shift = 1;

	};// PitchShift::Data


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

	PitchShift::~PitchShift ()
	{
	}

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

		self->stretch.reset();
	}

	void
	PitchShift::set_shift (float shift)
	{
		self->shift = shift;

		set_updated();
	}

	float
	PitchShift::shift () const
	{
		return self->shift;
	}

	void
	PitchShift::filter (Context* context, Signals* signals, uint* offset)
	{
		Super::filter(context, signals, offset);

		if (self->shift == 1 || signals->nsamples() <= 0)
			return;

		SignalSamples<float> input(*signals);
		SignalSamples<float> output(input.nsamples(), signals->nchannels());

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

		Signals_write_samples(signals, output, signals->nsamples());
	}

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


}// Beeps

Version data entries

19 entries across 19 versions & 1 rubygems

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