Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

flow code added, segfaults in the usual example

  • Loading branch information...
commit 033884d62ff0641bbc35065e068c6951706c7d90 1 parent a375d7a
@substack authored
Showing with 36 additions and 6 deletions.
  1. +13 −5 play.js
  2. +23 −0 src/chain.hpp
  3. +0 −1  src/effect.hpp
View
18 play.js
@@ -1,12 +1,20 @@
-var sox = require('./build/Release/format');
+var sox = require('./build/Release/sox');
var Format = sox.Format;
var Signal = sox.Signal;
var Effect = sox.Effect;
+var Chain = sox.Chain;
-var fmt = new Format;
-fmt.readFile('test.wav');
-var sig = new Signal(fmt.getSignal());
+var rf = new Format;
+rf.readFile('test.wav');
+
+var sig = new Signal(rf.getSignal());
var wf = new Format;
-var e = new Effect('input', ['test.wav']);
//wf.play(sig, 'alsa');
wf.play(sig);
+
+var c = new Chain(rf, wf);
+c.addEffect(new Effect('input', ['test.wav']), rf, rf);
+c.addEffect(new Effect('rate', []), rf, wf);
+c.addEffect(new Effect('channels', []), rf, wf);
+c.addEffect(new Effect('output', ['rawk.wav']), rf, wf);
+c.flow();
View
23 src/chain.hpp
@@ -22,6 +22,7 @@ class Chain : public ObjectWrap {
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
constructor_template->SetClassName(String::NewSymbol("Chain"));
NODE_SET_PROTOTYPE_METHOD(constructor_template, "addEffect", AddEffect);
+ NODE_SET_PROTOTYPE_METHOD(constructor_template, "flow", Flow);
target->Set(
String::NewSymbol("Chain"),
@@ -59,6 +60,28 @@ class Chain : public ObjectWrap {
) == SOX_SUCCESS);
return args.This();
}
+
+ static Handle<Value> Flow(const Arguments &args) {
+ HandleScope scope;
+ Chain *c = ObjectWrap::Unwrap<Chain>(args.This());
+ void *data = (void *) c->chain;
+ eio_custom(eio_flow, EIO_PRI_DEFAULT, eio_flow_after, data);
+ ev_ref(EV_DEFAULT_UC);
+ c->Ref();
+ return Undefined();
+ }
+
+ static void eio_flow (eio_req *ereq) {
+ sox_effects_chain_t *chain = (sox_effects_chain_t *) ereq->data;
+ sox_flow_effects(chain, NULL, NULL);
+ sox_delete_effects_chain(chain);
+ }
+
+ static int eio_flow_after (eio_req *ereq) {
+ HandleScope scope;
+ ev_unref(EV_DEFAULT_UC);
+ return 0;
+ }
};
Persistent<FunctionTemplate> Chain::constructor_template;
View
1  src/effect.hpp
@@ -46,7 +46,6 @@ class Effect : public ObjectWrap {
for (unsigned int i = 0; i < 10 && i < xs->Length(); i++) {
argv[i] = *String::Utf8Value(xs->Get(Integer::New(i)));
}
-
sox_effect_options(e->effect, xs->Length(), argv);
e->Wrap(args.This());
Please sign in to comment.
Something went wrong with that request. Please try again.