10 using namespace ARDOUR;
11 using namespace SessionUtils;
14 static void usage (int status)
16 // help2man compatible format (standard GNU help-text)
17 printf (UTILNAME " - create a new empty session from the commandline.\n\n");
18 printf ("Usage: " UTILNAME " [ OPTIONS ] <session-dir> [session-name]\n\n");
20 -h, --help display this help and exit\n\
21 -s, --samplerate <rate> samplerate to use (default 48000)\n\
22 -V, --version print version information and exit\n\
26 This tool creates a new empty Ardour session.\n\
28 If the session-name is unspecified, the sesion-dir-name is used.\n\
29 If specified, the tool expects a session-name without .ardour\n\
30 file-name extension.\n\
35 " UTILNAME " -s 44100 /tmp/TestSession TestSession\n\
38 printf ("Report bugs to <http://tracker.ardour.org/>\n"
39 "Website: <http://ardour.org/>\n");
43 int main (int argc, char* argv[])
45 int sample_rate = 48000;
47 const char *optstring = "hs:V";
49 const struct option longopts[] = {
50 { "help", 0, 0, 'h' },
51 { "samplerate", 1, 0, 's' },
52 { "version", 0, 0, 'V' },
56 while (EOF != (c = getopt_long (argc, argv,
57 optstring, longopts, (int *) 0))) {
61 const int sr = atoi (optarg);
62 if (sr >= 8000 && sr <= 192000) {
65 fprintf(stderr, "Invalid Samplerate\n");
71 printf ("ardour-utils version %s\n\n", VERSIONSTRING);
72 printf ("Copyright (C) GPL 2017 Robin Gareus <robin@gareus.org>\n");
86 std::string snapshot_name;
88 if (optind + 2 == argc) {
89 snapshot_name = argv[optind+1];
90 } else if (optind + 1 == argc) {
91 snapshot_name = Glib::path_get_basename (argv[optind]);
96 if (snapshot_name.empty ()) {
97 fprintf(stderr, "Error: Invalid empty session/snapshot name.\n");
98 ::exit (EXIT_FAILURE);
103 SessionUtils::init();
106 s = SessionUtils::create_session (argv[optind], snapshot_name, sample_rate);
108 /* save is implicit when creating a new session */
111 std::cout << "Created session in '" << s->path () <<"'" << std::endl;
114 SessionUtils::unload_session (s);
115 SessionUtils::cleanup();