-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
67 lines (56 loc) · 1.74 KB
/
index.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
58
59
60
61
62
63
64
65
66
67
import AudioStore from './lib/audiostore.js';
import StreamCoordinator from './lib/streamcoordinator.js';
import Player from './lib/player.js';
const el = document.querySelector('.player');
const ac = new ( window.AudioContext || window.webkitAudioContext )();
const store = new AudioStore( ac );
const logs = document.querySelector('.logs');
const fdrs = document.querySelector('.faders');
const info = console.info;
const urls = [
'audio/1901_bass.mp3',
'audio/1901_drumsleft.mp3',
'audio/1901_drumsright.mp3',
'audio/1901_gtr1.mp3',
'audio/1901_gtr2.mp3',
'audio/1901_keys.mp3',
'audio/1901_leadvox.mp3',
'audio/1901_siren.mp3',
'audio/1901_synth1.mp3',
'audio/1901_synth2.mp3',
'audio/1901_triggers.mp3',
'audio/1901_voxfx.mp3'
];
const streamer = new StreamCoordinator( urls, store );
console.info = str => {
requestAnimationFrame( () => {
const pre = document.createElement('pre');
pre.textContent = `${ str }\n`;
logs.appendChild( pre );
logs.scrollTop = Math.pow( 2, 53 ) - 1;
info.call( console, str );
});
};
// initialize the database
await store.init();
// load all audio assets
await streamer.load();
// set up the player
window.player = new Player( el, streamer );
window.player.seek( 3 );
urls.forEach( ( url, i ) => {
const name = url.split('_').pop().split('.').shift();
const inp = document.createElement('input');
const lab = document.createElement('label');
lab.textContent = name;
inp.type = 'range';
inp.min = 0;
inp.max = 100;
inp.value = 50;
streamer.streamers[ i ].gain.gain.value = 0.5;
inp.addEventListener( 'input', () => {
streamer.streamers[ i ].gain.gain.value = inp.value / 100;
});
lab.appendChild( inp );
fdrs.appendChild( lab );
});