Closed davidgovea closed 13 years ago
Currently you can do audioLib.Generator(myGenerator[, prototype=myGenerator.prototype]);
or audioLib.Effect(myEffect[, prototype=myEffect.prototype]);
to inherit the respective class, it will also take into account the existing prototype, as you described. It will also attach it to audioLib.effects
or audioLib.generators
. These are actually exactly the same functions audioLib uses internally for the inheritance.
But I'm also thinking of another thing, being a dedicated Plugin API. The purpose of that would be to serve the needs of the Audio Workers, for which audioLib automatically injects the audioLib code to the worker. The Plugin API would allow plugins to be loaded to audio workers as well. I'm thinking something like this, where audioLib plugins would be created inside named closures:
(function myPluginInitializer(){
// the plugin code
audioLib.Plugin('myPlugin', myPluginInitializer);
}());
Hmm I must be missing something.. it appears to me that the Generator/Effect functions you described are wrapped in immediately-invoked functions: wrapper-end.js, lines 120, 148
I need to read up on audio workers.
Oops, sorry, I remembered it wrong, it's audioLib.generators(name, constructor[, prototype])
and effects respectively! But yeah, the closures are there just to make the code smaller and not to pollute the namespace, but the functionality is available to outside as well.
doh! I see now.
Feature request - Plugin API
It would be great to have an easy to use way to load plugins.
Features
For example: audioLib.extend(name, class, prototype, type) //where type is "Generator", "Effect", null