Class: RSox
- Inherits:
-
Object
- Object
- RSox
- Defined in:
- ext/rsox.c
Class Method Summary collapse
-
.count ⇒ Object
{{{.
-
.new ⇒ Object
{{{.
Instance Method Summary collapse
-
#buffer_size ⇒ Object
{{{.
-
#buffer_size=(bufsize) ⇒ Object
{{{.
-
#chain(input, output) ⇒ Object
{{{.
-
#format_init ⇒ Object
{{{.
-
#format_quit ⇒ Object
{{{.
-
#initialize ⇒ Object
constructor
{{{.
-
#open_read(*args) ⇒ Object
{{{.
-
#open_write(*args) ⇒ Object
{{{.
Constructor Details
#initialize ⇒ Object
{{{
40 41 42 43 44 45 46 47 48 |
# File 'ext/rsox.c', line 40
VALUE rsox_initialize(VALUE self) {/*{{{*/
int *instance_count;
Data_Get_Struct(self, int, instance_count);
if (*instance_count == 1)
sox_init();
return self;
}/
|
Class Method Details
.count ⇒ Object
{{{
36 37 38 |
# File 'ext/rsox.c', line 36
VALUE rsox_count(VALUE class) {/*{{{*/
return rb_iv_get(class, "@count");
}/
|
.new ⇒ Object
{{{
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'ext/rsox.c', line 23
VALUE rsox_new(VALUE class) {/*{{{*/
static int rsox_instance_count = 0;
VALUE instance_num;
rsox_instance_count++;
instance_num = Data_Wrap_Struct(RSox, 0, rsox_destroy, &rsox_instance_count);
rb_iv_set(class, "@instance_count", INT2NUM(rsox_instance_count));
rb_obj_call_init(instance_num, 0, 0);
return instance_num;
}/
|
Instance Method Details
#buffer_size ⇒ Object
{{{
56 57 58 |
# File 'ext/rsox.c', line 56
VALUE rsox_get_bufsize(VALUE self) {/*{{{*/
return INT2FIX(sox_globals.bufsiz);
}/
|
#buffer_size=(bufsize) ⇒ Object
{{{
50 51 52 53 54 |
# File 'ext/rsox.c', line 50
VALUE rsox_set_bufsize(VALUE self, VALUE bufsize) {/*{{{*/
sox_globals.bufsiz = FIX2INT(bufsize);
return Qtrue;
}/
|
#chain(input, output) ⇒ Object
{{{
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
# File 'ext/rsox.c', line 386
VALUE rsox_effectschain(VALUE self, VALUE input, VALUE output) {/*{{{*/
sox_format_t *c_input, *c_output;
sox_effects_chain_t *c_chain;
VALUE chain;
Data_Get_Struct(input, sox_format_t, c_input);
Data_Get_Struct(output, sox_format_t, c_output);
c_chain = sox_create_effects_chain(&c_input->encoding, &c_output->encoding);
chain = Data_Wrap_Struct(RSoxEffectsChain, 0, rsoxeffectschain_free, c_chain);
rb_iv_set(chain, "@input", input);
rb_iv_set(chain, "@output", output);
rb_iv_set(self, "@chain", chain);
return chain;
}/
|
#format_init ⇒ Object
{{{
60 61 62 63 |
# File 'ext/rsox.c', line 60
VALUE rsox_format_init(VALUE self) {/*{{{*/
int i = sox_format_init();
return INT2NUM(i);
}/
|
#format_quit ⇒ Object
{{{
65 66 67 68 |
# File 'ext/rsox.c', line 65
VALUE rsox_format_quit(VALUE self) {/*{{{*/
sox_format_quit();
return Qnil;
}/
|
#open_read(*args) ⇒ Object
{{{
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'ext/rsox.c', line 74
VALUE rsox_open_read(int argc, VALUE *argv, VALUE self) {/*{{{*/
VALUE path, signal, encoding, filetype;
sox_signalinfo_t *c_signal = NULL;
sox_encodinginfo_t *c_encoding = NULL;
sox_format_t *c_format;
rb_scan_args(argc, argv, "13", &path, &signal, &encoding, &filetype);
if (!NIL_P(signal)) Data_Get_Struct(signal, sox_signalinfo_t, c_signal);
if (!NIL_P(encoding)) Data_Get_Struct(encoding, sox_encodinginfo_t, c_encoding);
c_format = sox_open_read(StringValuePtr(path), c_signal, c_encoding, filetype == Qnil ? NULL : StringValuePtr(filetype));
return Data_Wrap_Struct(RSoxFormat, 0, rsox_format_close, c_format);
}/
|
#open_write(*args) ⇒ Object
{{{
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'ext/rsox.c', line 94
VALUE rsox_open_write(int argc, VALUE *argv, VALUE self) {/*{{{*/
VALUE path, signal, encoding, filetype, oob;
sox_signalinfo_t *c_signal = NULL;
sox_encodinginfo_t *c_encoding = NULL;
sox_oob_t *c_oob = NULL;
sox_format_t *c_format;
rb_scan_args(argc, argv, "14", &path, &signal, &encoding, &filetype, &oob);
if (signal != Qnil) Data_Get_Struct(signal, sox_signalinfo_t, c_signal);
if (encoding != Qnil) Data_Get_Struct(encoding, sox_encodinginfo_t, c_encoding);
if (oob != Qnil) Data_Get_Struct(oob, sox_oob_t, c_oob);
c_format = sox_open_write(StringValuePtr(path),
c_signal,
c_encoding,
filetype == Qnil ? NULL : StringValuePtr(filetype),
c_oob,
rb_block_given_p() ? rsox_overwrite_callback : NULL);
return Data_Wrap_Struct(RSoxFormat, 0, 0, c_format);
}/
|