module Music.Abc (
AbcFile(..),
FileHeader(..),
Element(..),
AbcTune(..),
TuneHeader(..),
TuneBody(..),
Music(..),
Note(..),
DecorationT(..),
SlurT(..),
BeamT(..),
GraceT(..),
TupletT(..),
DurationT(..),
RestT(..),
(:|:),
Duration(..),
PitchClass(..),
Accidental(..),
Octave(..),
Pitch(..),
Decoration(..),
Barline(..),
MultiRest(..),
Information(..),
Directive(..),
readAbc,
showAbc
) where
import Network.URI (URI)
data AbcFile
= AbcFile
(Maybe String)
(Maybe FileHeader)
[Element]
data FileHeader
= FileHeader
[Information]
[Directive]
deriving (Eq, Ord, Show)
data Element
= Tune
AbcTune
| FreeText
String
| TypesetText
String
deriving (Eq, Ord, Show)
data AbcTune
= AbcTune
TuneHeader
TuneBody
deriving (Eq, Ord, Show)
data TuneHeader
= TuneHeader
[Information]
deriving (Eq, Ord, Show)
type TuneBody = [Music]
data Music
= Music [Note :|: MultiRest :|: Barline :|: ()]
deriving (Eq, Ord, Show)
newtype MultiRest = MultiRest { getMultiRest :: Int }
deriving (Eq, Ord, Show)
type Note = DecorationT (SlurT (BeamT (GraceT (TupletT (DurationT (RestT Pitch))))))
type DecorationT a = ([Decoration], a)
type SlurT a = (Bool, a, Bool)
type BeamT a = (Bool, a, Bool)
type GraceT a = (Bool, a)
type TupletT a = (Duration, a)
type DurationT a = (a, Duration)
type RestT a = Maybe (Maybe a)
data Decoration
= Trill
| TrillBegin
| TrillEnd
| Lowermordent
| Uppermordent
| Roll
| Turn
| Turnx
| Invertedturn
| Invertedturnx
| Arpeggio
| Accent
| Fermata Bool
| Tenuto
| Fingering Int
| Plus
| Snap
| Slide
| Wedge
| Upbow
| Downbow
| Open
| Thumb
| Breath
| Crescendo
| EndCrescendo
| Diminuendo
| EndDiminuendo
| Segno
| Coda
| DaSegno
| DaCapo
| Dacoda
| Fine
| Shortphrase
| Mediumphrase
| Longphrase
deriving (Eq, Ord, Show)
newtype Duration = Duration { getDuration :: Rational }
deriving (Eq, Ord, Show, Enum, Num, Real, Fractional, RealFrac)
data PitchClass = C | D | E | F | G | A | B
deriving (Eq, Ord, Show, Enum, Bounded)
data Accidental = DoubleFlat |Flat | Natural | Sharp | DoubleSharp
deriving (Eq, Ord, Show, Enum, Bounded)
newtype Octave = Octave { getOctave :: Int }
deriving (Eq, Ord, Show, Enum, Num, Real, Integral)
newtype Pitch = Pitch { getPitch :: (PitchClass, Accidental, Octave) }
deriving (Eq, Ord, Show)
data StemDirection = Up | Down
deriving (Eq, Ord, Show, Enum, Bounded)
data Clef = NoClef | Treble | Alto | Tenor | Bass | Perc
deriving (Eq, Ord, Show, Enum, Bounded)
data Barline
= Barline
| DoubleBarline Bool Bool
| Repeat Int Bool Bool
| DottedBarline Barline
| InvisibleBarline Barline
deriving (Eq, Ord, Show)
data Information
= Area String
| Book String
| Composer String
| Discography String
| FileUrl String URI
| Group String
| History String
| Instruction Directive
| Key Key
| UnitNoteLength Duration
| Meter Meter
| Notes String
| Origin String
| Parts
| Tempo Tempo
| Rhythm String
| Source String
| SymbolLine Symbol
| TuneTitle String
| Voice VoiceProps
| Words String
| ReferenceNumber Integer
| Transcription String
deriving (Eq, Ord, Show)
type Key = (PitchClass, Mode)
type Tempo = (Maybe String, [Duration], Duration)
type Symbol = ()
data VoiceProps
= VoiceProps
(Maybe String)
(Maybe String)
(Maybe StemDirection)
(Maybe Clef)
deriving (Eq, Ord, Show)
data Meter
= NoMeter
| Common
| Cut
| Simple Rational
| Compound [Integer] Integer
deriving (Eq, Ord, Show)
data Mode
= Major
| Minor
| Ionian
| Dorian
| Phrygian
| Lydian
| Mixolydian
| Aeolian
| Locrian
deriving (Eq, Ord, Show)
type Directive = (String, String)
readAbc :: String -> AbcFile
readAbc = error "Not impl"
showAbc :: AbcFile -> String
showAbc = error "Not impl"
infixr 5 :|:
type a :|: b = Either a b