-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
27 lines (22 loc) · 862 Bytes
/
index.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
<!-- run npm update to test with this example -->
<script src="node_modules/tiny-sample-loader/dist/tiny-sample-loader.js"></script>
<script src="dist/audio-buffer-instrument.js"></script>
<script>
var ctx = new AudioContext();
var remoteUrl = 'https://oramics.github.io/sampled/DM/TR-909/SP/samples/hihat-open-2.wav';
var hihatPromise = tinySampleLoader(remoteUrl, ctx);
hihatPromise.then(function (value) {
var instrument = new audioBufferInstrument(ctx, value);
// Trigger
instrument.trigger(1);
var audioBuf = instrument.get();
audioBuf.connect(ctx.destination);
audioBuf.start(2);
// In this way you don't need to reload the buffer source
var audioBuf = instrument.get();
audioBuf.connect(ctx.destination);
audioBuf.start(3);
}).catch(function (value) {
console.log(value); // error message
})
</script>