Class: NoyesC::Preemphasizer

Inherits:
Object
  • Object
show all
Defined in:
lib/cext/preemphasis.c

Instance Method Summary collapse

Constructor Details

#initializeObject


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cext/preemphasis.c', line 11

static VALUE t_init(VALUE self, VALUE args) {
  int len = RARRAY_LEN(args);
  double factor = 0.97;
  if (len > 0) {
     factor = NUM2DBL(rb_ary_entry(args, 0));
  }
  Preemphasizer *pre = new_preemphasizer(factor);
  VALUE prev = Data_Wrap_Struct(cPreemphasizer, 0, _preemphasizer_free, pre);
  rb_iv_set(self, "@preemphasizer", prev);
  return self;
}

Instance Method Details

#<<Object


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cext/preemphasis.c', line 23

static VALUE t_left_shift(VALUE self, VALUE obj) {
  Carr *M = r2carr(obj);
  Preemphasizer *pre;
  VALUE prev = rb_iv_get(self, "@preemphasizer");
  Data_Get_Struct(prev, Preemphasizer, pre);
  Carr *N = preemphasizer_apply(pre, M);
  VALUE result = carr2r(N);
  carr_free(N);
  carr_free(M);
  return result;
}