Frequencies and Ratios

Overview

Pitches and intervals can also be expressed as physical frequencies and freqency ratios, respectively. We provide wrappers around Float64 that represent log frequencies and log freqency ratios, and perform arithmetic with and without octave equivalence. There are two versions of each constructor depending on whether you provide log or non-log values. All values are printed as non-log. Pitch and interval classes are printed in brackets to indicate that they are representatives of an equivalence class.

julia> freqi(3/2)
fr1.5

julia> logfreqi(log(3/2))
fr1.5

julia> freqic(3/2)
fr[1.5]

julia> freqp(441)
441.0Hz

julia> freqpc(441)
[1.7226562500000004]Hz

Because of the use of floats, rounding errors can occur:

julia> freqp(440)
439.99999999999983Hz

You can use Julia's builtin method isapprox/ to test for approximate equality:

julia> freqp(220) + freqi(2) ≈ freqp(440)
true

Reference

Types

Pitches.FreqIntervalType
FreqInterval <: Interval

A frequency ratio interval. Is internally represented by the logarithm of the frequency ratio, so conversion to Float64 will return a log-frequency ratio!

source
Pitches.FreqICType
FreqIC <: Interval

A frequency ratio interval class. Is internally represented by the logarithm of the frequency ratio, so conversion to Float64 will return a log-frequency ratio! Maintains octave equivalence.

source

Constructors

octave equivalenttakes logintervalpitch
nonofreqifreqp
yeslogfreqilogfreqp
yesnofreqicfreqpc
yeslogfreqiclogfreqpc
Pitches.freqiFunction
freqi(ratio)

Creates a frequency ratio interval from a frequency ratio.

source
Pitches.freqicFunction
freqic(ratio)

Creates a frequency ratio interval class from a frequency ratio.

source