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
|
<!DOCTYPE html>
<html>
<head>
<title>
audiobuffer.html
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/webaudio/resources/audit-util.js"></script>
<script src="/webaudio/resources/audit.js"></script>
</head>
<body>
<script id="layout-test-code">
let sampleRate = 44100.0
let lengthInSeconds = 2;
let numberOfChannels = 4;
let audit = Audit.createTaskRunner();
audit.define('Basic tests for AudioBuffer', function(task, should) {
let context = new AudioContext();
let buffer = context.createBuffer(
numberOfChannels, sampleRate * lengthInSeconds, sampleRate);
// Just for printing out a message describing what "buffer" is in the
// following tests.
should(
true,
'buffer = context.createBuffer(' + numberOfChannels + ', ' +
(sampleRate * lengthInSeconds) + ', ' + sampleRate + ')')
.beTrue();
should(buffer.sampleRate, 'buffer.sampleRate').beEqualTo(sampleRate);
should(buffer.length, 'buffer.length')
.beEqualTo(sampleRate * lengthInSeconds);
should(buffer.duration, 'buffer.duration').beEqualTo(lengthInSeconds);
should(buffer.numberOfChannels, 'buffer.numberOfChannels')
.beEqualTo(numberOfChannels);
for (let index = 0; index < buffer.numberOfChannels; ++index) {
should(
buffer.getChannelData(index) instanceof window.Float32Array,
'buffer.getChannelData(' + index +
') instanceof window.Float32Array')
.beTrue();
}
should(
function() {
buffer.getChannelData(buffer.numberOfChannels);
},
'buffer.getChannelData(' + buffer.numberOfChannels + ')')
.throw(DOMException, 'IndexSizeError');
let buffer2 = context.createBuffer(1, 1000, 24576);
let expectedDuration = 1000 / 24576;
should(
buffer2.duration, 'context.createBuffer(1, 1000, 24576).duration')
.beEqualTo(expectedDuration);
task.done();
});
audit.run();
</script>
</body>
</html>
|