initial experiment with drumplayer (

This commit is contained in:
Eric Rosenbaum 2017-01-10 11:35:03 -05:00
parent 85489d8a95
commit 193a9f181b
2 changed files with 21 additions and 2 deletions

16
src/DrumPlayer.js Normal file
View file

@ -0,0 +1,16 @@
var SoundPlayer = require('./SoundPlayer');
var Tone = require('tone');
function DrumPlayer (outputNode) {
this.outputNode = outputNode;
this.snare = new SoundPlayer(this.outputNode);
var snareUrl = 'https://raw.githubusercontent.com/LLK/scratch-audio/develop/sound-files/drums/SnareDrum(1)_22k.wav';
this.snare.setBuffer(new Tone.Buffer(snareUrl));
}
DrumPlayer.prototype.start = function () {
this.snare.start();
};
module.exports = DrumPlayer;

View file

@ -12,6 +12,7 @@ var ReverbEffect = require('./effects/ReverbEffect');
var SoundPlayer = require('./SoundPlayer');
var ADPCMSoundLoader = require('./ADPCMSoundLoader');
var InstrumentPlayer = require('./InstrumentPlayer');
var DrumPlayer = require('./DrumPlayer');
function AudioEngine () {
@ -36,6 +37,8 @@ function AudioEngine () {
this.currentTempo = 60;
this.instrumentPlayer = new InstrumentPlayer(this.input);
this.drumPlayer = new DrumPlayer(this.input);
}
AudioEngine.prototype.createPlayer = function () {
@ -119,8 +122,8 @@ AudioPlayer.prototype.playNoteForBeats = function (note, beats) {
return this.waitForBeats(beats);
};
AudioPlayer.prototype.playDrumForBeats = function (beats) {
// this.drumSamplers[drumNum].triggerAttack();
AudioPlayer.prototype.playDrumForBeats = function (drum, beats) {
this.audioEngine.drumPlayer.start();
return this.waitForBeats(beats);
};