# utils/audiomath

AudioMath provides transformations commonly used when handling audio related units.

Source:

### Methods

#### (inner) coef2db(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) coef2freq(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) db2coef(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) db2gain(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) db2scale(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) freq2coef(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) freq2scale(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) gain2db(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) scale2db(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) scale2freq(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