Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- drumInit(4);
- });
- function drumInit(count){
- var samples = [];
- for(i = 0; i < count; i++) {
- sample = new Audio('sample-' + i + '.wav');
- samples.push(sample);
- }
- samples[2].volume = .3;
- samples[3].volume = .4;
- $(document).keydown(function(e){
- switch(e.which) {
- case 90:
- samples[0].play();
- break;
- case 88:
- samples[2].play();
- break;
- case 67:
- samples[1].play();
- break;
- case 86:
- samples[3].play();
- break;
- default: return;
- }
- e.preventDefault();
- });
- }
- case 90:
- samples[0].play();
- if(samples[0].playing) {
- samples[0].pause();
- samples[0].ended;
- samples[0].play();
- }
- break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement