Skip to content

Instantly share code, notes, and snippets.

@s3thi
Created January 12, 2016 08:40
Show Gist options
  • Save s3thi/e94e198c6e8ba7aa3635 to your computer and use it in GitHub Desktop.
Save s3thi/e94e198c6e8ba7aa3635 to your computer and use it in GitHub Desktop.
sampler.js – GainNode
playSample() {
let bufferSource = this.audioContext.createBufferSource();
bufferSource.buffer = this.audioBuffer;
bufferSource.playbackRate.value = this.playbackRate;
let gainNode = this.audioContext.createGain();
gainNode.gain.value = this.gain;
bufferSource.connect(gainNode);
gainNode.connect(this.audioContext.destination);
bufferSource.start(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment