Util

object Util

This is a helper object containing utility functions for common math operations and constants

This is a helper object containing utility functions for common math operations and constants

class Object
trait Matchable
class Any

Value members

Concrete methods

def ampDb(linear: Double): Double

Linear-to-Decibel conversion

Linear-to-Decibel conversion

Value Params
linear

volume linear

Returns

volume in decibals, such that linearToDB( 2.0 ) returns c. +6

def calcEnergy(a: Array[Double], off: Int, length: Int): Double

Calculates energy of a signal (sum(x*x)).

Calculates energy of a signal (sum(x*x)).

def dbAmp(dB: Double): Double

Decibel-to-Linear conversion.

Decibel-to-Linear conversion.

Value Params
dB

volume in decibels

Returns

volume linear, such that dBToLinear( -6 ) returns c. 0.5

def log2(value: Double): Double

Calculates the logarithm with base 2.

Calculates the logarithm with base 2.

Value Params
value

the input value

Returns

the log2 of the value

def nextPowerOfTwo(value: Int): Int

Calculates an integer that is a power of two and is equal or greater than a given integer

Calculates an integer that is a power of two and is equal or greater than a given integer

Value Params
value

the minimum value to return

Returns

an integer 2^n which is equal or greater than x

Concrete fields

final val Ln10: Double

logarithmus naturalis of 10

logarithmus naturalis of 10

final val Ln2: Double

logarithmus naturalis of 2

logarithmus naturalis of 2

final val Pi2: 6.283185307179586d

2 * Pi (Outline of the unit circle)

2 * Pi (Outline of the unit circle)