Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: chrome/test/data/extensions/api_test/tabs/basics/sinewave.js

Issue 987583004: Add audible, muted to Tab, c.t.query, c.t.update, and c.t.onUpdated where relevant (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch1
Patch Set: rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 window.sinewave = {
6 play: function(win, frequency) {
7 win.sinewaveData_ = win.sinewaveData_ || {};
8 data = win.sinewaveData_;
9
10 if (!data.audioContext) {
11 data.audioContext = new AudioContext();
12 data.gainNode = data.audioContext.createGain();
13 data.gainNode.gain.value = 0.5;
14 data.gainNode.connect(data.audioContext.destination);
15 }
16 if (!data.oscillator ||
17 data.oscillator.frequency.value != frequency) {
18
19 // Note: We recreate the oscillator each time because this switches the
20 // audio frequency immediately. Re-using the same oscillator tends to
21 // take several hundred milliseconds to ramp-up/down the frequency.
22 if (data.oscillator) {
23 data.oscillator.stop();
24 data.oscillator.disconnect();
25 }
26 data.oscillator = data.audioContext.createOscillator();
27 data.oscillator.type = OscillatorNode.SINE;
28 data.oscillator.frequency.value = frequency;
29 data.oscillator.connect(data.gainNode);
30 }
31 data.oscillator.start();
32 },
33
34 stop: function(win) {
35 if (win.sinewaveData_)
36 win.sinewaveData_.oscillator.stop();
37 }
38 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698