2 Functions for writing and reading PowerTab (.ptb) files
3 (c) 2004-2005 Jelmer Vernooij <jelmer@samba.org>
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 2 of the License, or
8 (at your option) any later version.
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.
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.
26 #if defined(_MSC_VER) && !defined(PTB_CORE)
27 #pragma comment(lib,"ptb.lib")
31 typedef unsigned char uint8_t;
32 typedef unsigned short uint16_t;
33 typedef unsigned long uint32_t;
42 typedef uint8_t ptb_chord;
43 typedef uint8_t ptb_tone;
44 typedef uint8_t ptb_note;
47 enum { CLASSIFICATION_SONG = 0, CLASSIFICATION_LESSON} classification;
51 enum { RELEASE_TYPE_PR_AUDIO = 0, RELEASE_TYPE_PR_VIDEO, RELEASE_TYPE_BOOTLEG, RELEASE_TYPE_UNRELEASED } release_type;
55 enum { AUDIO_TYPE_SINGLE = 0, AUDIO_TYPE_EP, AUDIO_TYPE_ALBUM, AUDIO_TYPE_DOUBLE_ALBUM, AUDIO_TYPE_TRIPLE_ALBUM, AUDIO_TYPE_BOXSET } type;
58 uint8_t is_live_recording;
63 uint8_t is_live_recording;
75 uint8_t is_original_author_unknown;
81 char *guitar_transcribed_by;
82 char *bass_transcribed_by;
91 enum { LEVEL_BEGINNER = 0, LEVEL_INTERMEDIATE, LEVEL_ADVANCED} level;
104 struct ptb_guitar *prev, *next;
116 uint8_t initial_volume;
117 uint8_t midi_instrument;
123 struct ptb_dynamic *prev, *next;
130 struct ptb_guitarin {
131 struct ptb_guitarin *prev, *next;
137 /* OR'd numbers of guitars
138 * (0x01 = guitar1, 0x02 = guitar2, 0x04 = guitar3, etc) */
139 uint8_t rhythm_slash;
151 struct ptb_floatingtext {
152 struct ptb_floatingtext *prev, *next;
157 #define ALIGN_CENTER 2
158 #define ALIGN_RIGHT 3
159 #define ALIGN_TIMESTAMP 8
161 struct ptb_font font;
164 struct ptb_tempomarker {
165 struct ptb_tempomarker *prev, *next;
174 struct ptb_chorddiagram {
175 struct ptb_chorddiagram *prev, *next;
184 struct ptb_chordtext {
185 struct ptb_chordtext *prev, *next;
188 #define CHORDTEXT_PROPERTY_NOCHORD 0x10
189 #define CHORDTEXT_PROPERTY_PARENTHESES 0x20
190 #define CHORDTEXT_PROPERTY_FORMULA_M 0x01
191 #define CHORDTEXT_PROPERTY_FORMULA_MAJ7 0x08
194 #define CHORDTEXT_ADD_9 0x40
197 #define CHORDTEXT_VII 0x08
201 struct ptb_position {
202 struct ptb_position *prev, *next;
205 #define POSITION_PALM_MUTE 0x20
206 #define POSITION_STACCATO 0x02
207 #define POSITION_ACCENT 0x04
210 #define POSITION_DOTS_1 0x01
211 #define POSITION_DOTS_2 0x02
212 #define POSITION_DOTS_REST 0x04
213 #define POSITION_DOTS_ARPEGGIO_UP 0x10
215 #define POSITION_PROPERTY_IN_SINGLE_BEAM 0x0080
216 #define POSITION_PROPERTY_IN_DOUBLE_BEAM 0x0100
217 #define POSITION_PROPERTY_FIRST_IN_BEAM 0x0400
218 #define POSITION_PROPERTY_LAST_IN_BEAM 0x2000
222 #define POSITION_FERMENTA_LET_RING 0x08
223 #define POSITION_FERMENTA_FERMENTA 0x10
224 #define POSITION_FERMENTA_TRIPLET_1 0x20
225 #define POSITION_FERMENTA_TRIPLET_2 0x40
226 #define POSITION_FERMENTA_TRIPLET_3 0x80
228 uint8_t nr_additional_data;
229 struct ptb_position_additional
231 uint8_t start_volume;
233 uint8_t duration; /* Number of following positions */
235 #define POSITION_ADDITIONAL_VOLUMESWELL 0x61
236 #define POSITION_ADDITIONAL_TREMOLOBAR 0x63
239 struct ptb_linedata *linedatas;
244 #define STAFF_TYPE_BASS_KEY 0x10
247 struct ptb_staff *prev, *next;
249 /* Number of strings OR-ed with some settings */
251 uint8_t highest_note;
253 struct ptb_position *positions[2];
258 uint8_t bend_pitch:4;
259 uint8_t release_pitch:4;
265 struct ptb_linedata {
266 struct ptb_linedata *prev, *next;
271 unsigned int string:3;
275 #define LINEDATA_PROPERTY_TIE 0x01
276 #define LINEDATA_PROPERTY_MUTED 0x02
277 #define LINEDATA_PROPERTY_HAMMERON_FROM 0x08
278 #define LINEDATA_PROPERTY_PULLOFF_FROM 0x10
279 #define LINEDATA_PROPERTY_NATURAL_HARMONIC 0x40
280 #define LINEDATA_PROPERTY_GHOST_NOTE 0x80
283 #define LINEDATA_TRANSCRIBE_8VA 0x01
284 #define LINEDATA_TRANSCRIBE_15MA 0x02
285 #define LINEDATA_TRANSCRIBE_8VB 0x03
286 #define LINEDATA_TRANSCRIBE_15MB 0x04
287 uint8_t conn_to_next;
288 struct ptb_bend *bends;
291 #define METER_TYPE_BEAM_2 0x0080
292 #define METER_TYPE_BEAM_4 0x0100
293 #define METER_TYPE_BEAM_3 0x0180
294 #define METER_TYPE_BEAM_6 0x0200
295 #define METER_TYPE_BEAM_5 0x0280
296 #define METER_TYPE_COMMON 0x4000
297 #define METER_TYPE_CUT 0x8000
298 #define METER_TYPE_SHOW 0x1000
300 #define END_MARK_TYPE_NORMAL 0x00
301 #define END_MARK_TYPE_DOUBLELINE 0x20
302 #define END_MARK_TYPE_REPEAT 0x80
305 struct ptb_section *prev, *next;
308 struct ptb_staff *staffs;
309 struct ptb_chordtext *chordtexts;
310 struct ptb_rhythmslash *rhythmslashes;
311 struct ptb_direction *directions;
312 struct ptb_musicbar *musicbars;
314 /* Number of times to repeat OR-ed with end mark type */
321 unsigned int beat_value:5;
324 uint8_t metronome_pulses_per_measure;
327 uint8_t position_width;
331 struct ptb_sectionsymbol {
332 struct ptb_sectionsymbol *prev, *next;
334 uint16_t repeat_ending;
337 struct ptb_musicbar {
338 struct ptb_musicbar *prev, *next;
341 #define MUSICBAR_PROPERTY_SINGLE_BAR 0x01
342 #define MUSICBAR_PROPERTY_DOUBLE_BAR 0x20
343 #define MUSICBAR_PROPERTY_FREE_BAR 0x40
344 #define MUSICBAR_PROPERTY_REPEAT_BEGIN 0x60
345 #define MUSICBAR_PROPERTY_REPEAT_END 0x80
346 #define MUSICBAR_PROPERTY_END_BAR 0xA0
347 /* Number of times to repeat OR-ed only with REPEAT_END property */
353 struct ptb_rhythmslash {
354 struct ptb_rhythmslash *prev, *next;
356 #define RHYTHMSLASH_PROPERTY_FIRST_IN_BEAM 0x04
363 struct ptb_direction {
364 struct ptb_direction *prev, *next;
373 struct ptb_instrument {
374 struct ptb_guitar *guitars;
375 struct ptb_section *sections;
376 struct ptb_guitarin *guitarins;
377 struct ptb_chorddiagram *chorddiagrams;
378 struct ptb_tempomarker *tempomarkers;
379 struct ptb_dynamic *dynamics;
380 struct ptb_floatingtext *floatingtexts;
381 struct ptb_sectionsymbol *sectionsymbols;
384 struct ptb_font default_font;
385 struct ptb_font chord_name_font;
386 struct ptb_font tablature_font;
389 extern struct ptbf *ptb_read_file(const char *ptb);
390 extern int ptb_write_file(const char *ptb, struct ptbf *);
391 extern void ptb_free(struct ptbf *);
393 extern void ptb_set_debug(int level);
394 extern void ptb_set_asserts_fatal(int yes);
396 extern const char *ptb_get_note(struct ptb_guitar *guitar, ptb_note);
397 extern const char *ptb_get_tone(ptb_tone);
398 extern const char *ptb_get_tone_full(ptb_tone);
400 extern void ptb_get_position_difference(struct ptb_section *, int start, int end, int *bars, int *length);
402 /* Reading tuning data files (tunings.dat) */
404 struct ptb_tuning_dict {
415 extern struct ptb_tuning_dict *ptb_read_tuning_dict(const char *);
416 extern int ptb_write_tuning_dict(const char *, struct ptb_tuning_dict *);
417 extern void ptb_free_tuning_dict(struct ptb_tuning_dict *);
418 extern const char *ptb_tuning_get_note(char);
424 #endif /* __PTB_H__ */