Sha256: 19d9f62c7f65062b3a3c14b4c58df91683d08160c07c5f78c2efa6b41db00032

Contents?: true

Size: 1.71 KB

Versions: 4

Compression:

Stored size: 1.71 KB

Contents

#include "beeps/ruby/generator.h"


#include "beeps/ruby/processor.h"
#include "defs.h"


RUCY_DEFINE_WRAPPER_VALUE_FROM_TO(BEEPS_EXPORT, Beeps::Oscillator)

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

#define CHECK RUCY_CHECK_OBJ(Beeps::Oscillator, self)


static
VALUE alloc(VALUE klass)
{
	return value(new Beeps::RubyProcessor<Beeps::Oscillator>, klass);
}

static
VALUE set_type(VALUE self, VALUE type)
{
	CHECK;

	THIS->set_type((Beeps::Oscillator::Type) to<uint>(type));
	return type;
}

static
VALUE get_type(VALUE self)
{
	CHECK;

	return value(THIS->type());
}

static
VALUE set_frequency(VALUE self, VALUE frequency)
{
	CHECK;

	THIS->set_frequency(to<float>(frequency));
	return frequency;
}

static
VALUE get_frequency(VALUE self)
{
	CHECK;

	return value(THIS->frequency());
}


static Class cOscillator;

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

	cOscillator = mBeeps.define_class("Oscillator", Beeps::processor_class());
	rb_define_alloc_func(cOscillator, alloc);
	rb_define_method(cOscillator, "type=", RUBY_METHOD_FUNC(set_type), 1);
	rb_define_method(cOscillator, "type", RUBY_METHOD_FUNC(get_type), 0);
	rb_define_method(cOscillator, "frequency=", RUBY_METHOD_FUNC(set_frequency), 1);
	rb_define_method(cOscillator, "frequency", RUBY_METHOD_FUNC(get_frequency), 0);

	cOscillator.define_const("TYPE_NONE", Beeps::Oscillator::TYPE_NONE);
	cOscillator.define_const("SINE",      Beeps::Oscillator::SINE);
	cOscillator.define_const("TRIANGLE",  Beeps::Oscillator::TRIANGLE);
	cOscillator.define_const("SQUARE",    Beeps::Oscillator::SQUARE);
	cOscillator.define_const("SAWTOOTH",  Beeps::Oscillator::SAWTOOTH);
}


namespace Beeps
{


	Class
	oscillator_class ()
	{
		return cOscillator;
	}


}// Beeps

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
beeps-0.3.3 .doc/ext/beeps/oscillator.cpp
beeps-0.3.2 .doc/ext/beeps/oscillator.cpp
beeps-0.3.1 .doc/ext/beeps/oscillator.cpp
beeps-0.3 .doc/ext/beeps/oscillator.cpp