-
Notifications
You must be signed in to change notification settings - Fork 3
/
jamsetting.js
57 lines (40 loc) · 1.63 KB
/
jamsetting.js
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
// how many bars do we want to draw? Max of 128.
var bars = 128, hue=320;
// add the bar elements to the container div:
for (var i=0; i<bars; i++) {
var bar = document.createElement("div");
bar.className = "bar";
container.appendChild(bar);
}
// create a new JAM instance:
var jam = new JustAddMusic({
// default audio to load:
paused:true,
deltaT:150,
avgT:150,
// label text to include in the UI (bottom left)
volume:0,
// set the number of spectrum values we'd like to get back:
spectrumBins: bars,
// the ontick callback, called 60 time per second by default
// with the latest audio data object as the only parameter
ontick: function(o) {
// change the base hue value on a bass hit:
if (o.low.hit) { hue = (hue+100)%360; }
for (var i=0; i<bars; i++) {
// update bars based on the spectrum values:
var style = container.childNodes[i].style, val = o.spectrum[i];
style.height = val*20+"%";
style.background = "hsl("+ (hue-val*180) +","+ (val*50+50) +"%,"+ (val*40+20) +"%)";
}
}
});
setTimeout(function(){
jam.loadAudio(ap.audio.currentSrc);
$(".aplayer-list").click(function(){
ap.volume(0, true);
setTimeout(function(){jam.loadAudio(ap.audio.currentSrc);console.log(ap.audio.currentSrc)},500);
setTimeout(function(){ap.play();ap.seek(0);jam.seek(0);ap.volume(1, true)},4000);
});
console.log(ap.audio.currentSrc)},1500);
console.log("\n %c JustAddMusic 30b23c7 %c https://github.com/gskinner/JustAddMusic \n", "color: #fadfa3; background: #030307; padding:5px 0;", "background: #fadfa3; padding:5px 0;")