Module Pitch.Class

Pitch classes.

In the naming scheme, f stands for flat (♭) and s is for sharp (♯).

Pitch classes

type t = [
  1. | `Cff
    (*

    C♭♭

    *)
  2. | `Cf
    (*

    C

    *)
  3. | `C
    (*

    C

    *)
  4. | `Cs
    (*

    C

    *)
  5. | `Css
    (*

    C♯♯

    *)
  6. | `Dff
    (*

    D♭♭

    *)
  7. | `Df
    (*

    D

    *)
  8. | `D
    (*

    D

    *)
  9. | `Ds
    (*

    D

    *)
  10. | `Dss
    (*

    D♯♯

    *)
  11. | `Eff
    (*

    E♭♭

    *)
  12. | `Ef
    (*

    E

    *)
  13. | `E
    (*

    E

    *)
  14. | `Es
    (*

    E

    *)
  15. | `Ess
    (*

    E♯♯

    *)
  16. | `Fff
    (*

    F♭♭

    *)
  17. | `Ff
    (*

    F

    *)
  18. | `F
    (*

    F

    *)
  19. | `Fs
    (*

    F

    *)
  20. | `Fss
    (*

    F♯♯

    *)
  21. | `Gff
    (*

    G♭♭

    *)
  22. | `Gf
    (*

    G

    *)
  23. | `G
    (*

    G

    *)
  24. | `Gs
    (*

    G

    *)
  25. | `Gss
    (*

    G♯♯

    *)
  26. | `Aff
    (*

    F♭♭

    *)
  27. | `Af
    (*

    A

    *)
  28. | `A
    (*

    A

    *)
  29. | `As
    (*

    A

    *)
  30. | `Ass
    (*

    A♯♯

    *)
  31. | `Bff
    (*

    B♭♭

    *)
  32. | `Bf
    (*

    B

    *)
  33. | `B
    (*

    B

    *)
  34. | `Bs
    (*

    B

    *)
  35. | `Bss
    (*

    B♯♯

    *)
]

The type for pitch classes. The representation is not unique, for example Css (C♯♯) and D are the same pitch class.

val to_int : t -> int

to_int c is c as an integer on a non-modular semitone scale. `C is 0, `Cff is -2 and `Bss is 13. See also to_mod_int.

val to_mod_int : t -> int

to_mod_int c is like to_int but the result is non-negative and modulo 12, `C is 0. Enharmonics like `C and `Bs are mapped to the same integer. See also to_int.

Predicates and comparisons

XXX. Should the default equal and compare be the modular one ?

val equal : t -> t -> bool

equal c0 c1 is true iff to_int c0 = to_int c1. Note that this does not equate enharmonics like `C and `Bs, use mod_equal for that.

val compare : t -> t -> int

compare c0 c1 orders c0 and c1 according to to_int. Note that this does not equate enharmonics like `C and `Bs, use mod_compare for that.

val mod_equal : t -> t -> bool

mod_equal c0 c1 is true iff c0 and c1 represent the same pitch class. Equates enharmonics like `C and `Bs.

val mod_compare : t -> t -> int

mod_compare c0 c1 is a total order on pitches compatible with mod_equal.

Formatters

val pp : Stdlib.Format.formatter -> t -> unit

pp formats pitch classes. Uses the Unicode ♭ and ♯ characters.