Fix compatibility with newer versions of lilypond.
[jelmer/ptabtools.git] / gp.h
1 /*
2    Parsing utilities for GuitarPro (version 2, 3 and 4) files
3    (c) 2004 Jelmer Vernooij <jelmer@samba.org>
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #ifndef __GP_H__
21 #define __GP_H__
22
23 #include <sys/stat.h>
24 #include <stdlib.h>
25
26 #if defined(_MSC_VER) && !defined(PTB_CORE)
27 #pragma comment(lib,"ptb.lib")
28 #endif
29
30 #ifdef _MSC_VER
31 typedef unsigned char uint8_t;
32 typedef unsigned short uint16_t;
33 typedef unsigned long uint32_t;
34 #endif
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 struct gp_color {
41         uint8_t unknown;
42         uint8_t red;
43         uint8_t green;
44         uint8_t blue;
45 };
46
47 struct gpf {
48         int fd;
49         const char *version_string;
50         double version;
51         
52         const char *title;
53         const char *artist;
54         const char *album;
55         const char *subtitle;
56         const char *tab_by;
57         const char *instruction;
58         const char *author;
59         const char *copyright;
60         uint32_t notice_num_lines;
61         const char **notice;
62
63         uint8_t shuffle;
64
65         uint32_t lyrics_track;
66
67         uint32_t num_lyrics;
68         struct gp_lyric {
69                 uint32_t bar;
70                 const char *data;
71         } *lyrics;
72
73         uint32_t bpm;
74
75         uint32_t num_instruments;
76         struct gp_instrument {
77                 char dummy;
78         } *instrument;
79
80         uint32_t num_bars;
81         uint32_t num_tracks;
82
83         struct gp_bar {
84                 uint8_t properties;
85 #define GP_BAR_PROPERTY_CUSTOM_RHYTHM_1 0x01
86 #define GP_BAR_PROPERTY_CUSTOM_RHYTHM_2 0x02
87 #define GP_BAR_PROPERTY_REPEAT_OPEN             0x04
88 #define GP_BAR_PROPERTY_REPEAT_CLOSE    0x08
89 #define GP_BAR_PROPERTY_ALT_ENDING              0x10
90 #define GP_BAR_PROPERTY_MARKER                  0x20
91 #define GP_BAR_PROPERTY_CHANGE_ARMOR    0x40
92 #define GP_BAR_PROPERTY_DOUBLE_ENDING   0x80
93                 
94                 uint8_t rhythm_1;
95                 uint8_t rhythm_2;
96                 struct {
97                         uint8_t volta;
98                 } repeat_close;
99                 struct {
100                         uint8_t type;
101                 } alternate_ending;
102                 struct {
103                         const char *name;
104                         struct gp_color color;
105                 } marker;
106                 struct {
107                         uint8_t armor_jumps;
108                         uint8_t minor;
109                 } change_armor;
110                 struct gp_bar_track
111                 {
112                         uint32_t num_beats;
113                         struct gp_beat
114                         {
115                                 uint8_t properties;
116 #define GP_BEAT_PROPERTY_DOTTED 0x01
117 #define GP_BEAT_PROPERTY_CHORD  0x02
118 #define GP_BEAT_PROPERTY_TEXT   0x04
119 #define GP_BEAT_PROPERTY_EFFECT 0x08
120 #define GP_BEAT_PROPERTY_CHANGE 0x10
121 #define GP_BEAT_PROPERTY_TUPLET 0x20
122 #define GP_BEAT_PROPERTY_REST   0x40
123                                 struct { 
124                                         uint8_t complete;
125                                         const char *name;
126                                         uint32_t top_fret;
127                                 } chord;
128                                 struct {
129 #define GP_BEAT_EFFECT1_VIBRATO                         0x01
130 #define GP_BEAT_EFFECT1_WIDE_VIBRATO            0x02
131 #define GP_BEAT_EFFECT1_NATURAL_HARMONIC        0x04
132 #define GP_BEAT_EFFECT1_OTHER_HARMONIC          0x08
133 #define GP_BEAT_EFFECT1_FADE_IN                         0x10
134 #define GP_BEAT_EFFECT1_4_STROCKE_EFFECT        0x20
135 #define GP_BEAT_EFFECT1_TREMOLO_BAR                     0x20
136 #define GP_BEAT_EFFECT1_STROCKE                         0x40
137 #define GP_BEAT_EFFECT2_RASGUEADO                       0x01
138 #define GP_BEAT_EFFECT2_PICK_STROCKE            0x02
139 #define GP_BEAT_EFFECT2_TREMOLO_BAR                     0x04
140                                         uint8_t properties1;
141                                         uint8_t properties2;
142                                         struct {
143                                                 uint32_t num_points;
144                                         } tremolo_bar;
145                                 } effect;
146                                 struct {
147                                         uint8_t new_instrument;
148                                         uint8_t new_volume;
149                                         uint8_t new_reverb;
150                                         uint8_t new_pan;
151                                         uint8_t new_chorus;
152                                         uint8_t new_phaser;
153                                         uint32_t new_tempo;
154                                         uint8_t new_tremolo;
155                                 } change;
156                                 struct {
157                                         uint32_t n_tuplet;
158                                 } tuplet;
159                                 uint8_t duration;
160                                 const char *text;
161                                 uint8_t strings_present;
162                                 struct gp_note {
163                                         uint8_t duration;
164                                         uint8_t new_nuance;
165                                         uint8_t value;
166                                         uint8_t properties;
167 #define GP_NOTE_PROPERTY_DURATION_SPECIAL       0x01
168 #define GP_NOTE_PROPERTY_DOTTED                         0x02
169 #define GP_NOTE_PROPERTY_GHOST                          0x04
170 #define GP_NOTE_PROPERTY_EFFECT                         0x08
171 #define GP_NOTE_PROPERTY_NUANCE_CHANGE          0x10
172 #define GP_NOTE_PROPERTY_ALTERATION                     0x20
173 #define GP_NOTE_PROPERTY_ACCENTUATED            0x40
174 #define GP_NOTE_PROPERTY_FINGERING                      0x80
175                                         uint8_t alteration;
176 #define GP_NOTE_ALTERATION_LINKED                       0x02
177 #define GP_NOTE_ALTERATION_DEAD                         0x03
178                                         struct {
179                                                 uint8_t properties1;
180 #define GP_NOTE_EFFECT1_BEND                            0x01
181 #define GP_NOTE_EFFECT1_HAMMER                          0x02
182 #define GP_NOTE_EFFECT1_SLIDE                           0x04
183 #define GP_NOTE_EFFECT1_LET_RING                        0x08
184 #define GP_NOTE_EFFECT1_APPOGIATURE                     0x10
185                                                 uint8_t properties2;
186 #define GP_NOTE_EFFECT2_STACCATO                        0x01
187 #define GP_NOTE_EFFECT2_PALM_MUTE                       0x02
188 #define GP_NOTE_EFFECT2_TREMOLO_PICKING         0x04
189 #define GP_NOTE_EFFECT2_SLIDE                           0x08
190 #define GP_NOTE_EFFECT2_HARMONIC                        0x10
191 #define GP_NOTE_EFFECT2_TRILL                           0x20
192 #define GP_NOTE_EFFECT2_VIBRATO                         0x40
193                                                 struct {
194                                                         uint32_t num_points;
195                                                         struct gp_note_effect_bend_point 
196                                                         {
197                                                                 uint32_t pitch;
198                                                         } *points;
199                                                 } bend;
200
201                                                 struct {
202                                                         uint8_t duration;
203                                                 } tremolo_picking;
204
205                                                 struct {
206                                                         uint8_t type;
207                                                 } slide;
208
209                                                 struct {
210                                                         uint8_t type;
211                                                 } harmonic;
212
213                                                 struct {
214                                                         uint8_t note_value;
215                                                         uint8_t frequency;
216                                                 } trill;
217
218                                                 struct {
219                                                         uint8_t duration;
220                                                         uint8_t previous_note;
221                                                         uint8_t transition;
222                                                 } appogiature;
223                                         } effect;
224                                         struct {
225                                                 uint8_t left_hand;
226                                                 uint8_t right_hand;
227                                         } fingering;
228                                 } notes[7];
229                         } *beats;
230                 } *tracks;
231         } *bars;
232
233         struct gp_track {
234                 const char *name;
235                 uint8_t spc;
236                 uint32_t num_frets;
237                 uint32_t num_strings;
238                 uint32_t midi_port;
239                 uint32_t channel1;
240                 uint32_t channel2;
241                 struct gp_track_string {
242                         uint32_t pitch;
243                 } *strings;
244                 struct gp_color color;
245                 uint32_t capo;
246         } *tracks;
247
248 };
249
250 extern struct gpf *gp_read_file(const char *filename);
251 extern void gp_free(struct gpf *);
252
253 #ifdef __cplusplus
254 }
255 #endif
256
257 #endif /* __GP_H__ */