Double

struct Double

Numeric extension for doubles

  • Get basic value as a double

    Declaration

    Swift

    public func value() -> Double
  • Return a value on [minimum, maximum] to a [0, 1] range, according to a taper

    Declaration

    Swift

    public func normalized(from range: ClosedRange<Double>, taper: Double = 1) -> Double

    Parameters

    to

    Source range (cannot include zero if taper is not positive)

    taper

    For taper > 0, there is an algebraic curve, taper = 1 is linear, and taper < 0 is exponential

  • Return a value on [minimum, maximum] to a [0, 1] range, according to a taper

    Declaration

    Swift

    public func normalized(minimum: Double, maximum: Double, taper: Double = 1) -> Double

    Parameters

    minimum

    Minimum of the source range (cannot be zero if taper is not positive)

    maximum

    Maximum of the source range

    taper

    For taper > 0, there is an algebraic curve, taper = 1 is linear, and taper < 0 is exponential

  • Convert a value on [minimum, maximum] to a [0, 1] range, according to a taper

    Declaration

    Swift

    public mutating func normalize(minimum: Double, maximum: Double, taper: Double = 1)

    Parameters

    minimum

    Minimum of the source range (cannot be zero if taper is not positive)

    maximum

    Maximum of the source range

    taper

    For taper > 0, there is an algebraic curve, taper = 1 is linear, and taper < 0 is exponential

  • Return a value on [0, 1] to a [minimum, maximum] range, according to a taper

    Declaration

    Swift

    public func denormalized(to range: ClosedRange<Double>, taper: Double = 1) -> Double

    Parameters

    to

    Target range (cannot contain zero if taper is not positive)

    taper

    For taper > 0, there is an algebraic curve, taper = 1 is linear, and taper < 0 is exponential

  • Return a value on [0, 1] to a [minimum, maximum] range, according to a taper

    Declaration

    Swift

    public func denormalized(minimum: Double, maximum: Double, taper: Double = 1) -> Double

    Parameters

    minimum

    Minimum of the target range (cannot be zero if taper is not positive)

    maximum

    Maximum of the target range

    taper

    For taper > 0, there is an algebraic curve, taper = 1 is linear, and taper < 0 is exponential

  • Convert a value on [0, 1] to a [min, max] range, according to a taper

    Declaration

    Swift

    public mutating func denormalize(minimum: Double, maximum: Double, taper: Double = 1)

    Parameters

    minimum

    Minimum of the target range (cannot be zero if taper is not positive)

    maximum

    Maximum of the target range

    taper

    For taper > 0, there is an algebraic curve, taper = 1 is linear, and taper < 0 is exponential

  • Calculate frequency from a floating point MIDI Note Number

    Declaration

    Swift

    public func midiNoteToFrequency(_ aRef: Double = 440.0) -> Double

    Parameters

    aRef

    Reference frequency of A Note (Default: 440Hz)

  • Calculate MIDI Note Number from a frequency in Hz

    Declaration

    Swift

    public func frequencyToMIDINote(_ aRef: Double = 440.0) -> Double

    Parameters

    aRef

    Reference frequency of A Note (Default: 440Hz)