Skip to content

Instantly share code, notes, and snippets.

@beefchimi
Last active October 22, 2017 23:39
Show Gist options
  • Save beefchimi/d19dac9ca6e55ef28b22171f5c1e0068 to your computer and use it in GitHub Desktop.
Save beefchimi/d19dac9ca6e55ef28b22171f5c1e0068 to your computer and use it in GitHub Desktop.
Web Audio common method patch
const methodPatch = {
start(source) {
return (source.start) ? source.start : (startTime = 0) => source.noteOn(startTime);
},
stop(source) {
return (source.stop) ? source.stop : (stopTime = 0) => source.noteOff(stopTime);
},
};
export default methodPatch;
// later on... we alias our methods
this.source.start = methodPatch.start(this.source);
this.source.stop = methodPatch.stop(this.source);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment