-
Notifications
You must be signed in to change notification settings - Fork 164
/
index.html
35 lines (29 loc) · 1.48 KB
/
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
28
29
30
31
32
33
34
35
<!doctype html>
<html>
<head>
<title>Volume Meter Sample</title>
<style>
</style>
<!-- Include the volume meter component -->
<script src="volume-meter.js"></script>
<!-- Include the main app logic -->
<script src="main.js"></script>
</head>
<body>
<p>This sample shows how to implement a clip-indicating volume meter in Web Audio, using a ScriptProcessor. It's necessary to use a ScriptProcessor in order to not miss any clipping samples - otherwise you could implement this using a RealtimeAnalyser to only grab samples when necessary.</p>
<p><button onclick="startMeter();">Start</button></p>
<canvas id="meter" width="500" height="50"></canvas>
<p>Check out the <a href="http://github.com/cwilso/volume-meter/">source on Github</a>.</p>
<p>The usage is quite easy:
<pre>var meter = createAudioMeter(audioContext,clipLevel,averaging,clipLag);
audioContext: the AudioContext you're using.
clipLevel: the level (0 to 1) that you would consider "clipping". Defaults to 0.98.
averaging: how "smoothed" you would like the meter to be over time. Should be between 0 and less than 1. Defaults to 0.95.
clipLag: how long you would like the "clipping" indicator to show after clipping has occured, in milliseconds. Defaults to 750ms.
meter.checkClipping();
returns true if the node has clipped in the last clipLag milliseconds.
meter.shutdown();
used to destroy the node (it's important to disconnect and remove the event handler for any ScriptProcessor).
</pre>
</body>
</html>