Documentation
¶
Overview ¶
Package parsegp provides functionality for parsing Guitar Pro files (.gp3, .gp4, .gp5, .gpx).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SupportedFormats ¶
func SupportedFormats() []string
SupportedFormats returns a slice of strings representing the supported Guitar Pro file formats. The supported formats are ".gp3", ".gp4", and ".gp5".
This function does not take any parameters and returns a slice of strings.
Example usage:
formats := parsegp.SupportedFormats() fmt.Println(formats) // Output: [".gp3" ".gp4" ".gp5"]
Types ¶
type Beat ¶
type Beat struct {
Start int `json:"start"`
}
Beat represents a beat in a Guitar Pro measure.
type BitStream ¶
type BitStream struct {
// contains filtered or unexported fields
}
BitStream represents a stream of bits that can be read bit by bit.
type GPFile ¶
type GPFile struct { FullPath string `json:"-"` Version string `json:"version"` Title string `json:"title"` Subtitle string `json:"subtitle"` Artist string `json:"artist"` Album string `json:"album"` LyricsAuthor string `json:"lyricsAuthor"` MusicAuthor string `json:"musicAuthor"` Copyright string `json:"copyright"` Tab string `json:"tab"` Instructions string `json:"instructions"` Comments []string `json:"comments"` Lyric Lyric `json:"lyric"` TempoValue int `json:"tempoValue"` KeySignature int `json:"keySignature"` Channels []Channel `json:"channels"` Measures int `json:"measures"` TrackCount int `json:"trackCount"` MeasureHeaders []MeasureHeader `json:"measureHeaders"` Tracks []Track `json:"tracks"` }
GPFile represents a Guitar Pro file structure.
func NewGPFile ¶
NewGPFile creates a new GPFile instance for the specified file path. It checks if the file exists, is not empty, and has a supported Guitar Pro format (.gp3, .gp4, .gp5, .gpx). If the file is valid, it opens the file, sets the FullPath property, and returns the GuitarProFileInfo instance. If the file is not a supported format, it returns a notGPFile error.
Parameters: p (string): The file path of the Guitar Pro file.
Returns: gp (*GPFile): A pointer to the GPFile instance for the specified file path. err (error): An error if any issues occur during the file validation or opening process.
func (*GPFile) LoadHeader ¶
LoadHeader reads the header of the Guitar Pro file (gp3, gp4, gp5, gpx) It first checks if the file exists and is not empty. If the file is valid, it opens the file and seeks to the beginning. Then, it determines the type of Guitar Pro file (gp3, gp4, gp5, gpx) by reading the header.
If the file is a Guitar Pro file (gp3, gp4, gp5), it calls the appropriate function to read and store the file's information such as title, artist, version, and full path.
If the file is a Guitar Pro XML file (gpx), it calls the loadGPXFile function to parse and store the XML data.
The function returns an error if any issues occur during the file reading, header detection, or information extraction process.
type Measure ¶
type Measure struct { Header MeasureHeader `json:"header"` Start int `json:"start"` Beats []Beat `json:"beats"` }
Measure represents a measure in a Guitar Pro file.
type MeasureHeader ¶
type MeasureHeader struct { Number int `json:"number"` Start int `json:"start"` Tempo int `json:"tempo"` RepeatOpen bool `json:"repeatOpen"` TimeSignature TimeSignature `json:"timeSignature"` }
MeasureHeader represents a measure header in a Guitar Pro file.
type TimeSignature ¶
type TimeSignature struct { Numerator int `json:"numerator"` Denominator struct { Value int `json:"value"` Division struct { Enters int `json:"enters"` Times int `json:"times"` } `json:"division"` } `json:"denominator"` }
TimeSignature represents a time signature in a Guitar Pro file.