Documentation ¶
Overview ¶
Provides Parsers and a Types to represents a song with chords
Index ¶
Examples ¶
Constants ¶
View Source
const ( Verse = "verse" Chorus = "chorus" ChorusRecall = "chorus-recall" Comment = "comment" )
Constants for section type
Variables ¶
This section is empty.
Functions ¶
func LoadTemplates ¶
Types ¶
type Line ¶
type Line struct { // Text of the line Text string // Chords in the line Chords []chord.Chord // Position of chords in the line Positions []int }
A Line represent a line of text in the song it is composed of chords that are position by index in the text
type Section ¶
type Section struct { // Section type (Verse, Chorus, ChorusRecall, Comment) Type SectionType // Text content of the section Lines []Line }
A section correspond to a paragraph of the song it can be a verse, a chorus, a comment
type SectionType ¶
type SectionType string
A section is used in a section to know how to interpret the content of the section
type Song ¶
type Song struct { // Title Title string // Subtitles of the song SubTitles []string // Artist of the song Artists []string // Authors Authors []string // Authors Compositors []string // Album of the song Album string // Year the song has been created Year string // The Text content of the song Content []Section // Specific Guitar Voicing used in this song GuitarVoicing []chord.GuitarVoicing }
A song
Example ¶
Em := chord.Chord{ Name: "Em", Notes: []note.Note{ note.Minor.Degree(note.E, 1), note.Minor.Degree(note.E, 3), note.Minor.Degree(note.E, 5), }, } VoicingEm := chord.GuitarVoicing{ Name: "Em", Tuning: []note.Note{note.E, note.A, note.D, note.G, note.B, note.E}, Frets: []int{0, 2, 2, 0, 0, 0}, Fingers: []int{-1, 2, 3, -1, -1, -1}, } Am := chord.Chord{ Name: "Am", Notes: []note.Note{ note.Minor.Degree(note.A, 1), note.Minor.Degree(note.A, 3), note.Minor.Degree(note.A, 5), }, } VoicingAm := chord.GuitarVoicing{ Name: "Am", Tuning: []note.Note{note.E, note.A, note.D, note.G, note.B, note.E}, Frets: []int{0, 0, 2, 2, 1, 0}, Fingers: []int{-1, -1, 2, 3, 1, -1}, } song := Song{ Title: "My Song", Artists: []string{"Anonymous"}, Album: "My Album", Year: "2010", Content: []Section{ Section{ Type: Verse, Lines: []Line{ Line{ Text: "my song is not really a song is just a test", Chords: []chord.Chord{ Em, Am, }, Positions: []int{0, 22}, }, }, }, }, GuitarVoicing: []chord.GuitarVoicing{ VoicingEm, VoicingAm, }, } fmt.Printf("%v\n", song)
Output: {My Song [] [Anonymous] [] [] My Album 2010 [{verse [{my song is not really a song is just a test [{Em [E G B]} {Am [A C E]}] [0 22]}]}] [{Em [E A D G B E] [0 2 2 0 0 0] [-1 2 3 -1 -1 -1]} {Am [E A D G B E] [0 0 2 2 1 0] [-1 -1 2 3 1 -1]}]}
Click to show internal directories.
Click to hide internal directories.