Class AudioBuffer
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The AudioBuffer interface represents a short audio asset residing in memory, created from an audio file using the BaseAudioContextdecodeAudioData method, or from raw data using BaseAudioContextcreateBuffer. Once put into an AudioBuffer, the audio can then be played by being passed into an AudioBufferSourceNode.
[Value("AudioBuffer")]
public class AudioBuffer
- Inheritance
-
AudioBuffer
- Inherited Members
Remarks
Objects of these types are designed to hold small audio snippets, typically less than 45 s. For longer sounds, objects implementing the MediaElementAudioSourceNode are more suitable. The buffer contains the audio signal waveform encoded as a series of amplitudes in the following format: non-interleaved IEEE754 32-bit linear PCM with a nominal range between -1 and +1, that is, a 32-bit floating point buffer, with each sample between -1.0 and 1.0. If the AudioBuffer has multiple channels, they are stored in separate buffers.
Constructors
AudioBuffer()
public AudioBuffer()
AudioBuffer(AudioBufferOptions)
The AudioBuffer constructor of
the Web Audio API creates a new
AudioBuffer object.
public AudioBuffer(AudioBufferOptions options)
Parameters
optionsAudioBufferOptions
Remarks
Properties
Duration
The duration property of the AudioBuffer interface returns a double representing the duration, in seconds, of the PCM data stored in the buffer.
[Value("duration")]
public Number Duration { get; }
Property Value
- Number
A double.
Remarks
Length
The length property of the AudioBuffer
interface returns an integer representing the length, in sample-frames, of the PCM data
stored in the buffer.
[Value("length")]
public ulong Length { get; }
Property Value
- ulong
An integer.
Remarks
NumberOfChannels
The numberOfChannels property of the AudioBuffer
interface returns an integer representing the number of discrete audio channels
described by the PCM data stored in the buffer.
[Value("numberOfChannels")]
public ulong NumberOfChannels { get; }
Property Value
- ulong
An integer.
Remarks
SampleRate
The sampleRate property of the AudioBuffer interface returns a float representing the sample rate, in samples per second, of the PCM data stored in the buffer.
[Value("sampleRate")]
public Number SampleRate { get; }
Property Value
- Number
A floating-point value indicating the current sample rate of the buffers data, in
samples per second.
Remarks
Methods
CopyFromChannel(Float32Array, ulong, ulong)
ThecopyFromChannel() method of the
AudioBuffer interface copies the audio sample data from the specified
channel of the AudioBuffer to a specified
Float32Array.
[Value("copyFromChannel")]
public GlobalObject.Undefined CopyFromChannel(Float32Array destination, ulong channelNumber, ulong bufferOffset = 0)
Parameters
destinationFloat32ArraychannelNumberulongbufferOffsetulong
Returns
Remarks
CopyToChannel(Float32Array, ulong, ulong)
The copyToChannel() method of the AudioBuffer interface copies
the samples to the specified channel of the AudioBuffer, from the source array.
[Value("copyToChannel")]
public GlobalObject.Undefined CopyToChannel(Float32Array source, ulong channelNumber, ulong bufferOffset = 0)
Parameters
sourceFloat32ArraychannelNumberulongbufferOffsetulong
Returns
Remarks
GetChannelData(ulong)
The getChannelData() method of the AudioBuffer Interface returns a {{jsxref("Float32Array")}} containing the PCM data associated with the channel, defined by the channel parameter (with 0 representing the first channel).
[Value("getChannelData")]
public Float32Array GetChannelData(ulong channel)
Parameters
channelulong