GO-V.ORG
As seen in

ConstantSourceNode: ConstantSourceNode() constructor

Web Audio API

Web Audio API

The **`ConstantSourceNode()`** constructor creates a new
ConstantSourceNode object instance, representing an audio source which
constantly outputs samples whose values are always the same.

## Syntax

```js-nolint
new ConstantSourceNode(context)
new ConstantSourceNode(context, options)
```

### Parameters

- `context`
- : An AudioContext representing the audio context you want the node to
be associated with.
- `options`
- : A `ConstantSourceOptions` dictionary object defining the properties you
want the `ConstantSourceNode` to have:
- `offset`
- : A floating-point number specifying the initial value of the offset AudioParam, which determines the constant value generated by the source. The default is 1.0. The value must be finite.

## Examples

In this example, an audio context is created, then a `ConstantSourceNode` is
established with its `offset` initialized to 0.5.

```js
let audioContext = new AudioContext();

let myConstantSource = new ConstantSourceNode(audioContext, { offset: 0.5 });
```

> [!NOTE]
> The new `ConstantSourceNode` created by the
> constructor has a
> [`channelCount`](/docs/Web/API/AudioNode/channelCount) of
> 2\.

## Specifications

## Browser compatibility

source: MDN Web Docs mirror · page

Cite this

"ConstantSourceNode: ConstantSourceNode() constructor". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/ConstantSourceNode/ConstantSourceNode

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·