AudioNode
=========

A interface AudioNode é uma interface genérica para representar um módulo de processamento como uma fonte de áudio (ex. um elemento HTML `<audio>` ou `<video>` , um `OscillatorNode` (en-US), etc.), um destino do áudio, um módulo intermediário de processamento (ex. um filtro como `BiquadFilterNode` ou `ConvolverNode` (en-US)), ou um controle de volume (como o `GainNode` (en-US)).

![AudioNodes participating in an AudioContext create a audio routing graph.](/pt-BR/docs/Web/API/AudioNode/webaudiobasicspt-br.png)

Um `AudioNode` tem entradas (inputs) e saídas (outputs), cada uma delas com uma determinada quantidade de canais. Um `AudioNode` sem nenhuma entrada e uma ou múltiplas saídas é chamado de *source node*. The exact processing done varies from one `AudioNode` to another but, in general, a node reads its inputs, does some audio-related processing, and generates new values for its outputs, or simply lets the audio pass through (for example in the `AnalyserNode` (en-US), where the result of the processing is accessed separately).

Different nodes can be linked together to build a *processing graph*. Such a graph is contained in an `AudioContext`. Each `AudioNode` participates in exactly one such context. In general, processing nodes inherit the properties and methods of `AudioNode`, but also define their own functionality on top. See the individual node pages for more details, as listed on the Web Audio API homepage.

**Nota:** An `AudioNode` can be target of events, therefore it implements the `EventTarget` interface.

Properties
----------

`AudioNode.context` (en-US) Somente leitura 

Returns the associated `AudioContext`, that is the object representing the processing graph the node is participating in.

`AudioNode.numberOfInputs` (en-US) Somente leitura 

Returns the number of inputs feeding the node. Source nodes are defined as nodes having a `numberOfInputs` property with a value of `0`.

`AudioNode.numberOfOutputs` (en-US) Somente leitura 

Returns the number of outputs coming out of the node. Destination nodes — like `AudioDestinationNode` (en-US) — have a value of `0` for this attribute.

`AudioNode.channelCount` (en-US)

Represents an integer used to determine how many channels are used when up-mixing and down-mixing (en-US) connections to any inputs to the node. Its usage and precise definition depend on the value of `AudioNode.channelCountMode` (en-US).

`AudioNode.channelCountMode` (en-US)

Represents an enumerated value describing the way channels must be matched between the node's inputs and outputs.

`AudioNode.channelInterpretation` (en-US)

 Represents an enumerated value describing the meaning of the channels. This interpretation will define how audio up-mixing and down-mixing (en-US) will happen.
 The possible values are `"speakers"` or `"discrete"`.


Methods
-------

*Also implements methods from the interface* `EventTarget`.

`AudioNode.connect(AudioNode)` (en-US)

Allows us to connect one output of this node to one input of another node.

`AudioNode.connect(AudioParam)`

Allows us to connect one output of this node to one input of an audio parameter.

`AudioNode.disconnect()` (en-US)

Allows us to disconnect the current node from another one it is already connected to.

Example
-------

This simple snippet of code shows the creation of some audio nodes, and how the `AudioNode` properties and methods can be used. You can find examples of such usage on any of the examples linked to on the Web Audio API landing page (for example Violent Theremin.)


```js
var AudioContext = window.AudioContext || window.webkitAudioContext;

var audioCtx = new AudioContext();

var oscillator = audioCtx.createOscillator();
var gainNode = audioCtx.createGain();

oscillator.connect(gainNode);
gainNode.connect(audioCtx.destination);

oscillator.context;
oscillator.numberOfInputs;
oscillator.numberOfOutputs;
oscillator.channelCount;
```

Specifications
--------------

| Specification |
| --- |
| Web Audio API # AudioNode |

Compatibilidade com navegadores
-------------------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* Using the Web Audio API (en-US)