Skip to content
Permalink
Browse files

initial commit

  • Loading branch information...
Jason Belcher
Jason Belcher committed Jun 29, 2019
0 parents commit 69cf85ce517950b9d3ea8adde74b18c84056fed3
Showing with 219 additions and 0 deletions.
  1. +29 −0 .gitignore
  2. +142 −0 drum-machine.js
  3. +34 −0 package-lock.json
  4. +14 −0 package.json
  5. BIN samples/Deep House Drum Samples/bd_kick/bd_909dwsd.wav
  6. BIN samples/Deep House Drum Samples/bd_kick/bd_chicago.wav
  7. BIN samples/Deep House Drum Samples/bd_kick/bd_dandans.wav
  8. BIN samples/Deep House Drum Samples/bd_kick/bd_deephouser.wav
  9. BIN samples/Deep House Drum Samples/bd_kick/bd_diesel.wav
  10. BIN samples/Deep House Drum Samples/bd_kick/bd_dropped.wav
  11. BIN samples/Deep House Drum Samples/bd_kick/bd_flir.wav
  12. BIN samples/Deep House Drum Samples/bd_kick/bd_gas.wav
  13. BIN samples/Deep House Drum Samples/bd_kick/bd_ghost.wav
  14. BIN samples/Deep House Drum Samples/bd_kick/bd_hybrid.wav
  15. BIN samples/Deep House Drum Samples/bd_kick/bd_isampleoldskool.wav
  16. BIN samples/Deep House Drum Samples/bd_kick/bd_liked.wav
  17. BIN samples/Deep House Drum Samples/bd_kick/bd_mainroom.wav
  18. BIN samples/Deep House Drum Samples/bd_kick/bd_mirror.wav
  19. BIN samples/Deep House Drum Samples/bd_kick/bd_nash.wav
  20. BIN samples/Deep House Drum Samples/bd_kick/bd_newyear.wav
  21. BIN samples/Deep House Drum Samples/bd_kick/bd_organicisin.wav
  22. BIN samples/Deep House Drum Samples/bd_kick/bd_outdoor.wav
  23. BIN samples/Deep House Drum Samples/bd_kick/bd_shoein.wav
  24. BIN samples/Deep House Drum Samples/bd_kick/bd_sodeep.wav
  25. BIN samples/Deep House Drum Samples/bd_kick/bd_sonikboom.wav
  26. BIN samples/Deep House Drum Samples/bd_kick/bd_streek.wav
  27. BIN samples/Deep House Drum Samples/bd_kick/bd_stripped.wav
  28. BIN samples/Deep House Drum Samples/bd_kick/bd_sub808.wav
  29. BIN samples/Deep House Drum Samples/bd_kick/bd_tech.wav
  30. BIN samples/Deep House Drum Samples/bd_kick/bd_tripper.wav
  31. BIN samples/Deep House Drum Samples/bd_kick/bd_uma.wav
  32. BIN samples/Deep House Drum Samples/bd_kick/bd_untitled.wav
  33. BIN samples/Deep House Drum Samples/bd_kick/bd_vintager.wav
  34. BIN samples/Deep House Drum Samples/bd_kick/bd_vinylinstereo.wav
  35. BIN samples/Deep House Drum Samples/clap/clp_analogue.wav
  36. BIN samples/Deep House Drum Samples/clap/clp_applause.wav
  37. BIN samples/Deep House Drum Samples/clap/clp_basics.wav
  38. BIN samples/Deep House Drum Samples/clap/clp_can.wav
  39. BIN samples/Deep House Drum Samples/clap/clp_clap10000.wav
  40. BIN samples/Deep House Drum Samples/clap/clp_classic.wav
  41. BIN samples/Deep House Drum Samples/clap/clp_clipper.wav
  42. BIN samples/Deep House Drum Samples/clap/clp_delma.wav
  43. BIN samples/Deep House Drum Samples/clap/clp_donuts.wav
  44. BIN samples/Deep House Drum Samples/clap/clp_drastik.wav
  45. BIN samples/Deep House Drum Samples/clap/clp_eternity.wav
  46. BIN samples/Deep House Drum Samples/clap/clp_happiness.wav
  47. BIN samples/Deep House Drum Samples/clap/clp_kiddo.wav
  48. BIN samples/Deep House Drum Samples/clap/clp_knowledge.wav
  49. BIN samples/Deep House Drum Samples/clap/clp_kournikova.wav
  50. BIN samples/Deep House Drum Samples/clap/clp_raw.wav
  51. BIN samples/Deep House Drum Samples/clap/clp_scorch.wav
  52. BIN samples/Deep House Drum Samples/clap/clp_socute.wav
  53. BIN samples/Deep House Drum Samples/clap/clp_sustained.wav
  54. BIN samples/Deep House Drum Samples/clap/clp_tayo.wav
  55. BIN samples/Deep House Drum Samples/clap/clp_tense.wav
  56. BIN samples/Deep House Drum Samples/clap/clp_thinlayer.wav
  57. BIN samples/Deep House Drum Samples/clap/clp_verona.wav
  58. BIN samples/Deep House Drum Samples/hats/hat_626.wav
  59. BIN samples/Deep House Drum Samples/hats/hat_ace.wav
  60. BIN samples/Deep House Drum Samples/hats/hat_addverb.wav
  61. BIN samples/Deep House Drum Samples/hats/hat_analog.wav
  62. BIN samples/Deep House Drum Samples/hats/hat_bebias.wav
  63. BIN samples/Deep House Drum Samples/hats/hat_bestfriend.wav
  64. BIN samples/Deep House Drum Samples/hats/hat_bigdeal.wav
  65. BIN samples/Deep House Drum Samples/hats/hat_blackmamba.wav
  66. BIN samples/Deep House Drum Samples/hats/hat_chart.wav
  67. BIN samples/Deep House Drum Samples/hats/hat_charter.wav
  68. BIN samples/Deep House Drum Samples/hats/hat_chipitaka.wav
  69. BIN samples/Deep House Drum Samples/hats/hat_classical.wav
  70. BIN samples/Deep House Drum Samples/hats/hat_classichousehat.wav
  71. BIN samples/Deep House Drum Samples/hats/hat_closer.wav
  72. BIN samples/Deep House Drum Samples/hats/hat_collective.wav
  73. BIN samples/Deep House Drum Samples/hats/hat_crackers.wav
  74. BIN samples/Deep House Drum Samples/hats/hat_critters.wav
  75. BIN samples/Deep House Drum Samples/hats/hat_cuppa.wav
  76. BIN samples/Deep House Drum Samples/hats/hat_darkstar.wav
  77. BIN samples/Deep House Drum Samples/hats/hat_deephouseopen.wav
  78. BIN samples/Deep House Drum Samples/hats/hat_drawn.wav
  79. BIN samples/Deep House Drum Samples/hats/hat_freekn.wav
  80. BIN samples/Deep House Drum Samples/hats/hat_gater.wav
  81. BIN samples/Deep House Drum Samples/hats/hat_glitchbitch.wav
  82. BIN samples/Deep House Drum Samples/hats/hat_hatgasm.wav
  83. BIN samples/Deep House Drum Samples/hats/hat_hattool.wav
  84. BIN samples/Deep House Drum Samples/hats/hat_jelly.wav
  85. BIN samples/Deep House Drum Samples/hats/hat_kate.wav
  86. BIN samples/Deep House Drum Samples/hats/hat_lights.wav
  87. BIN samples/Deep House Drum Samples/hats/hat_lilcloser.wav
  88. BIN samples/Deep House Drum Samples/hats/hat_mydustyhouse.wav
  89. BIN samples/Deep House Drum Samples/hats/hat_myfavouriteopen.wav
  90. BIN samples/Deep House Drum Samples/hats/hat_negative6.wav
  91. BIN samples/Deep House Drum Samples/hats/hat_nice909open.wav
  92. BIN samples/Deep House Drum Samples/hats/hat_niner0niner.wav
  93. BIN samples/Deep House Drum Samples/hats/hat_omgopen.wav
  94. BIN samples/Deep House Drum Samples/hats/hat_openiner.wav
  95. BIN samples/Deep House Drum Samples/hats/hat_original.wav
  96. BIN samples/Deep House Drum Samples/hats/hat_quentin.wav
  97. BIN samples/Deep House Drum Samples/hats/hat_rawsample.wav
  98. BIN samples/Deep House Drum Samples/hats/hat_retired.wav
  99. BIN samples/Deep House Drum Samples/hats/hat_sampleking.wav
  100. BIN samples/Deep House Drum Samples/hats/hat_samplekingdom.wav
  101. BIN samples/Deep House Drum Samples/hats/hat_sharp.wav
  102. BIN samples/Deep House Drum Samples/hats/hat_soff.wav
  103. BIN samples/Deep House Drum Samples/hats/hat_spreadertrick.wav
  104. BIN samples/Deep House Drum Samples/hats/hat_stereosonic.wav
  105. BIN samples/Deep House Drum Samples/hats/hat_tameit.wav
  106. BIN samples/Deep House Drum Samples/hats/hat_vintagespread.wav
  107. BIN samples/Deep House Drum Samples/hats/hat_void.wav
  108. BIN samples/Deep House Drum Samples/percussion/prc_808rimmer.wav
  109. BIN samples/Deep House Drum Samples/percussion/prc_bigdrum.wav
  110. BIN samples/Deep House Drum Samples/percussion/prc_bongodrm.wav
  111. BIN samples/Deep House Drum Samples/percussion/prc_bongorock.wav
  112. BIN samples/Deep House Drum Samples/percussion/prc_boxed.wav
  113. BIN samples/Deep House Drum Samples/percussion/prc_change.wav
  114. BIN samples/Deep House Drum Samples/percussion/prc_clav.wav
  115. BIN samples/Deep House Drum Samples/percussion/prc_congaz.wav
  116. BIN samples/Deep House Drum Samples/percussion/prc_dnthavacowman.wav
  117. BIN samples/Deep House Drum Samples/percussion/prc_drop.wav
  118. BIN samples/Deep House Drum Samples/percussion/prc_emtythepot.wav
  119. BIN samples/Deep House Drum Samples/percussion/prc_flickingabucket.wav
  120. BIN samples/Deep House Drum Samples/percussion/prc_foryoursampler.wav
  121. BIN samples/Deep House Drum Samples/percussion/prc_harmony.wav
  122. BIN samples/Deep House Drum Samples/percussion/prc_hit.wav
  123. BIN samples/Deep House Drum Samples/percussion/prc_home.wav
  124. BIN samples/Deep House Drum Samples/percussion/prc_itgoespop.wav
  125. BIN samples/Deep House Drum Samples/percussion/prc_jungledrummer.wav
  126. BIN samples/Deep House Drum Samples/percussion/prc_knockknock.wav
  127. BIN samples/Deep House Drum Samples/percussion/prc_reworked.wav
  128. BIN samples/Deep House Drum Samples/percussion/prc_rolled.wav
  129. BIN samples/Deep House Drum Samples/percussion/prc_syntheticlav.wav
  130. BIN samples/Deep House Drum Samples/percussion/prc_trainstation.wav
  131. BIN samples/Deep House Drum Samples/percussion/prc_u5510n.wav
  132. BIN samples/Deep House Drum Samples/percussion/prc_vinylshot.wav
  133. BIN samples/Deep House Drum Samples/percussion/prc_virustiatmos.wav
  134. BIN samples/Deep House Drum Samples/percussion/prc_youpanit.wav
  135. BIN samples/Deep House Drum Samples/ride_cymbal/cym_crashtest.wav
  136. BIN samples/Deep House Drum Samples/ride_cymbal/cym_gatecrashed.wav
  137. BIN samples/Deep House Drum Samples/ride_cymbal/ride_8bitdirty.wav
  138. BIN samples/Deep House Drum Samples/ride_cymbal/ride_cymbal1.wav
  139. BIN samples/Deep House Drum Samples/ride_cymbal/ride_full.wav
  140. BIN samples/Deep House Drum Samples/ride_cymbal/ride_jules.wav
  141. BIN samples/Deep House Drum Samples/ride_cymbal/ride_mpc60.wav
  142. BIN samples/Deep House Drum Samples/shaker_tambourine/shaker_bot.wav
  143. BIN samples/Deep House Drum Samples/shaker_tambourine/shaker_broom.wav
  144. BIN samples/Deep House Drum Samples/shaker_tambourine/shaker_command.wav
  145. BIN samples/Deep House Drum Samples/shaker_tambourine/shaker_halfshake.wav
  146. BIN samples/Deep House Drum Samples/shaker_tambourine/shaker_pause.wav
  147. BIN samples/Deep House Drum Samples/shaker_tambourine/shaker_quicky.wav
  148. BIN samples/Deep House Drum Samples/shaker_tambourine/shaker_really.wav
  149. BIN samples/Deep House Drum Samples/shaker_tambourine/tam_christmassy.wav
  150. BIN samples/Deep House Drum Samples/shaker_tambourine/tam_extras.wav
  151. BIN samples/Deep House Drum Samples/shaker_tambourine/tam_hohoho.wav
  152. BIN samples/Deep House Drum Samples/shaker_tambourine/tam_lifein2d.wav
  153. BIN samples/Deep House Drum Samples/shaker_tambourine/tam_mrhat.wav
  154. BIN samples/Deep House Drum Samples/snare/snr_analogging.wav
  155. BIN samples/Deep House Drum Samples/snare/snr_answer8bit.wav
  156. BIN samples/Deep House Drum Samples/snare/snr_bland.wav
  157. BIN samples/Deep House Drum Samples/snare/snr_drm909kit.wav
  158. BIN samples/Deep House Drum Samples/snare/snr_dwreal.wav
  159. BIN samples/Deep House Drum Samples/snare/snr_housey.wav
  160. BIN samples/Deep House Drum Samples/snare/snr_mpc.wav
  161. BIN samples/Deep House Drum Samples/snare/snr_myclassicsnare.wav
  162. BIN samples/Deep House Drum Samples/snare/snr_owned.wav
  163. BIN samples/Deep House Drum Samples/snare/snr_royalty.wav
  164. BIN samples/Deep House Drum Samples/snare/snr_rusnarious.wav
  165. BIN samples/Deep House Drum Samples/snare/snr_truevintage.wav
  166. BIN samples/Deep House Drum Samples/toms/tom_909fatty.wav
  167. BIN samples/Deep House Drum Samples/toms/tom_909onvinyl.wav
  168. BIN samples/Deep House Drum Samples/toms/tom_cleansweep.wav
  169. BIN samples/Deep House Drum Samples/toms/tom_dept.wav
  170. BIN samples/Deep House Drum Samples/toms/tom_discodisco.wav
  171. BIN samples/Deep House Drum Samples/toms/tom_eclipse.wav
  172. BIN samples/Deep House Drum Samples/toms/tom_enriched.wav
  173. BIN samples/Deep House Drum Samples/toms/tom_enrico.wav
  174. BIN samples/Deep House Drum Samples/toms/tom_greatwhite.wav
  175. BIN samples/Deep House Drum Samples/toms/tom_iloveroland.wav
  176. BIN samples/Deep House Drum Samples/toms/tom_madisonave.wav
  177. BIN samples/Deep House Drum Samples/toms/tom_ofalltoms.wav
  178. BIN samples/Deep House Drum Samples/toms/tom_summerdayze.wav
  179. BIN samples/Deep House Drum Samples/toms/tom_taste.wav
  180. BIN samples/Deep House Drum Samples/toms/tom_vsneve.wav
