summaryrefslogtreecommitdiff
path: root/ptftool.cc
blob: e56e467726e11450f00cbd2fa976fa62d7a05645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
    Copyright (C) 2015  Damien Zammit

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

*/

#include "ptfformat.h"
using namespace std;
using std::string;

int main (int argc, char **argv) {
	PTFFormat ptf;
	int ok;

	if (argc == 1) {
		printf("No ptf file specified, quit\n");
		exit(0);
	}

	ok = ptf.load(argv[1]);

	switch (ok) {
	case -1:
		printf("Cannot open ptf, quit\n");
		exit(-1);
		break;
	case 0:
		if (ptf.audiofiles.size() > 0) {
			printf("%d wavs, %d regions, %d tracks\n\n",
				ptf.audiofiles.size(),
				ptf.regions.size(),
				ptf.tracks.size()
				);
			printf("Audio file @ offset, length:\n");
			for (vector<PTFFormat::wav_t>::iterator
					a = ptf.audiofiles.begin();
					a != ptf.audiofiles.end(); ++a) {
				//printf("%s @ %lu, len=%lu\n", a->filename.c_str(),
				printf("%d %s @ 0x%08x, len=0x%08x\n",
					a->index,
					a->filename.c_str(),
					a->posabsolute,
					a->length);
			}
			
			printf("\nRegion (WAV file) @ into-sample, length:\n");
			for (vector<PTFFormat::region_t>::iterator
					a = ptf.regions.begin();
					a != ptf.regions.end(); ++a) {
				//printf("%s (%s) @ %lu + %lu, len=%lu\n", a->name.c_str(),
				printf("%d %s (%d) @ 0x%08x, len=0x%08x\n",
					a->index,
					a->name.c_str(),
					a->wave.index,
					a->sampleoffset,
					a->length);
			}

			printf("\nTrack (region#) @ absolute:\n");
			for (vector<PTFFormat::track_t>::iterator
					a = ptf.tracks.begin();
					a != ptf.tracks.end(); ++a) {
				//printf("%s (%s) @ %lu + %lu, len=%lu\n", a->name.c_str(),
				printf("%s (%d) @ 0x%08x\n",
					a->name.c_str(),
					a->reg.index,
					a->startpos);
			}
		} else {
			printf("No audio files in session, quit\n");
		}
		break;
	default:
		printf("Missing LUT 0x%02x, quit\n", ok);
		exit(ok);
		break;
	}
	exit(0);
}