2 (c) 2004: Jelmer Vernooij <jelmer@samba.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "dlinklist.h"
34 #define COND_PRINTF(desc,field) if(field) printf("%s: %s\n", desc, field);
36 #define PRINT_LIST(ls,t,fn) { t l = ls; while(l) { fn(l); l = l->next; } }
38 void write_musicbar(struct ptb_musicbar *mb)
40 printf("\t\tOffset: %d\n", mb->offset);
41 printf("\t\tProperties: %d\n", mb->properties);
42 printf("\t\tLetter: %c\n", mb->letter);
43 if (mb->description) printf("\t\tDescription: %s\n", mb->description);
47 void write_linedata(struct ptb_linedata *ld)
49 printf("\t\t\t\tFret: %d, String: %d\n", ld->detailed.fret, ld->detailed.string);
50 if (ld->properties & LINEDATA_PROPERTY_TIE) printf("\t\t\t\tTie\n");
51 if (ld->properties & LINEDATA_PROPERTY_MUTED) printf("\t\t\t\tMuted\n");
52 if (ld->properties & LINEDATA_PROPERTY_CONTINUES) printf("\t\t\t\tContinues\n");
53 if (ld->properties & LINEDATA_PROPERTY_HAMMERON_FROM) printf("\t\t\t\tStart of hammer-on\n");
54 if (ld->properties & LINEDATA_PROPERTY_PULLOFF_FROM) printf("\t\t\t\tStart of pull-off\n");
55 if (ld->properties & LINEDATA_PROPERTY_DEST_NOWHERE) printf("\t\t\t\tDest-nowhere(?)\n");
56 if (ld->properties & LINEDATA_PROPERTY_NATURAL_HARMONIC) printf("\t\t\t\tNatural Harmonic\n");
57 if (ld->properties & LINEDATA_PROPERTY_GHOST_NOTE) printf("\t\t\t\tGhost Note\n");
60 printf("\t\t\t\tTranscribed: ");
61 if (ld->transcribe & LINEDATA_TRANSCRIBE_8VA) printf("8va ");
62 if (ld->transcribe & LINEDATA_TRANSCRIBE_15MA) printf("15ma ");
63 if (ld->transcribe & LINEDATA_TRANSCRIBE_8VB) printf("8vb ");
64 if (ld->transcribe & LINEDATA_TRANSCRIBE_15MB) printf("15mb ");
71 void write_position(struct ptb_position *pos)
73 printf("\t\t\tOffset: %d\n", pos->offset);
74 printf("\t\t\tLength: %d\n", pos->length);
75 printf("\t\t\t Attached data:\n");
76 PRINT_LIST(pos->linedatas, struct ptb_linedata *, write_linedata);
80 void write_staff(struct ptb_staff *staff)
82 printf("\t\tLowest Note: %d, Highest Note: %d\n", staff->lowest_note, staff->highest_note);
83 printf("\t\tProperties: %d\n", staff->properties);
85 printf("\t\t Positions:\n");
86 PRINT_LIST(staff->positions[0], struct ptb_position *, write_position);
87 PRINT_LIST(staff->positions[0], struct ptb_position *, write_position);
91 void write_chordtext(struct ptb_chordtext *ct)
93 printf("\t\tName: %c%d\n", ct->name[0], ct->name[1]);
94 printf("\t\tOffset: %d\n", ct->offset);
98 void write_rhythmslash(struct ptb_rhythmslash *sl)
100 printf("\t\tOffset: %d\n", sl->offset);
101 printf("\t\tLength: %d\n", sl->length);
105 void write_direction(struct ptb_direction *dr)
110 void write_section(struct ptb_section *section)
112 printf("\tSection(%c): %s\n", section->letter, section->description);
113 printf("\tEnd-Mark: %d\n", section->end_mark);
114 printf("\tMeter Type: %d\n", section->meter_type);
115 printf("\tMetronome Pulses Per Measure: %d\n", section->metronome_pulses_per_measure);
116 printf("\tProperties: %d\n", section->properties);
117 printf("\tKey Extra: %d\n", section->key_extra);
118 printf("\tPosition Width: %d\n", section->position_width);
120 if (section->staffs) {
121 printf("\t Staffs:\n");
122 PRINT_LIST(section->staffs, struct ptb_staff *, write_staff);
125 if (section->chordtexts) {
126 printf("\t Chordtexts:\n");
127 PRINT_LIST(section->chordtexts, struct ptb_chordtext *, write_chordtext);
130 if (section->rhythmslashes) {
131 printf("\t Rhythmslashes:\n");
132 PRINT_LIST(section->rhythmslashes, struct ptb_rhythmslash *, write_rhythmslash);
135 if (section->directions) {
136 printf("\t Directions:\n");
137 PRINT_LIST(section->directions, struct ptb_direction *, write_direction);
140 if (section->musicbars) {
141 printf("\t Music Bars:\n");
142 PRINT_LIST(section->musicbars, struct ptb_musicbar *, write_musicbar);
148 void write_sectionsymbol(struct ptb_sectionsymbol *ssb)
150 printf("\tRepeat Ending: %d\n", ssb->repeat_ending);
154 void write_tempomarker(struct ptb_tempomarker *tm)
156 printf("\tDescription: %s\n", tm->description);
157 printf("\tType: %d\n", tm->type);
158 printf("\tBPM: %d\n", tm->bpm);
159 printf("\tSection: %d\n", tm->section);
160 printf("\tOffset: %d\n", tm->offset);
164 void write_dynamic(struct ptb_dynamic *dn)
166 printf("\tOffset: %d\n", dn->offset);
167 printf("\tStaff: %d\n", dn->staff);
168 printf("\tVolume: %d\n", dn->volume);
172 void write_guitar(struct ptb_guitar *gtr)
175 printf("\tNumber: %d\n", gtr->index);
176 printf("\tTitle: %s\n", gtr->title);
177 printf("\tType: %s\n", gtr->type);
178 printf("\tStrings(%d):\n", gtr->nr_strings);
179 for (i = 0; i < gtr->nr_strings; i++)
180 printf("\t\t%d\n", gtr->strings[i]);
182 printf("\tReverb: %d\n", gtr->reverb);
183 printf("\tChorus: %d\n", gtr->chorus);
184 printf("\tTremolo: %d\n", gtr->chorus);
185 printf("\tPan: %d\n", gtr->pan);
186 printf("\tCapo on fret: %d\n", gtr->capo);
187 printf("\tInitial volume: %d\n", gtr->initial_volume);
188 printf("\tMidi Instrument: %d\n", gtr->midi_instrument);
189 printf("\tHalf up(?): %d\n", gtr->half_up);
190 printf("\tSimulate (?): %d\n", gtr->simulate);
194 void write_guitarin(struct ptb_guitarin *gtr)
196 printf("\tOffset: %d\n", gtr->offset);
197 printf("\tSection: %d\n", gtr->section);
198 printf("\tStaff: %d\n", gtr->staff);
199 printf("\tRhythmslash: %d\n", gtr->rhythm_slash);
200 printf("\tStaff In(?): %d\n", gtr->staff_in);
204 void write_chorddiagram(struct ptb_chorddiagram *chd)
207 printf("\tName: %c%c\n", chd->name[0], chd->name[1]);
208 printf("\tFret Offset: %d\n", chd->frets);
209 printf("\tType: %d\n", chd->type);
210 printf("\tTones(%d): \n", chd->nr_strings);
211 for (i = 0; i < chd->nr_strings; i++)
212 printf("\t\t%d\n", chd->tones[i]);
216 void write_font(struct ptb_font *font)
218 printf("%s, Size: %d, Thickness: %d, Underlined: %d, Italic: %d", font->family, font->size, font->thickness, font->underlined, font->italic);
221 void write_floatingtext(struct ptb_floatingtext *ft)
223 printf("\tText: %s\n", ft->text);
224 printf("\tOffset: %d\n", ft->offset);
225 printf("\tAlignment: ");
226 switch (ft->alignment & (ALIGN_LEFT|ALIGN_CENTER|ALIGN_RIGHT)) {
227 case ALIGN_LEFT: printf("Left");break;
228 case ALIGN_CENTER: printf("Center"); break;
229 case ALIGN_RIGHT: printf("Right"); break;
231 if (ft->alignment & ALIGN_TIMESTAMP) printf(", Print Timestamp");
233 printf("\tFont: "); write_font(&ft->font); printf("\n");
238 void write_praudio_info(struct ptb_hdr *hdr)
240 printf("Audio Type: ");
241 switch(hdr->class_info.song.release_info.pr_audio.type)
243 case AUDIO_TYPE_SINGLE: printf("Single\n"); break;
244 case AUDIO_TYPE_EP: printf("EP\n"); break;
245 case AUDIO_TYPE_ALBUM: printf("Album\n"); break;
246 case AUDIO_TYPE_DOUBLE_ALBUM: printf("Double Album\n"); break;
247 case AUDIO_TYPE_TRIPLE_ALBUM: printf("Triple Album\n"); break;
248 case AUDIO_TYPE_BOXSET: printf("Boxset\n"); break;
250 COND_PRINTF("Album Title", hdr->class_info.song.release_info.pr_audio.album_title);
251 printf("Year: %d\n", hdr->class_info.song.release_info.pr_audio.year);
252 printf("Live recording? %s\n", hdr->class_info.song.release_info.pr_audio.is_live_recording?"Yes":"No");
255 void write_prvideo_info(struct ptb_hdr *hdr)
257 COND_PRINTF("Video Title", hdr->class_info.song.release_info.pr_video.video_title);
258 printf("Year: %d\n", hdr->class_info.song.release_info.pr_video.year);
259 printf("Live recording? %s\n", hdr->class_info.song.release_info.pr_video.is_live_recording?"Yes":"No");
262 void write_bootleg_info(struct ptb_hdr *hdr)
264 COND_PRINTF("Bootleg Title", hdr->class_info.song.release_info.bootleg.title);
265 printf("Date: %d-%d-%d\n",
266 hdr->class_info.song.release_info.bootleg.day,
267 hdr->class_info.song.release_info.bootleg.month,
268 hdr->class_info.song.release_info.bootleg.year);
271 void write_song_info(struct ptb_hdr *hdr)
273 COND_PRINTF("Title", hdr->class_info.song.title);
274 COND_PRINTF("Artist", hdr->class_info.song.artist);
275 COND_PRINTF("Words By", hdr->class_info.song.words_by);
276 COND_PRINTF("Music By", hdr->class_info.song.music_by);
277 COND_PRINTF("Arranged By", hdr->class_info.song.arranged_by);
278 COND_PRINTF("Guitar Transcribed By", hdr->class_info.song.guitar_transcribed_by);
279 COND_PRINTF("Bass Transcribed By", hdr->class_info.song.bass_transcribed_by);
280 if(hdr->class_info.song.lyrics)
281 printf("Lyrics\n----------\n%s\n\n", hdr->class_info.song.lyrics);
282 COND_PRINTF("Copyright", hdr->class_info.song.copyright);
284 printf("Release type: ");
285 switch(hdr->class_info.song.release_type) {
286 case RELEASE_TYPE_PR_AUDIO:
287 printf("Public Release (Audio)\n");
288 write_praudio_info(hdr);
290 case RELEASE_TYPE_PR_VIDEO:
291 printf("Public Release (Video)\n");
292 write_prvideo_info(hdr);
294 case RELEASE_TYPE_BOOTLEG:
296 write_bootleg_info(hdr);
298 case RELEASE_TYPE_UNRELEASED:
299 printf("Unreleased\n");
304 void write_lesson_info(struct ptb_hdr *hdr)
306 COND_PRINTF("Title", hdr->class_info.lesson.title);
307 COND_PRINTF("Artist", hdr->class_info.lesson.artist);
308 printf("Style: %d\n", hdr->class_info.lesson.style);
310 switch(hdr->class_info.lesson.level) {
311 case LEVEL_BEGINNER: printf("Beginner"); break;
312 case LEVEL_INTERMEDIATE: printf("Intermediate"); break;
313 case LEVEL_ADVANCED: printf("Advanced"); break;
315 COND_PRINTF("Author", hdr->class_info.lesson.author);
316 COND_PRINTF("Copyright", hdr->class_info.lesson.copyright);
319 int main(int argc, const char **argv)
327 struct poptOption options[] = {
329 {"debug", 'd', POPT_ARG_NONE, &debugging, 0, "Turn on debugging output" },
330 {"tree", 't', POPT_ARG_NONE, &tree, 't', "Print tree of PowerTab file" },
331 {"version", 'v', POPT_ARG_NONE, &version, 'v', "Show version information" },
335 pc = poptGetContext(argv[0], argc, argv, options, 0);
336 poptSetOtherOptionHelp(pc, "file.ptb");
337 while((c = poptGetNextOpt(pc)) >= 0) {
340 printf("ptbinfo Version "PACKAGE_VERSION"\n");
341 printf("(C) 2004 Jelmer Vernooij <jelmer@samba.org>\n");
347 ptb_set_debug(debugging);
348 ptb_set_asserts_fatal(0);
350 if(!poptPeekArg(pc)) {
351 poptPrintUsage(pc, stderr, 0);
354 ret = ptb_read_file(poptGetArg(pc));
357 perror("Read error: ");
361 printf("File type: ");
362 switch(ret->hdr.classification) {
363 case CLASSIFICATION_SONG:
365 write_song_info(&ret->hdr);
367 case CLASSIFICATION_LESSON:
369 write_lesson_info(&ret->hdr);
376 DLIST_LEN(ret->instrument[0].sections, tmp1, struct ptb_section *);
377 DLIST_LEN(ret->instrument[1].sections, tmp2, struct ptb_section *);
378 printf("Number of sections: \tRegular: %d Bass: %d\n", tmp1, tmp2);
380 DLIST_LEN(ret->instrument[0].guitars, tmp1, struct ptb_guitar *);
381 DLIST_LEN(ret->instrument[1].guitars, tmp2, struct ptb_guitar *);
383 printf("Number of guitars: \tRegular: %d Bass: %d\n", tmp1, tmp2);
389 for (i = 0; i < 2; i++) {
391 if (i == 0) printf("Guitar\n"); else printf("Bass\n");
393 if (ret->instrument[i].guitars) {
394 printf(" Guitars:\n");
395 PRINT_LIST(ret->instrument[i].guitars, struct ptb_guitar *, write_guitar);
398 if (ret->instrument[i].guitarins) {
399 printf(" GuitarIns:\n");
400 PRINT_LIST(ret->instrument[i].guitarins, struct ptb_guitarin *, write_guitarin);
403 if (ret->instrument[i].chorddiagrams) {
404 printf(" Chord Diagrams:\n");
405 PRINT_LIST(ret->instrument[i].chorddiagrams, struct ptb_chorddiagram *, write_chorddiagram);
408 if (ret->instrument[i].tempomarkers) {
409 printf(" Tempo Markers:\n");
410 PRINT_LIST(ret->instrument[i].tempomarkers, struct ptb_tempomarker *, write_tempomarker);
413 if (ret->instrument[i].dynamics) {
414 printf(" Dynamics:\n");
415 PRINT_LIST(ret->instrument[i].dynamics, struct ptb_dynamic *, write_dynamic);
418 if (ret->instrument[i].floatingtexts) {
419 printf(" Floating Texts:\n");
420 PRINT_LIST(ret->instrument[i].floatingtexts, struct ptb_floatingtext *, write_floatingtext);
423 if (ret->instrument[i].sectionsymbols) {
424 printf(" Section Symbols:\n");
425 PRINT_LIST(ret->instrument[i].sectionsymbols, struct ptb_sectionsymbol *, write_sectionsymbol);
428 if (ret->instrument[i].sections) {
429 printf(" Sections:\n");
430 PRINT_LIST(ret->instrument[i].sections, struct ptb_section *, write_section);
434 printf("Default Font: "); write_font(&ret->default_font); printf("\n");
435 printf("Chord Name Font: "); write_font(&ret->chord_name_font); printf("\n");
436 printf("Tablature Font: "); write_font(&ret->tablature_font); printf("\n");