@@ -0,0 +1,29 @@
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

node_modules
@@ -0,0 +1,142 @@
let player = require("play-sound")();

// For each tick in a sequence this object will be checked
// to determine what instruments need
// to be triggered for the current tick.

function DrumMachineState(id) {
this.id = id;
this.kick = {
on: false,
name: "kick",
location: "./samples/Deep House Drum Samples/bd_kick/bd_deephouser.wav"
};
this.clap = {
on: false,
name: "clap",
location: "./samples/Deep House Drum Samples/clap/clp_analogue.wav"
};
this.hat = {
on: false,
name: "hat",
location: "./samples/Deep House Drum Samples/hats/hat_analog.wav"
};
this.shaker = {
on: false,
name: "shaker",
location:
"./samples/Deep House Drum Samples/shaker_tambourine/shaker_bot.wav"
};
this.perc = {
on: false,
name: "perc",
location: "./samples/Deep House Drum Samples/percussion/prc_bongodrm.wav"
};
this.perc2 = {
on: false,
name: "perc2",
location: "./samples/Deep House Drum Samples/percussion/prc_congaz.wav"
};
}

DrumMachineState.prototype.getState = function(name) {
return this[name];
};
DrumMachineState.prototype.setState = function(name, on, volume) {
this[name].on = on;
this[name].volume = volume || 1;
this[name].name = name;
};

