Closed echo66 closed 9 years ago
neu.Sched
receives a function that returns an iterator.
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Iteration_protocols
neu.Sched(function(e) {
var freq = e.count ? 440 : 880;
neu.Synth(Foo, freq, 0.75).start(e.playbackTime);
return {
next: function() {
return {
value: "+" + (e.count + 2) + "n",
done: false
};
};
};
}).start().stop("+10");
I'm going to redesign neume.js in the near future. Maybe, the specification for scheduling will be changed.
thanks for the clarification, mohayonao!
I just noticed one thing: the function that returns the "next" does not have access to the "e.count".
In sched.js, we have this in line 87:
var result = _this._schedIter.next();
There is no object passed as argument to both "next" and "_schedIter".
_schedIter.next()
should return an iteration object that contains duration for next schedule.
e.g.
var result = _this._schedIter.next();
// result
{ value: 0.5, done: false } // run next schedule after 500ms
For sure, this specification is awkward to use. Maybe, I will change this specification.
Well, it is awkward. Maybe that is the reason why I got confuse.
Still, thanks for the quick reply! :)
Greetings!
I'm trying to run the following code:
but, unfortunately, the browser throws the following error: neume.js:1216 Uncaught TypeError: undefined is not a function