-
Notifications
You must be signed in to change notification settings - Fork 0
/
one.html
74 lines (60 loc) · 2.06 KB
/
one.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
</head>
<body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src='remix.js'></script>
<script type="text/javascript">
// First-beat extraction and assembly
// You will need to supply your Echo Nest API key, the trackID, and a URL to the track.
// The supplied track can be found in the audio subdirectory.
var apiKey = 'GWRU3T1ZZ0D0FDZRI';
var trackID = 'TRCYWPQ139279B3308';
var trackURL = 'test.mp3'
var remixer;
var player;
var track;
var remixed;
function init() {
var contextFunction = window.AudioContext || window.webkitAudioContext;
if (contextFunction === undefined) {
$("#info").text("Sorry, this app needs advanced web audio. Your browser doesn't"
+ " support it. Try the latest version of Chrome?");
} else {
var context = new contextFunction();
remixer = createJRemixer(context, $, apiKey);
player = remixer.getPlayer();
$("#info").text("Loading analysis data...");
remixer.remixTrackById(trackID, trackURL, function(t, percent) {
track = t;
$("#info").text(percent + "% of the track loaded");
if (percent == 100) {
$("#info").text(percent + "% of the track loaded, remixing...");
}
if (track.status == 'ok') {
remixed = new Array();
// Do the remixing here!
for (var i=0; i < track.analysis.beats.length; i++) {
remixed.push(track.analysis.beats[i])
console.log(remixed[i].track.audio_summary.duration);
}
$("#info").text("Remix complete!");
}
});
}
/*for(var i = 0; i <remixed.length; i++)
{
console.log(remixed[i]);
//$("#info").text("im in the loop");
} */
}
window.onload = init;
</script>
Welcome to One.html
<div id='info'> </div>
<button onClick="player.play(0, remixed);">Play!</button>
<button onClick="player.stop()">Stop!</button>
</body>
</html>