Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. AudioProcessingEvent
  4. inputBuffer

AudioProcessingEvent: inputBuffer property

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see thecompatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

TheinputBuffer read-only property of theAudioProcessingEvent interface represents the input buffer of an audio processing event.

The input buffer is represented by anAudioBuffer object, which contains a collection of audio channels, each of which is an array of floating-point values representing the audio signal waveform encoded as a series of amplitudes. The number of channels and the length of each channel are determined by the channel count and buffer size properties of theAudioBuffer.

Value

AnAudioBuffer object.

Examples

In this example, aScriptProcessorNode is created with a buffer size of 256 samples, 2 input channels, and 2 output channels. When anaudioprocess event is fired, the input and output buffers are retrieved from the event object. The audio data in the input buffer is processed, and the result is written to the output buffer. In this case, the audio data is scaled down by a factor of 0.5.

js
const audioContext = new AudioContext();const processor = audioContext.createScriptProcessor(256, 2, 2);processor.addEventListener("audioprocess", (event) => {  const inputBuffer = event.inputBuffer;  const outputBuffer = event.outputBuffer;  for (let channel = 0; channel < outputBuffer.numberOfChannels; channel++) {    const inputData = inputBuffer.getChannelData(channel);    const outputData = outputBuffer.getChannelData(channel);    // Process the audio data here    for (let i = 0; i < outputBuffer.length; i++) {      outputData[i] = inputData[i] * 0.5;    }  }});processor.connect(audioContext.destination);

Specifications

Specification
Web Audio API
# dom-audioprocessingevent-inputbuffer

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp