Skip to content

Commit

Permalink
testing beat switching
Browse files Browse the repository at this point in the history
  • Loading branch information
sagangwee committed Oct 12, 2015
1 parent 4879f42 commit 011dd2a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<script>
// Create a new instance of an audio object and adjust some of its properties
var audio = new Audio();
audio.src = 'rap-app-slow-instrumental-1.mp3';
audio.src = 'rap-app-instrumental/freestyle_rap.mp3';
audio.controls = true;
audio.loop = true;
audio.autoplay = false;
Expand All @@ -35,6 +35,31 @@

}

Kendrickbtn = document.getElementById("Kendrick");
Drakebtn = document.getElementById("Drake");
Colebtn = document.getElementById("Cole");
Kanyebtn = document.getElementById("Kanye");

Kendrickbtn.addEventListener("click", beat("Kendrick"));
Drakebtn.addEventListener("click", beat("Drake"));
Colebtn.addEventListener("click", beat("Cole"));
Kanyebtn.addEventListener("click", beat("Kanye"));

function beat(name) {
if (name === "Kendrick") {
audio.src = 'rap-app-instrumental/money_trees.mp3'
} else if (name === "Drake") {
audio.src = 'rap-app-instrumental/back_to_back.mp3'
} else if (name === "Cole") {
audio.src = 'rap-app-instrumental/slow.mp3'
} else if (name === "Kanye") {
audio.src = 'rap-app-instrumental/medium'
}
if (audio.paused) {
audio.play();
}
}

context = new webkitAudioContext(); // AudioContext object instance
analyser = context.createAnalyser(); // AnalyserNode method
canvas = document.getElementById('analyser_render');
Expand Down
Binary file added rap_app_instrumentals/back_to_back.mp3
Binary file not shown.
Binary file added rap_app_instrumentals/freestyle_rap.mp3
Binary file not shown.
Binary file added rap_app_instrumentals/medium.mp3
Binary file not shown.
Binary file added rap_app_instrumentals/money_trees.mp3
Binary file not shown.
Binary file added rap_app_instrumentals/slow.mp3
Binary file not shown.

0 comments on commit 011dd2a

Please sign in to comment.