parsegp

package module
v0.0.0-...-f1858e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 7 Imported by: 0

README

My Guitar Pro Journey

I have been playing guitar for many years. Over time I have accumulated a lot of Guitar Pro files. From Guitar Pro 4 to 8. There are good tools for Guitar Pro, each tool has its strengths and weaknesses. In order to be able to design my own software according to my ideas, I need a library to manage these files.

Here are some projects that can be used with Guitar Pro. Some of these also contain good tips on how to process the files.

[https://github.com/Antti/rust-gpx-reader] Important information about how a GPX file is structured.

Status

This library can currently read information from Gutiar Pro 4 - 6 (no GPX) such as Song title, author, subtitle, creator, copyright etc. Tracks and music information is not yet implemented.

I have not yet been able to read information from a GPX file. However, since I need this information, I am actively working on it.

about me

I'm not a Go pro, but I chose this language because I simply love Go (not a love-hate relationship like with ruby ​​:-) ). With this project I want to grow and delve deeper into Go. I would like to encourage everyone to join me, improve this library and learn together.

I would be happy if someone would join me in building this library.

TODO List

  • Simple Songinformation from

    • GP3
    • GP4
    • GP5
    • GPX
  • Read music data

    • GP3
    • GP4
    • GP5
    • GPX

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 Channel

type Channel struct {
	Program int   `json:"program"`
	Color   Color `json:"color"`
}

Channel represents a channel in a Guitar Pro file.

type Color

type Color struct {
	R uint8 `json:"r"`
	G uint8 `json:"g"`
	B uint8 `json:"b"`
}

Color represents a color in RGB format.

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

func NewGPFile(p string) (gp *GPFile, err error)

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

func (gp *GPFile) LoadHeader() error

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 Lyric

type Lyric struct {
	From  int    `json:"from"`
	Lyric string `json:"lyric"`
}

Lyric represents a lyric in a Guitar Pro file.

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.

type Track

type Track struct {
	Number   int       `json:"number"`
	Name     string    `json:"name"`
	Strings  []string  `json:"strings"`
	Measures []Measure `json:"measures"`
}

Track represents a track in a Guitar Pro file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL