Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 763427 of Web Audio Editor

  • Revision slug: Tools/Web_Audio_Editor
  • Revision title: Web Audio Editor
  • Revision id: 763427
  • Created:
  • Creator: wbamberg
  • Is current revision? No
  • Comment
Tags: 

Revision Content

With the Web Audio API, developers create an {{domxref ("AudioContext", "audio context")}}. Within that context they then construct a number of {{domxref ("AudioNode", "audio nodes")}}, including:

Each node has zero or more {{domxref ("AudioParam")}} properties that configure its operation. For example, the {{domxref ("GainNode")}} has a single gain property, while the {{domxref ("OscillatorNode")}} has frequency and detune properties.

The developer connects the nodes in a graph, and the complete graph defines the behavior of the audio stream.

The Web Audio Editor examines an audio context constructed in the page and provides a visualization of its graph. This gives you a high-level view of its operation, and enables you to ensure that all the nodes are connected in the way you expect. You can then examine and edit the AudioParam properties for each node in the graph. Some non-AudioParam properties, like an OscillatorNode's type property, are displayed, and you can edit these as well.

This tool is still experimental. If you find bugs, we'd love it if you filed them in Bugzilla. If you have feedback or suggestions for new features, ffdevtools.uservoice.com or Twitter are great places to register them.

Opening the Web Audio Editor

The Web Audio Editor is not enabled by default in Firefox 32. To enable it, open the Developer Tool Settings and check "Web Audio". Now there should be an extra tab in the Toolbox toolbar labeled "Web Audio". Click the tab and load a page that constructs an audio context. Two good demos are:

  • the Voice-change-O-Matic, which can apply various effects to the microphone input and also provides a visualisation of the result
  • the Violent Theremin, which changes the pitch and volume of a sine wave as you move the mouse pointer

Visualizing the graph

The Web Audio Editor will now display the graph for the loaded audio context. Here's the graph for the Violent Theremin demo:

You can see that it uses three nodes: an {{domxref ("OscillatorNode")}} as the source, a {{domxref ("GainNode")}} to control the volume, and an {{domxref ("GainNode")}} as the destination.

Connections to AudioParams

Displaying connections to AudioParams is new in Firefox 34.

Connections between nodes are displayed as solid lines. If, instead, you've connected a node to an AudioParam in another node, then the connection is shown as a dashed line between the nodes, and is labeled with the name of the AudioParam:

Inspecting and modifying AudioNodes

If you click on a node, it's highlighted and you get a node inspector on the right hand side. This list the values of that node's AudioParam properties. For example, here's what the OscillatorNode looks like:

With the Violent Theremin demo, the frequency parameter is modified as the user moves the mouse left and right, and you can see this reflected in the node inspector. However, the value isn't updated in real time: you have to click the node again to see the updated value.

If you click on a value in the node inspector you can modify it: press Enter or Tab and the new value takes effect immediately.

Bypassing nodes

New in Firefox 38.

In the pane that shows you the node's details, there's an on/off button:

Click it, and the graph will be modified to bypass this node, so it will no longer have any effect. Nodes that are bypassed are show with a hatched background:

Revision Source

<p>With the <a href="/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API">Web Audio API</a>, developers create an {{domxref ("AudioContext", "audio context")}}. Within that context they then construct a number of {{domxref ("AudioNode", "audio nodes")}}, including:</p>

<ul>
 <li>nodes providing the <a href="/en-US/docs/Web/API/Web_Audio_API#Defining_audio_sources">audio source</a>, such as an oscillator or a data buffer source</li>
 <li>nodes performing <a href="/en-US/docs/Web/API/Web_Audio_API#Defining_audio_effects_filters">transformations</a> such as delay and gain</li>
 <li>nodes representing the <a href="/en-US/docs/Web/API/Web_Audio_API#Defining_audio_destinations">destination of the audio stream</a>, such as the speakers</li>
</ul>

<p>Each node has zero or more {{domxref ("AudioParam")}} properties that configure its operation. For example, the {{domxref ("GainNode")}} has a single <code>gain</code> property, while the {{domxref ("OscillatorNode")}} has <code>frequency</code> and <code>detune</code> properties.</p>

<p>The developer connects the nodes in a graph, and the complete graph defines the behavior of the audio stream.</p>

<p>The Web Audio Editor examines an audio context constructed in the page and provides a visualization of its graph. This gives you a high-level view of its operation, and enables you to ensure that all the nodes are connected in the way you expect. You can then examine and edit the <code>AudioParam</code> properties for each node in the graph. Some non-<code>AudioParam</code> properties, like an <code>OscillatorNode</code>'s <code>type</code> property, are displayed, and you can edit these as well.</p>

<p>This tool is still experimental. If you find bugs, we'd love it if you <a class="external external-icon" href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox&amp;component=Developer%20Tools%3A%20Web%20Audio%20Editor">filed them in Bugzilla</a>. If you have feedback or suggestions for new features, <a href="https://ffdevtools.uservoice.com/forums/246087-firefox-developer-tools-ideas">ffdevtools.uservoice.com</a> or <a href="https://twitter.com/firefoxdevtools">Twitter</a> are great places to register them.</p>

<h2 id="Opening_the_Web_Audio_Editor">Opening the Web Audio Editor</h2>

<p>The Web Audio Editor is not enabled by default in Firefox 32. To enable it, open the <a href="/en-US/docs/Tools/Tools_Toolbox#Settings_2">Developer Tool Settings</a> and check "Web Audio". Now there should be an extra tab in the <a href="/en-US/docs/Tools/Tools_Toolbox#Toolbar">Toolbox toolbar</a> labeled "Web Audio". Click the tab and load a page that constructs an audio context. Two good demos are:</p>

<ul>
 <li>the <a href="https://github.com/mdn/voice-change-o-matic">Voice-change-O-Matic</a>, which can apply various effects to the microphone input and also provides a visualisation of the result</li>
 <li>the <a href="https://mdn.github.io/violent-theremin/">Violent Theremin</a>, which changes the pitch and volume of a sine wave as you move the mouse pointer</li>
</ul>

<h2 id="Visualizing_the_graph">Visualizing the graph</h2>

<p>The Web Audio Editor will now display the graph for the loaded audio context. Here's the graph for the Violent Theremin demo:</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/10171/web-audio-editor.png" style="display: block; margin-left: auto; margin-right: auto; width: 868px; height: 648px;" />You can see that it uses three nodes: an {{domxref ("OscillatorNode")}} as the source, a {{domxref ("GainNode")}} to control the volume, and an {{domxref ("GainNode")}} as the destination.</p>

<h3 id="Connections_to_AudioParams">Connections to AudioParams</h3>

<div class="geckoVersionNote">
<p>Displaying connections to AudioParams is new in Firefox 34.</p>
</div>

<p>Connections between nodes are displayed as solid lines. If, instead, you've <a href="/en-US/docs/Web/API/AudioNode.connect%28AudioParam%29">connected a node to an AudioParam in another node</a>, then the connection is shown as a dashed line between the nodes, and is labeled with the name of the <code>AudioParam</code>:<img alt="" src="https://mdn.mozillademos.org/files/8819/web%20audio-editor-connect-param.png" style="display: block; margin-left: auto; margin-right: auto;" /></p>

<h2 id="Inspecting_and_modifying_AudioNodes">Inspecting and modifying AudioNodes</h2>

<p>If you click on a node, it's highlighted and you get a node inspector on the right hand side. This list the values of that node's <code>AudioParam</code> properties. For example, here's what the OscillatorNode looks like:</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/10173/web-audio-editor-props.png" style="display: block; margin-left: auto; margin-right: auto; width: 868px; height: 648px;" />With the Violent Theremin demo, the frequency parameter is modified as the user moves the mouse left and right, and you can see this reflected in the node inspector. However, the value isn't updated in real time: you have to click the node again to see the updated value.</p>

<p>If you click on a value in the node inspector you can modify it: press <kbd>Enter</kbd> or <kbd>Tab</kbd> and the new value takes effect immediately.</p>

<h2 id="Bypassing_nodes">Bypassing nodes</h2>

<div class="geckoVersionNote">
<p>New in Firefox 38.</p>
</div>

<p>In the pane that shows you the node's details, there's an on/off button:</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/10183/web-audio-editor-on-off.png" style="width: 316px; height: 97px; display: block; margin-left: auto; margin-right: auto;" />Click it, and the graph will be modified to bypass this node, so it will no longer have any effect. Nodes that are bypassed are show with a hatched background:</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/10181/web-audio-editor-bypassed.png" style="width: 348px; height: 74px; display: block; margin-left: auto; margin-right: auto;" /></p>
Revert to this revision