Sha256: dd02a225358f03a7bc83e6e94b842c728a351adcb5c70a26338b595ece81082d

Contents?: true

Size: 1.38 KB

Versions: 18

Compression:

Stored size: 1.38 KB

Contents

#include "signals.h"


#include <memory>
#include "beeps/beeps.h"
#include "beeps/exception.h"


namespace Beeps
{


	struct Signals::Data
	{

		std::unique_ptr<stk::StkFrames> frames;

	};// Signals::Data


	stk::StkFrames*
	Signals_get_frames (Signals* signals)
	{
		if (!signals)
			argument_error(__FILE__, __LINE__);

		return signals->self->frames.get();
	}

	const stk::StkFrames*
	Signals_get_frames (const Signals* signals)
	{
		return Signals_get_frames(const_cast<Signals*>(signals));
	}


	Signals::Signals (float seconds, uint channels)
	{
		if (seconds <= 0 || channels <= 0)
			return;

		self->frames.reset(new stk::StkFrames(seconds * sampling_rate(), channels));
	}

	Signals::~Signals ()
	{
	}

	Signals
	Signals::dup () const
	{
		Signals t;
		if (self->frames)
			t.self->frames.reset(new stk::StkFrames(*self->frames));
		return t;
	}

	float
	Signals::seconds () const
	{
		double sec = samples() / (double) sampling_rate();
		return (float) sec;
	}

	uint
	Signals::samples () const
	{
		Data* p = self.get();
		return p ? p->frames->frames() : 0;
	}

	uint
	Signals::channels () const
	{
		Data* p = self.get();
		return p ? p->frames->channels() : 0;
	}

	Signals::operator bool () const
	{
		const stk::StkFrames* f = Signals_get_frames(this);
		return f && f->frames() > 0 && f->channels() > 0;
	}

	bool
	Signals::operator ! () const
	{
		return !operator bool();
	}


}// Beeps

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
beeps-0.1.32 src/signals.cpp
beeps-0.1.31 src/signals.cpp
beeps-0.1.30 src/signals.cpp
beeps-0.1.29 src/signals.cpp
beeps-0.1.28 src/signals.cpp
beeps-0.1.27 src/signals.cpp
beeps-0.1.26 src/signals.cpp
beeps-0.1.25 src/signals.cpp
beeps-0.1.24 src/signals.cpp
beeps-0.1.23 src/signals.cpp
beeps-0.1.22 src/signals.cpp
beeps-0.1.21 src/signals.cpp
beeps-0.1.20 src/signals.cpp
beeps-0.1.18 src/signals.cpp
beeps-0.1.16 src/signals.cpp
beeps-0.1.15 src/signals.cpp
beeps-0.1.14 src/signals.cpp
beeps-0.1.13 src/signals.cpp