~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to ManualTests/webaudio/limit-level-0db.html

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html>
 
2
<html>
 
3
<head>
 
4
    <title>Web Audio Sample</title>
 
5
    <script>
 
6
        var context = new webkitAudioContext();
 
7
        var gainNode = context.createGainNode();
 
8
        gainNode.connect(context.destination);
 
9
        gainNode.gain.value = 2;
 
10
 
 
11
        var frequency = 1000;
 
12
        var duration = 1000;
 
13
    
 
14
        function playNormal() {
 
15
            var oscillator = context.createOscillator();
 
16
            oscillator.frequency.value = frequency;
 
17
            oscillator.type = 0;
 
18
            oscillator.connect(context.destination);
 
19
            oscillator.noteOn(0);
 
20
            setTimeout(function(){ oscillator.disconnect(); }, duration);
 
21
        }
 
22
        
 
23
        function playLoud() {
 
24
            var oscillator = context.createOscillator();
 
25
            oscillator.frequency.value = frequency;
 
26
            oscillator.type = 0;
 
27
            oscillator.connect(gainNode);
 
28
            oscillator.noteOn(0);
 
29
            setTimeout(function(){ oscillator.disconnect(); }, duration);
 
30
        }
 
31
    </script>
 
32
</head>
 
33
<body>
 
34
    <p>
 
35
        This tests that output audio is clamped to 0db maximum.  Press each button below in turn.  The apparent volume for both should be equal, even though the second button plays with 2x gain of the first. The resulting waveforms are not equal, however, as the second button audio is clipped to a square wave shape.
 
36
    </p>
 
37
    <button onclick="playNormal()">normal volume</button><button onclick="playLoud()">double volume</button>
 
38
</body>
 
39
</html>