-
Notifications
You must be signed in to change notification settings - Fork 14
/
test.js
58 lines (47 loc) · 1.01 KB
/
test.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
'use strict';
const play = require('./')
const lena = require('audio-lena/buffer')
const AudioBuffer = require('audio-buffer')
const assert = require('assert')
const context = require('audio-context')()
const t = require('tape')
const load = require('audio-loader')
t('lena', t => {
let samples = new Float32Array(lena)
let buf = new AudioBuffer(context, {numberOfChannels: 1, length: samples.length});
buf.getChannelData(0).set(samples)
let playback = play(buf, {
start: 1.2,
end: 1.29,
volume: .5,
loop: true,
rate: 2
}, () => {
console.log('end');
});
//TODO
// setInterval(() => {
// playback.rate *= 1.5
// }, 10)
setTimeout(() => {
let play = playback.pause();
assert(playback.currentTime);
setTimeout(() => {
playback.play();
}, 500);
setTimeout(() => {
playback.pause();
t.end()
}, 1000);
}, 500);
})
t('long sample file', t => {
let loaded = false
load('./soundtest.wav', (err, buf) => {
if (loaded) return
loaded = true
play(buf, e => {
t.end()
})
})
})