forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudiobuffersource-negative-playbackrate-loop.html
50 lines (41 loc) · 1.45 KB
/
audiobuffersource-negative-playbackrate-loop.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<title>audiobuffersource-negative-playbackrate-loop</title>
<script src="../resources/js-test.js"></script>
<script src="resources/audio-testing.js"></script>
<script src="resources/audiobuffersource-testing-legacy.js"></script>
<script>
var sampleRate = 44100.0;
var sourceFrames = 128;
var renderFrames = 10;
var testSpacingFrames = 0;
var startLoop = 100 / sampleRate;
var loopDuration = (renderFrames / 2) / sampleRate;
var endLoop = startLoop + loopDuration;
var tests = [{
description:"Test looping playback at -1 playbackRate",
offsetFrame:0,
renderFrames:renderFrames,
expected:[104, 103, 102, 101, 100, 104, 103, 102, 101, 100],
}];
function go() {
jsTestIsAsync = true;
context = new OfflineAudioContext(1, renderFrames, sampleRate);
var bufferSource = context.createBufferSource();
bufferSource.buffer = createRamp(context, 0, 127, sourceFrames);
bufferSource.connect(context.destination);
bufferSource.playbackRate.value = -1;
bufferSource.loop = true;
bufferSource.loopStart = startLoop;
bufferSource.loopEnd = endLoop;
bufferSource.start(0, startLoop, loopDuration);
bufferSource.stop(loopDuration * 2);
context.oncomplete = checkAllTests;
context.startRendering();
}
</script>
</head>
<body onload="go()">
</body>
</html>