summaryrefslogtreecommitdiff
path: root/ptgenmissing.cc
blob: b874b17af351018f77a5bcb2ca97602a66e2d8d0 (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
/*
 * 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/ptfformat.h"
#include <inttypes.h> // PRIx
#include <cstdio>

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 open ptf, quit\n");
		exit(-1);
		break;
	case 0:
		printf("#!/bin/bash\nset -e\nmkdir \"Audio Files\"\n");
		for (vector<PTFFormat::wav_t>::iterator a = ptf.audiofiles.begin();
					a != ptf.audiofiles.end(); ++a) {
			if (!a->length) {
				printf("# unknown length : %s\n", a->filename.c_str());
			} else {
				printf("sox --no-clobber -S -n -r %" PRId64 " -c 1 -b 16 \"Audio Files\"/\"%s\" synth %" PRId64 "s sine 1000 gain -18\n",
					ptf.sessionrate,
					a->filename.c_str(),
					a->length
				);
			}
		}
		break;
	}
	exit(0);
}