-
Notifications
You must be signed in to change notification settings - Fork 18
/
ptftool.cc
145 lines (134 loc) · 3.93 KB
/
ptftool.cc
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* libptformat - a library to read ProTools sessions
*
* Copyright (C) 2015 Damien Zammit
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "ptformat/ptformat.h"
#include <inttypes.h> // PRIxyy
#include <cstdio>
#include <stdlib.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], 48000);
switch (ok) {
default:
case -1:
printf("Cannot decrypt ptf, quit\n");
exit(-1);
break;
case -2:
printf("Cannot extract version from ptf, quit\n");
exit(-1);
break;
case -3:
printf("Unsupported ptf version, quit\n");
exit(-1);
break;
case -4:
printf("Cannot parse ptf, quit\n");
exit(-1);
break;
case 0:
printf("ProTools %d Session: Samplerate = %" PRId64 "Hz\nTarget samplerate = 48000\n\n", ptf.version(), ptf.sessionrate());
printf("%zu wavs, %zu regions, %zu active regions\n\n",
ptf.audiofiles().size(),
ptf.regions().size(),
ptf.tracks().size()
);
printf("Audio file (WAV#) @ offset, length:\n");
for (vector<PTFFormat::wav_t>::const_iterator
a = ptf.audiofiles().begin();
a != ptf.audiofiles().end(); ++a) {
printf("`%s` w(%d) @ %" PRIu64 ", %" PRIu64 "\n",
a->filename.c_str(),
a->index,
a->posabsolute,
a->length);
}
printf("\nRegion (Region#) (WAV#) @ into-sample, length:\n");
for (vector<PTFFormat::region_t>::const_iterator
a = ptf.regions().begin();
a != ptf.regions().end(); ++a) {
printf("`%s` r(%d) w(%d) @ %" PRIu64 ", %" PRIu64 "\n",
a->name.c_str(),
a->index,
a->wave.index,
a->sampleoffset,
a->length);
}
printf("\nMIDI Region (Region#) @ into-sample, length:\n");
for (vector<PTFFormat::region_t>::const_iterator
a = ptf.midiregions().begin();
a != ptf.midiregions().end(); ++a) {
printf("`%s` r(%d) @ %" PRIu64 ", %" PRIu64 "\n",
a->name.c_str(),
a->index,
a->sampleoffset,
a->length);
for (vector<PTFFormat::midi_ev_t>::const_iterator
b = a->midi.begin();
b != a->midi.end(); ++b) {
printf(" MIDI: n(%d) v(%d) @ %" PRIu64 ", %" PRIu64 "\n",
b->note, b->velocity,
b->pos, b->length);
}
}
printf("\nTrack name (Track#) (Region#) @ Absolute:\n");
for (vector<PTFFormat::track_t>::const_iterator
a = ptf.tracks().begin();
a != ptf.tracks().end(); ++a) {
printf("`%s` t(%d) r(%d) @ %" PRIu64 "\n",
a->name.c_str(),
a->index,
a->reg.index,
a->reg.startpos);
}
printf("\nMIDI Track name (MIDITrack#) (MIDIRegion#) @ Absolute:\n");
for (vector<PTFFormat::track_t>::const_iterator
a = ptf.miditracks().begin();
a != ptf.miditracks().end(); ++a) {
printf("`%s` mt(%d) mr(%d) @ %" PRIu64 "\n",
a->name.c_str(),
a->index,
a->reg.index,
a->reg.startpos);
}
printf("\nTrack name (Track#) (WAV filename) @ Absolute + Into-sample, Length:\n");
for (vector<PTFFormat::track_t>::const_iterator
a = ptf.tracks().begin();
a != ptf.tracks().end(); ++a) {
printf("`%s` t(%d) (%s) @ %" PRIu64 " + %" PRIu64 ", %" PRIu64 "\n",
a->name.c_str(),
a->index,
a->reg.wave.filename.c_str(),
a->reg.startpos,
a->reg.sampleoffset,
a->reg.length
);
}
break;
}
exit(0);
}