termtab-0.1.0.0: TUI guitar tablature and score editor
Safe HaskellNone
LanguageGHC2021

Termtab.Types

Description

The core domain model for a tablature/score document.

The shape mirrors how a multi-track tab is actually organized:

  • A Song owns the master timeline — one Measure per bar, in order — plus a list of Tracks (one per instrument/part).
  • A Track does not store its beats in a list parallel to songMeasures. Instead trackBeats is a Map keyed by MeasureIndex, so a track only needs entries for measures it actually has notes in, and the same MeasureIndex is the join key back to the Measure that supplies its time/key signature and tempo.
  • A Beat groups the Notes that start together (e.g. every fretted string sounding on beat 1), plus the Duration shared by all of them.
  • A Note carries both the fretboard position (noteString, noteFret) used for tab rendering and the sounding Pitch / Velocity used for MIDI playback — the two are kept in sync by whichever code constructs the Note (parsers, or the UI's editing commands), not enforced by the type itself.
Synopsis

Documentation

newtype MeasureIndex Source #

Position of a Measure within a Song, and the lookup key into a Track's trackBeats map.

Constructors

MeasureIndex Int 

newtype BeatIndex Source #

Position of a Beat within the list of beats for one measure of one track.

Constructors

BeatIndex Int 

Instances

Instances details
Show BeatIndex Source # 
Instance details

Defined in Termtab.Types

Eq BeatIndex Source # 
Instance details

Defined in Termtab.Types

Ord BeatIndex Source # 
Instance details

Defined in Termtab.Types

newtype TrackIndex Source #

Position of a Track within songTracks.

Constructors

TrackIndex Int 

Instances

Instances details
Show TrackIndex Source # 
Instance details

Defined in Termtab.Types

Eq TrackIndex Source # 
Instance details

Defined in Termtab.Types

Ord TrackIndex Source # 
Instance details

Defined in Termtab.Types

newtype StringIndex Source #

Which string of a fretted Instrument a Note is played on (0 = lowest or highest string depending on convention used by the caller; this type only pairs with FretNumber to locate a tab cell).

Constructors

StringIndex Int 

newtype FretNumber Source #

Fret position for a fretted Note, paired with StringIndex.

Constructors

FretNumber Int 

Instances

Instances details
Show FretNumber Source # 
Instance details

Defined in Termtab.Types

Eq FretNumber Source # 
Instance details

Defined in Termtab.Types

Ord FretNumber Source # 
Instance details

Defined in Termtab.Types

newtype MidiChannel Source #

MIDI channel (0-15) a Track is routed to for playback.

Constructors

MidiChannel Int 

newtype MidiProgram Source #

General MIDI program (patch/instrument) number, used by Standard instruments.

Constructors

MidiProgram Int 

newtype Velocity Source #

MIDI note-on velocity (loudness) for a Note.

Constructors

Velocity Int 

Instances

Instances details
Show Velocity Source # 
Instance details

Defined in Termtab.Types

Eq Velocity Source # 
Instance details

Defined in Termtab.Types

Ord Velocity Source # 
Instance details

Defined in Termtab.Types

newtype Tempo Source #

Tempo in beats per minute. Appears both as a Song-wide default (songTempo) and as an optional per-Measure override (tempoChange).

Constructors

Tempo Int 

Instances

Instances details
Show Tempo Source # 
Instance details

Defined in Termtab.Types

Methods

showsPrec :: Int -> Tempo -> ShowS #

show :: Tempo -> String #

showList :: [Tempo] -> ShowS #

Eq Tempo Source # 
Instance details

Defined in Termtab.Types

Methods

(==) :: Tempo -> Tempo -> Bool #

(/=) :: Tempo -> Tempo -> Bool #

Ord Tempo Source # 
Instance details

Defined in Termtab.Types

Methods

compare :: Tempo -> Tempo -> Ordering #

(<) :: Tempo -> Tempo -> Bool #

(<=) :: Tempo -> Tempo -> Bool #

(>) :: Tempo -> Tempo -> Bool #

(>=) :: Tempo -> Tempo -> Bool #

max :: Tempo -> Tempo -> Tempo #

min :: Tempo -> Tempo -> Tempo #

newtype Pitch Source #

Absolute MIDI pitch (0-127, middle C = 60). Used for both the sounding pitch of a Note and the open-string tuning of a fretted Instrument.

Constructors

Pitch Int 

Instances

Instances details
Show Pitch Source # 
Instance details

Defined in Termtab.Types

Methods

showsPrec :: Int -> Pitch -> ShowS #

show :: Pitch -> String #

showList :: [Pitch] -> ShowS #

Eq Pitch Source # 
Instance details

Defined in Termtab.Types

Methods

(==) :: Pitch -> Pitch -> Bool #

(/=) :: Pitch -> Pitch -> Bool #

Ord Pitch Source # 
Instance details

Defined in Termtab.Types

Methods

compare :: Pitch -> Pitch -> Ordering #

(<) :: Pitch -> Pitch -> Bool #

(<=) :: Pitch -> Pitch -> Bool #

(>) :: Pitch -> Pitch -> Bool #

(>=) :: Pitch -> Pitch -> Bool #

max :: Pitch -> Pitch -> Pitch #

min :: Pitch -> Pitch -> Pitch #

data Duration Source #

Rhythmic duration of a Beat. Dotted and Triplet wrap another Duration rather than being enumerated separately, so e.g. a dotted eighth is Dotted Eighth and a triplet eighth is Triplet Eighth; the two can combine (Dotted (Triplet Eighth)) since nothing restricts nesting.

Instances

Instances details
Show Duration Source # 
Instance details

Defined in Termtab.Types

Eq Duration Source # 
Instance details

Defined in Termtab.Types

Ord Duration Source # 
Instance details

Defined in Termtab.Types

data Mode Source #

Major/minor quality of a KeySignature.

Constructors

Major 
Minor 

Instances

Instances details
Show Mode Source # 
Instance details

Defined in Termtab.Types

Methods

showsPrec :: Int -> Mode -> ShowS #

show :: Mode -> String #

showList :: [Mode] -> ShowS #

Eq Mode Source # 
Instance details

Defined in Termtab.Types

Methods

(==) :: Mode -> Mode -> Bool #

(/=) :: Mode -> Mode -> Bool #

data TimeSignature Source #

Time signature as TimeSignature numerator denominator, e.g. TimeSignature 4 4 for common time.

Constructors

TimeSignature Int Int 

Instances

Instances details
Show TimeSignature Source # 
Instance details

Defined in Termtab.Types

Eq TimeSignature Source # 
Instance details

Defined in Termtab.Types

data KeySignature Source #

Key signature as KeySignature accidentals mode, where accidentals is signed count of sharps (positive) or flats (negative) from the circle of fifths, e.g. KeySignature 2 Major is D major (two sharps).

Constructors

KeySignature Int Mode 

Instances

Instances details
Show KeySignature Source # 
Instance details

Defined in Termtab.Types

Eq KeySignature Source # 
Instance details

Defined in Termtab.Types

newtype BendValue Source #

Pitch bend amount in semitones/cents (interpretation is up to the producer/consumer, e.g. the GP5 parser or the audio engine); carried by the Bend NoteEffect.

Constructors

BendValue Int 

Instances

Instances details
Show BendValue Source # 
Instance details

Defined in Termtab.Types

Eq BendValue Source # 
Instance details

Defined in Termtab.Types

data SlideType Source #

Variants of slide/legato articulation between fretted notes, used by the Slide NoteEffect.

Instances

Instances details
Show SlideType Source # 
Instance details

Defined in Termtab.Types

Eq SlideType Source # 
Instance details

Defined in Termtab.Types

data NoteEffect Source #

A single articulation attached to a Note. A note can carry several of these via noteEffects (e.g. a bend into a vibrato).

Instances

Instances details
Show NoteEffect Source # 
Instance details

Defined in Termtab.Types

Eq NoteEffect Source # 
Instance details

Defined in Termtab.Types

data Note Source #

One played (or fretted) note. notePitch / noteVelocity describe what should sound; noteString / noteFret describe where it sits on the fretboard for tab rendering and are Nothing for non-fretted instruments (see Standard).

Instances

Instances details
Show Note Source # 
Instance details

Defined in Termtab.Types

Methods

showsPrec :: Int -> Note -> ShowS #

show :: Note -> String #

showList :: [Note] -> ShowS #

Eq Note Source # 
Instance details

Defined in Termtab.Types

Methods

(==) :: Note -> Note -> Bool #

(/=) :: Note -> Note -> Bool #

data Beat Source #

A set of Notes that start simultaneously, sharing one Duration. beatIsRest marks silence; when True, beatNotes is expected to be empty.

Constructors

Beat 

Instances

Instances details
Show Beat Source # 
Instance details

Defined in Termtab.Types

Methods

showsPrec :: Int -> Beat -> ShowS #

show :: Beat -> String #

showList :: [Beat] -> ShowS #

Eq Beat Source # 
Instance details

Defined in Termtab.Types

Methods

(==) :: Beat -> Beat -> Bool #

(/=) :: Beat -> Beat -> Bool #

data Measure Source #

Metadata for one bar of the Song-wide timeline. This holds the signatures and tempo change for the bar; it does not hold notes — the actual Beats for this bar live in each Track's trackBeats, keyed by this measure's measureIndex.

Instances

Instances details
Show Measure Source # 
Instance details

Defined in Termtab.Types

Eq Measure Source # 
Instance details

Defined in Termtab.Types

Methods

(==) :: Measure -> Measure -> Bool #

(/=) :: Measure -> Measure -> Bool #

data Instrument Source #

What a Track is played on. Guitar and Bass are fretted instruments described by their open-string tuning (low to high) and stringCount; their Notes are expected to carry noteString / noteFret. Standard is any non-fretted General MIDI instrument addressed purely by MidiProgram, whose Notes carry only pitch data.

Constructors

Guitar 

Fields

Bass 

Fields

Standard MidiProgram 

Instances

Instances details
Show Instrument Source # 
Instance details

Defined in Termtab.Types

Eq Instrument Source # 
Instance details

Defined in Termtab.Types

data Track Source #

One instrument's part across the whole Song. trackBeats maps each MeasureIndex that this track has content in to the ordered list of Beats for that bar; a measure absent from the map is silent for this track. trackChannel is the MIDI channel used for playback.

Instances

Instances details
Show Track Source # 
Instance details

Defined in Termtab.Types

Methods

showsPrec :: Int -> Track -> ShowS #

show :: Track -> String #

showList :: [Track] -> ShowS #

Eq Track Source # 
Instance details

Defined in Termtab.Types

Methods

(==) :: Track -> Track -> Bool #

(/=) :: Track -> Track -> Bool #

data Song Source #

A complete tablature/score document: the master bar-by-bar timeline (songMeasures) shared by every track, plus the per-instrument parts (songTracks) that reference it via MeasureIndex. songTempo is the default tempo, overridden per-bar by tempoChange.

Constructors

Song 

Instances

Instances details
Show Song Source # 
Instance details

Defined in Termtab.Types

Methods

showsPrec :: Int -> Song -> ShowS #

show :: Song -> String #

showList :: [Song] -> ShowS #

Eq Song Source # 
Instance details

Defined in Termtab.Types

Methods

(==) :: Song -> Song -> Bool #

(/=) :: Song -> Song -> Bool #

data UnsupportedFormat Source #

A recognized-but-unhandled input file: unsupportedPath is the file that was read and unsupportedReason explains what about its format isn't supported (as opposed to the file simply being malformed, which is ParseErrorMalformed).

data ParseError Source #

Failure result from a module in "Termtab.Parser.*". Distinguishes a format that is understood but deliberately not supported (ParseErrorUnsupported) from input that couldn't be parsed at all (ParseErrorMalformed, carrying a human-readable description).

Instances

Instances details
Show ParseError Source # 
Instance details

Defined in Termtab.Types