theHarmonicAlgorithm-3.0.0: Real-time harmonic progression generation for TidalCycles live performance
Safe HaskellSafe-Inferred
LanguageHaskell2010

Harmonic.Rules.Types.Pitch

Description

This module defines PitchClass as a proper cyclic group with modular arithmetic. All pitch operations automatically wrap within the octave.

Academic Lineage

Data Science In The Creative Process (South, 2018): the MusicData module's pitch-class algebra, where pitch classes are treated as elements of ℤ₁₂ with modular arithmetic operations.

Design

This module sits in the Rules (R) layer: the ℤ₁₂ algebra is part of the language the system's validity rules are written in. (R, E and T describe the creative system as a whole, not individual types — transposition and interval measurement here are algebra, and become traversal or evaluation only in the layers that use them for those purposes.)

Pitch classes are elements of ℤ₁₂, the integers modulo 12:

  • Addition: transposition
  • Subtraction: interval measurement
  • Identity: unison (0)
  • Inverse: octave complement
Synopsis

Core Types

newtype PitchClass Source #

PitchClass represents an element of ℤ₁₂, the cyclic group of integers mod 12. The Num instance ensures all arithmetic automatically wraps to [0..11].

Constructors

P 

Fields

Instances

Instances details
Bounded PitchClass Source #

Bounded instance: pitch classes range from 0 to 11

Instance details

Defined in Harmonic.Rules.Types.Pitch

Enum PitchClass Source #

Enum instance provides cyclic enumeration

Instance details

Defined in Harmonic.Rules.Types.Pitch

Generic PitchClass Source # 
Instance details

Defined in Harmonic.Rules.Types.Pitch

Associated Types

type Rep PitchClass :: Type -> Type #

Num PitchClass Source #

Num instance implements ℤ₁₂ group operations. All operations automatically wrap modulo 12.

Instance details

Defined in Harmonic.Rules.Types.Pitch

Read PitchClass Source #

Read instance handles legacy DB format "P 0" (with space after P)

Instance details

Defined in Harmonic.Rules.Types.Pitch

Integral PitchClass Source #

Integral instance for compatibility with legacy code

Instance details

Defined in Harmonic.Rules.Types.Pitch

Real PitchClass Source # 
Instance details

Defined in Harmonic.Rules.Types.Pitch

Show PitchClass Source #

Show instance matches legacy format for DB compatibility: "P 0" not P0

Instance details

Defined in Harmonic.Rules.Types.Pitch

Eq PitchClass Source # 
Instance details

Defined in Harmonic.Rules.Types.Pitch

Ord PitchClass Source # 
Instance details

Defined in Harmonic.Rules.Types.Pitch

type Rep PitchClass Source # 
Instance details

Defined in Harmonic.Rules.Types.Pitch

type Rep PitchClass = D1 ('MetaData "PitchClass" "Harmonic.Rules.Types.Pitch" "theHarmonicAlgorithm-3.0.0-1Jyc2qhqYzxBLoiBHPE0av" 'True) (C1 ('MetaCons "P" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPitchClass") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

mkPitchClass :: Int -> PitchClass Source #

Smart constructor ensuring values stay in [0..11]

Enharmonic Note Names

data NoteName Source #

All standard enharmonic note names within an octave

Constructors

C 
C' 
Db 
D 
D' 
Eb 
E 
F 
F' 
Gb 
G 
G' 
Ab 
A 
A' 
Bb 
B 

Instances

Instances details
Bounded NoteName Source # 
Instance details

Defined in Harmonic.Rules.Types.Pitch

Enum NoteName Source # 
Instance details

Defined in Harmonic.Rules.Types.Pitch

Read NoteName Source # 
Instance details

Defined in Harmonic.Rules.Types.Pitch

Show NoteName Source #

Custom Show instance: renders sharp notation C' as C#, D' as D#, etc. (matches legacy behavior and musical convention)

Instance details

Defined in Harmonic.Rules.Types.Pitch

Eq NoteName Source # 
Instance details

Defined in Harmonic.Rules.Types.Pitch

Ord NoteName Source # 
Instance details

Defined in Harmonic.Rules.Types.Pitch

pitchClass :: NoteName -> PitchClass Source #

Extract pitch class from a note name

notesToPCs :: [NoteName] -> [Int] Source #

Convert a list of NoteNames to pitch-class integers Useful for defining chord progressions with note names

sharp :: PitchClass -> NoteName Source #

Map pitch class to sharp enharmonic spelling

flat :: PitchClass -> NoteName Source #

Map pitch class to flat enharmonic spelling

enharmFromNoteName :: NoteName -> PitchClass -> NoteName Source #

Helper function for mapping NoteName to enharmonic function. This determines whether to use sharp or flat spelling based on the root note of a chord (for consistent enharmonic spelling). Ported from legacy MusicData.hs

Transposition (Group Action)

transpose :: Int -> PitchClass -> PitchClass Source #

Transpose a pitch class by an interval (group addition)

interval :: PitchClass -> PitchClass -> PitchClass Source #

Calculate the interval between two pitch classes (group subtraction) Returns the ascending interval from first to second.

invert :: PitchClass -> PitchClass Source #

Invert a pitch class (octave complement) The inverse of n is (12 - n) mod 12

Utilities

allPitchClasses :: [PitchClass] Source #

All 12 pitch classes

pcSet :: [Int] -> [PitchClass] Source #

Convert a list of integers to a set of unique pitch classes

zeroForm :: [Int] -> [PitchClass] Source #

Normalize a pitch set to start from zero (transposition-invariant form) Ported from legacy MusicData.hs