Sha256: fa537ce2817592633742d5f99b227aa7d4691d19e80f13baca0655ca40238d75

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

#include "beeps/ruby/processor.h"


#include <rucy.h>
#include "beeps/exception.h"
#include "defs.h"


using namespace Rucy;


RUCY_DEFINE_VALUE_FROM_TO(Beeps::SquareWave)

#define THIS  to<Beeps::SquareWave*>(self)

#define CHECK RUCY_CHECK_OBJECT(Beeps::SquareWave, self)


static
VALUE alloc(VALUE klass)
{
	return new_type<Beeps::SquareWave>(klass);
}

static
VALUE set_frequency(VALUE self, VALUE frequency)
{
	CHECK;
	THIS->set_frequency(frequency.as_f(true));
	return self;
}

static
VALUE frequency(VALUE self)
{
	CHECK;
	return to<float>(THIS->frequency());
}


static Class cSquareWave;

void
Init_square_wave ()
{
	Module mBeeps = rb_define_module("Beeps");

	cSquareWave = mBeeps.define_class("SquareWave", Beeps::processor_class());
	rb_define_alloc_func(cSquareWave, alloc);
	rb_define_method(cSquareWave, "frequency=", RUBY_METHOD_FUNC(set_frequency), 1);
	rb_define_method(cSquareWave, "frequency", RUBY_METHOD_FUNC(frequency), 0);
}


namespace Beeps
{


	Class
	square_wave_class ()
	{
		return cSquareWave;
	}


}// Beeps

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
beeps-0.1.12 .doc/ext/beeps/square_wave.cpp
beeps-0.1.11 .doc/ext/beeps/square_wave.cpp
beeps-0.1.10 .doc/ext/beeps/square_wave.cpp