| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Termtab.Types
Description
The core domain model for a tablature/score document.
The shape mirrors how a multi-track tab is actually organized:
- A
Songowns the master timeline — oneMeasureper bar, in order — plus a list ofTracks (one per instrument/part). - A
Trackdoes not store its beats in a list parallel tosongMeasures. InsteadtrackBeatsis aMapkeyed byMeasureIndex, so a track only needs entries for measures it actually has notes in, and the sameMeasureIndexis the join key back to theMeasurethat supplies its time/key signature and tempo. - A
Beatgroups theNotes that start together (e.g. every fretted string sounding on beat 1), plus theDurationshared by all of them. - A
Notecarries both the fretboard position (noteString,noteFret) used for tab rendering and the soundingPitch/Velocityused for MIDI playback — the two are kept in sync by whichever code constructs theNote(parsers, or the UI's editing commands), not enforced by the type itself.
Synopsis
- newtype MeasureIndex = MeasureIndex Int
- newtype BeatIndex = BeatIndex Int
- newtype TrackIndex = TrackIndex Int
- newtype StringIndex = StringIndex Int
- newtype FretNumber = FretNumber Int
- newtype MidiChannel = MidiChannel Int
- newtype MidiProgram = MidiProgram Int
- newtype Velocity = Velocity Int
- newtype Tempo = Tempo Int
- newtype Pitch = Pitch Int
- data Duration
- data Mode
- data TimeSignature = TimeSignature Int Int
- data KeySignature = KeySignature Int Mode
- newtype BendValue = BendValue Int
- data SlideType
- data NoteEffect
- data Note = Note {}
- data Beat = Beat {
- beatDuration :: Duration
- beatNotes :: [Note]
- beatIsRest :: Bool
- data Measure = Measure {}
- data Instrument
- = Guitar {
- tuning :: [Pitch]
- stringCount :: Int
- | Bass {
- tuning :: [Pitch]
- stringCount :: Int
- | Standard MidiProgram
- = Guitar {
- data Track = Track {}
- data Song = Song {
- songTitle :: Text
- songArtist :: Text
- songTempo :: Tempo
- songTracks :: [Track]
- songMeasures :: [Measure]
- data UnsupportedFormat = UnsupportedFormat {}
- data ParseError
Documentation
newtype MeasureIndex Source #
Position of a Measure within a Song, and the lookup key into a
Track's trackBeats map.
Constructors
| MeasureIndex Int |
Instances
| Show MeasureIndex Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> MeasureIndex -> ShowS # show :: MeasureIndex -> String # showList :: [MeasureIndex] -> ShowS # | |
| Eq MeasureIndex Source # | |
Defined in Termtab.Types | |
| Ord MeasureIndex Source # | |
Defined in Termtab.Types Methods compare :: MeasureIndex -> MeasureIndex -> Ordering # (<) :: MeasureIndex -> MeasureIndex -> Bool # (<=) :: MeasureIndex -> MeasureIndex -> Bool # (>) :: MeasureIndex -> MeasureIndex -> Bool # (>=) :: MeasureIndex -> MeasureIndex -> Bool # max :: MeasureIndex -> MeasureIndex -> MeasureIndex # min :: MeasureIndex -> MeasureIndex -> MeasureIndex # | |
Position of a Beat within the list of beats for one measure of one track.
Instances
| Show BeatIndex Source # | |
| Eq BeatIndex Source # | |
| Ord BeatIndex Source # | |
newtype TrackIndex Source #
Position of a Track within songTracks.
Constructors
| TrackIndex Int |
Instances
| Show TrackIndex Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> TrackIndex -> ShowS # show :: TrackIndex -> String # showList :: [TrackIndex] -> ShowS # | |
| Eq TrackIndex Source # | |
Defined in Termtab.Types | |
| Ord TrackIndex Source # | |
Defined in Termtab.Types Methods compare :: TrackIndex -> TrackIndex -> Ordering # (<) :: TrackIndex -> TrackIndex -> Bool # (<=) :: TrackIndex -> TrackIndex -> Bool # (>) :: TrackIndex -> TrackIndex -> Bool # (>=) :: TrackIndex -> TrackIndex -> Bool # max :: TrackIndex -> TrackIndex -> TrackIndex # min :: TrackIndex -> TrackIndex -> TrackIndex # | |
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 |
Instances
| Show StringIndex Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> StringIndex -> ShowS # show :: StringIndex -> String # showList :: [StringIndex] -> ShowS # | |
| Eq StringIndex Source # | |
Defined in Termtab.Types | |
| Ord StringIndex Source # | |
Defined in Termtab.Types Methods compare :: StringIndex -> StringIndex -> Ordering # (<) :: StringIndex -> StringIndex -> Bool # (<=) :: StringIndex -> StringIndex -> Bool # (>) :: StringIndex -> StringIndex -> Bool # (>=) :: StringIndex -> StringIndex -> Bool # max :: StringIndex -> StringIndex -> StringIndex # min :: StringIndex -> StringIndex -> StringIndex # | |
newtype FretNumber Source #
Fret position for a fretted Note, paired with StringIndex.
Constructors
| FretNumber Int |
Instances
| Show FretNumber Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> FretNumber -> ShowS # show :: FretNumber -> String # showList :: [FretNumber] -> ShowS # | |
| Eq FretNumber Source # | |
Defined in Termtab.Types | |
| Ord FretNumber Source # | |
Defined in Termtab.Types Methods compare :: FretNumber -> FretNumber -> Ordering # (<) :: FretNumber -> FretNumber -> Bool # (<=) :: FretNumber -> FretNumber -> Bool # (>) :: FretNumber -> FretNumber -> Bool # (>=) :: FretNumber -> FretNumber -> Bool # max :: FretNumber -> FretNumber -> FretNumber # min :: FretNumber -> FretNumber -> FretNumber # | |
newtype MidiChannel Source #
MIDI channel (0-15) a Track is routed to for playback.
Constructors
| MidiChannel Int |
Instances
| Show MidiChannel Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> MidiChannel -> ShowS # show :: MidiChannel -> String # showList :: [MidiChannel] -> ShowS # | |
| Eq MidiChannel Source # | |
Defined in Termtab.Types | |
| Ord MidiChannel Source # | |
Defined in Termtab.Types Methods compare :: MidiChannel -> MidiChannel -> Ordering # (<) :: MidiChannel -> MidiChannel -> Bool # (<=) :: MidiChannel -> MidiChannel -> Bool # (>) :: MidiChannel -> MidiChannel -> Bool # (>=) :: MidiChannel -> MidiChannel -> Bool # max :: MidiChannel -> MidiChannel -> MidiChannel # min :: MidiChannel -> MidiChannel -> MidiChannel # | |
newtype MidiProgram Source #
General MIDI program (patch/instrument) number, used by Standard instruments.
Constructors
| MidiProgram Int |
Instances
| Show MidiProgram Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> MidiProgram -> ShowS # show :: MidiProgram -> String # showList :: [MidiProgram] -> ShowS # | |
| Eq MidiProgram Source # | |
Defined in Termtab.Types | |
| Ord MidiProgram Source # | |
Defined in Termtab.Types Methods compare :: MidiProgram -> MidiProgram -> Ordering # (<) :: MidiProgram -> MidiProgram -> Bool # (<=) :: MidiProgram -> MidiProgram -> Bool # (>) :: MidiProgram -> MidiProgram -> Bool # (>=) :: MidiProgram -> MidiProgram -> Bool # max :: MidiProgram -> MidiProgram -> MidiProgram # min :: MidiProgram -> MidiProgram -> MidiProgram # | |
MIDI note-on velocity (loudness) for a Note.
Tempo in beats per minute. Appears both as a Song-wide default
(songTempo) and as an optional per-Measure override (tempoChange).
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.
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.
Major/minor quality of a KeySignature.
data TimeSignature Source #
Time signature as TimeSignature numerator denominator, e.g.
TimeSignature 4 4 for common time.
Constructors
| TimeSignature Int Int |
Instances
| Show TimeSignature Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> TimeSignature -> ShowS # show :: TimeSignature -> String # showList :: [TimeSignature] -> ShowS # | |
| Eq TimeSignature Source # | |
Defined in Termtab.Types Methods (==) :: TimeSignature -> TimeSignature -> Bool # (/=) :: TimeSignature -> TimeSignature -> Bool # | |
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
| Show KeySignature Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> KeySignature -> ShowS # show :: KeySignature -> String # showList :: [KeySignature] -> ShowS # | |
| Eq KeySignature Source # | |
Defined in Termtab.Types | |
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.
Instances
Variants of slide/legato articulation between fretted notes, used by
the Slide NoteEffect.
Instances
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
| Show NoteEffect Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> NoteEffect -> ShowS # show :: NoteEffect -> String # showList :: [NoteEffect] -> ShowS # | |
| Eq NoteEffect Source # | |
Defined in Termtab.Types | |
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).
Constructors
| Note | |
Fields
| |
A set of Notes that start simultaneously, sharing one Duration.
beatIsRest marks silence; when True, beatNotes is expected to be
empty.
Constructors
| Beat | |
Fields
| |
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.
Constructors
| Measure | |
Fields | |
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
| Show Instrument Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> Instrument -> ShowS # show :: Instrument -> String # showList :: [Instrument] -> ShowS # | |
| Eq Instrument Source # | |
Defined in Termtab.Types | |
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.
Constructors
| Track | |
Fields
| |
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 | |
Fields
| |
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).
Constructors
| UnsupportedFormat | |
Fields | |
Instances
| Show UnsupportedFormat Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> UnsupportedFormat -> ShowS # show :: UnsupportedFormat -> String # showList :: [UnsupportedFormat] -> ShowS # | |
| Eq UnsupportedFormat Source # | |
Defined in Termtab.Types Methods (==) :: UnsupportedFormat -> UnsupportedFormat -> Bool # (/=) :: UnsupportedFormat -> UnsupportedFormat -> Bool # | |
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
| Show ParseError Source # | |
Defined in Termtab.Types Methods showsPrec :: Int -> ParseError -> ShowS # show :: ParseError -> String # showList :: [ParseError] -> ShowS # | |