Skip to main content

fromFloatToByte

function fromFloatToByte(value): number;

Convert a float to byte, according to web audio spec

Floating point audio sample number is defined as: non-interleaved IEEE754 32-bit linear PCM with a nominal range between -1 and +1, that is, 32bits floating point buffer, with each samples between -1.0 and 1.0 https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer

Byte samples are represented as follows: 128 is silence, 0 is negative max, 256 is positive max

Parameters

ParameterTypeDescription
valuenumberThe float value to convert to byte

Returns

number

Remarks

Ref. https://www.w3.org/TR/webaudio/#dom-analysernode-getbytetimedomaindata