Class: RSoxBuffer

Inherits:
Object
  • Object
show all
Defined in:
ext/rsox.c

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object

{{{



330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'ext/rsox.c', line 330

VALUE rsoxbuffer_initialize(int argc, VALUE *argv, VALUE self) {/*{{{*/
  sox_sample_t *buffer;
  VALUE length;
  int llen;

  rb_scan_args(argc, argv, "01", &length);
  llen = NIL_P(length) ? 2048 : NUM2INT(length);
  buffer = ALLOC_N(sox_sample_t, llen);

  rb_iv_set(self, "@buffer", Data_Wrap_Struct(RSoxBuffer, 0, free, buffer));
  rb_iv_set(self, "@length", INT2NUM(llen));

  return self;
}/

Instance Method Details

#[](index) ⇒ Object

{{{



345
346
347
348
349
350
351
352
353
354
# File 'ext/rsox.c', line 345

VALUE rsoxbuffer_at(VALUE self, VALUE index) {/*{{{*/
  sox_sample_t *c_buffer;

  if (index < rb_iv_get(self, "@length")) {
    Data_Get_Struct(self, sox_sample_t, c_buffer);
    return INT2NUM(c_buffer[NUM2INT(index)]);
  }

  return Qnil;
}/

#at(index) ⇒ Object

{{{



345
346
347
348
349
350
351
352
353
354
# File 'ext/rsox.c', line 345

VALUE rsoxbuffer_at(VALUE self, VALUE index) {/*{{{*/
  sox_sample_t *c_buffer;

  if (index < rb_iv_get(self, "@length")) {
    Data_Get_Struct(self, sox_sample_t, c_buffer);
    return INT2NUM(c_buffer[NUM2INT(index)]);
  }

  return Qnil;
}/

#bufferObject

{{{



360
361
362
# File 'ext/rsox.c', line 360

VALUE rsoxbuffer_buffer(VALUE self) {/*{{{*/
  return rb_iv_get(self, "@buffer");
}/

#lengthObject

{{{



356
357
358
# File 'ext/rsox.c', line 356

VALUE rsoxbuffer_length(VALUE self) {/*{{{*/
  return rb_iv_get(self, "@length");
}/

#sizeObject

{{{



356
357
358
# File 'ext/rsox.c', line 356

VALUE rsoxbuffer_length(VALUE self) {/*{{{*/
  return rb_iv_get(self, "@length");
}/