# utils/audiomath

AudioMath provides transformations commonly used when handling audio related units.

Source:

### Methods

#### (inner) coefToDB(coef, min, max, reverse, factor) → {number}

Source:

Calculates a value in decibels from a value between 0.0 and 1.0 and some lower and upper boundaries in decibels.

##### Parameters:
Name Type Description
`coef` number

A value between 0.0 and 1.0.

`min` number

The minimum value in decibels.

`max` number

The maximum value in decibels.

`reverse` boolean

If the scale is reversed.

`factor` number

Changes the deflection of the logarithm if other than 1.0.

##### Returns:

The result in decibels.

Type
number

#### (inner) coefToFreq(coef, min, max, reverse, factor) → {number}

Source:

Calculates a value in hertz from a value between 0.0 and 1.0 and some lower and upper boundaries in hertz.

##### Parameters:
Name Type Description
`coef` number

A value between 0.0 and 1.0.

`min` number

The minimum value in hertz.

`max` number

The maximum value in hertz.

`reverse` boolean

If the scale is reversed.

`factor` number

Changes the deflection of the logarithm if other than 1.0.

##### Returns:

The result in hertz.

Type
number

#### (inner) dBToCoef(value, min, max, reverse, factor) → {number}

Source:

Calculates a linear value between 0.0 and 1.0 from a value and its lower and upper boundaries in decibels.

##### Parameters:
Name Type Description
`value` number

The value in decibels.

`min` number

The minimum value in decibels.

`max` number

The maximum value in decibels.

`reverse` boolean

If the scale is reversed.

`factor` number

Changes the deflection of the logarithm if other than 1.0.

##### Returns:

A value between 0.0 (min) and 1.0 (max).

Type
number

#### (inner) dBToGain(value, factoropt)

Source:

Calculates 10^(value / factor). Transforms a dBFS value to the corresponding gain.

##### Parameters:
Name Type Attributes Default Description
`value` number

A decibel value in dBFS.

`factor` number <optional>
`20`

The factor.

#### (inner) dBToScale(value, min, max, reverse, factor) → {number}

Source:

Calculates a linear value between 0.0 and scale. from a value and its lower and upper boundaries in decibels.

##### Parameters:
Name Type Description
`value` number

The value in decibels.

`min` number

The minimum value in decibels.

`max` number

The maximum value in decibels.

`reverse` boolean

If the scale is reversed.

`factor` number

Changes the deflection of the logarithm if other than 1.0.

##### Returns:

A value between 0.0 and scale.

Type
number

#### (inner) freqToCoef(value, min, max, reverse) → {number}

Source:

Calculates a linear value between 0.0 and 1.0 from a value and its lower and upper boundaries in hertz.

##### Parameters:
Name Type Description
`value` number

The value in hertz.

`min` number

The minimum value in hertz.

`max` number

The maximum value in hertz.

`reverse` boolean

If the scale is reversed.

##### Returns:

A value between 0.0 (min) and 1.0 (max).

Type
number

#### (inner) freqToScale(value, min, max, reverse) → {number}

Source:

Calculates a linear value between 0.0 and scale from a value and its lower and upper boundaries in hertz.

##### Parameters:
Name Type Description
`value` number

The value in hertz.

`min` number

The minimum value in hertz.

`max` number

The maximum value in hertz.

`reverse` boolean

If the scale is reversed.

##### Returns:

A value between 0.0 and scale.

Type
number

#### (inner) gainToDB(value, factoropt)

Source:

Calculates factor * log10(value). Transforms a gain value to the corresponding dBFS value.

##### Parameters:
Name Type Attributes Default Description
`value` number

A gain factor.

`factor` number <optional>
`20`

The factor.

#### (inner) scaleToDB(value, min, max, reverse, factor) → {number}

Source:

Calculates a value in decibels from a value between 0.0 and scale and some lower and upper boundaries in decibels.

##### Parameters:
Name Type Description
`value` number

A value between 0.0 and scale.

`min` number

The minimum value in decibels.

`max` number

The maximum value in decibels.

`reverse` boolean

If the scale is reversed.

`factor` number

Changes the deflection of the logarithm if other than 1.0.

##### Returns:

The result in decibels.

Type
number

#### (inner) scaleToFreq(value, min, max, reverse, factor) → {number}

Source:

Calculates a value in hertz from a value between 0.0 and scale and some lower and upper boundaries in hertz.

##### Parameters:
Name Type Description
`value` number

A value between 0.0 and scale.

`min` number

The minimum value in hertz.

`max` number

The maximum value in hertz.

`reverse` boolean

If the scale is reversed.

`factor` number

Changes the deflection of the logarithm if other than 1.0.

##### Returns:

The result in hertz.

Type
number