// dependency inject the drum machine state into sequencer
function Sequencer(drumMachineState, length) {
this.drumMachineState = drumMachineState;
this.length = length;
this.sequence = [];
}

Sequencer.prototype.initSeq = function() {
for (let i = 0; i < this.length; i += 1) {
this.sequence.push(new this.drumMachineState(i + 1));
}

return this.sequence;
};

// drum machine player
const dm = {
playingSeq: null,
playHead: 0,
tempo: 800,
setTempo: function(tempo, ticksPerBeat = 1) {
let ms;
switch (ticksPerBeat) {
case 1:
ms = 60000 / tempo;
break;
case 2:
ms = 30000 / tempo;
break;
case 4:
ms = 15000 / tempo;
default:
ms = 15000 / tempo;
}
this.tempo = ms;
},
start: function start(initializedSequence) {
this.playingSeq = setInterval(() => {
this.triggerSounds(initializedSequence[this.playHead]);
this.playHead++;
if (this.playHead === initializedSequence.length) {
this.playHead = 0;
}
}, this.tempo);
},
stop: function stop(m) {
if (m === undefined) {
clearInterval(this.playingSeq);
}
setTimeout(() => {
clearInterval(this.playingSeq);
}, m);
},
triggerSounds: function triggerSounds(dmState) {
for (let instrument in dmState) {
if (dmState.hasOwnProperty(instrument)) {
if (dmState[instrument].on) {
console.log(dmState.getState(instrument).location);
player.play(dmState.getState(instrument).location, {
afplay: ["-v", dmState.getState(instrument).volume]
});
}
}
}
}
};

const sequencer = new Sequencer(DrumMachineState, 8);
const seq = sequencer.initSeq();

seq[0].setState("kick", true, 1);
seq[4].setState("kick", true, 0.8);
seq[4].setState("clap", true);
seq[2].setState("hat", true, 0.2);
seq[6].setState("hat", true, 0.24);
seq[0].setState("shaker", true, 0.2);
seq[1].setState("shaker", true, 0.1);
seq[2].setState("shaker", true, 0.2);
seq[3].setState("shaker", true, 0.1);
seq[4].setState("shaker", true, 0.2);
seq[5].setState("shaker", true, 0.1);
seq[6].setState("shaker", true, 0.2);
seq[7].setState("shaker", true, 0.1);
seq[1].setState("perc", true, 0.3);
seq[4].setState("perc", true, 0.4);
seq[5].setState("perc", true, 0.3);
seq[2].setState("perc2", true, 0.3);
seq[3].setState("perc2", true, 0.5);
seq[7].setState("perc2", true, 0.25);

dm.setTempo(127, 4);
dm.start(seq);

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,14 @@
{
"name": "drum-machine-v0.1",
"version": "1.0.0",
"description": "",
"main": "drum-machine.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"play-sound": "^1.1.3"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.