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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/tabs/basics/sinewave.js
diff --git a/chrome/test/data/extensions/api_test/tabs/basics/sinewave.js b/chrome/test/data/extensions/api_test/tabs/basics/sinewave.js
new file mode 100644
index 0000000000000000000000000000000000000000..d98aa3f129de63c1cc52039c1a1bfbb782afb5a5
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/basics/sinewave.js
@@ -0,0 +1,38 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+window.sinewave = {
+ play: function(win, frequency) {
+ win.sinewaveData_ = win.sinewaveData_ || {};
+ data = win.sinewaveData_;
+
+ if (!data.audioContext) {
+ data.audioContext = new AudioContext();
+ data.gainNode = data.audioContext.createGain();
+ data.gainNode.gain.value = 0.5;
+ data.gainNode.connect(data.audioContext.destination);
+ }
+ if (!data.oscillator ||
+ data.oscillator.frequency.value != frequency) {
+
+ // Note: We recreate the oscillator each time because this switches the
+ // audio frequency immediately. Re-using the same oscillator tends to
+ // take several hundred milliseconds to ramp-up/down the frequency.
+ if (data.oscillator) {
+ data.oscillator.stop();
+ data.oscillator.disconnect();
+ }
+ data.oscillator = data.audioContext.createOscillator();
+ data.oscillator.type = OscillatorNode.SINE;
+ data.oscillator.frequency.value = frequency;
+ data.oscillator.connect(data.gainNode);
+ }
+ data.oscillator.start();
+ },
+
+ stop: function(win) {
+ if (win.sinewaveData_)
+ win.sinewaveData_.oscillator.stop();
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698