Basic Types

  • Periodic vibration in Hertz.

    Example Usage

    let nice = Frequency(440.0) // => "a 440"
    let mean: Frequency = 440.0 // => "a 440"
    
    See more

    Declaration

    Swift

    public struct Frequency : NewType, SignedNumeric
  • Floating point analog to the MIDI note number.

    Similarly to the MIDI note number, middle c is represented as 60. Each octave is represented by a distance of 12, thus 48 is the c below middle c, and 72 is the c above middle c.

    Example Usage

    let warm = NoteNumber(60)
    let cold: NoteNumber = 60
    
    See more

    Declaration

    Swift

    public struct NoteNumber:
        NewType,
        Comparable,
        SignedNumeric,
        ExpressibleByFloatLiteral,
        ExpressibleByIntegerLiteral
  • The quality of a sound governed by the rate of vibrations producing it.

    A Pitch is represented by a NoteNumber value. If offers an interface to represent this NoteNumber as a Frequency given different tuning conventions.

    Example Usage

    let middle = Pitch(60) // => middle c
    let high = Pitch(84) // => two octaves above middle c
    let lower = Pitch(69) // => a 440
    
    See more

    Declaration

    Swift

    public struct Pitch : NoteNumberRepresentable
  • Ordered sequence of pitch intervals.

    A Scale may or may not be octave invariant, and it may or may not be infinitely protracting.

    Example Usage

    let cMajor: Scale = [0,2,4,5,7,9,11]
    let cSharpWholeTone = Scale(1, [2,2,2,2,2,2])
    let gHarmonicMinor = Scale(7, .harmonicMinor)
    
    See more

    Declaration

    Swift

    public struct Scale
  • Collection of pitches.

    Example usage

    let cMajor: Chord = [60,64,67]
    let gMinor: Chord = [67,70,74]
    
    See more

    Declaration

    Swift

    public struct Chord