2 * Copyright (C) 2017-2019 Robin Gareus <robin@gareus.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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 using namespace ARDOUR;
29 using namespace SessionUtils;
34 // help2man compatible format (standard GNU help-text)
35 printf (UTILNAME " - create a new empty session from the commandline.\n\n");
36 printf ("Usage: " UTILNAME " [ OPTIONS ] <session-dir> [session-name]\n\n");
38 -h, --help display this help and exit\n\
39 -s, --samplerate <rate> samplerate to use (default 48000)\n\
40 -V, --version print version information and exit\n\
44 This tool creates a new empty Ardour session.\n\
46 If the session-name is unspecified, the sesion-dir-name is used.\n\
47 If specified, the tool expects a session-name without .ardour\n\
48 file-name extension.\n\
53 " UTILNAME " -s 44100 /tmp/TestSession TestSession\n\
56 printf ("Report bugs to <http://tracker.ardour.org/>\n"
57 "Website: <http://ardour.org/>\n");
58 ::exit (EXIT_SUCCESS);
61 int main (int argc, char* argv[])
63 int sample_rate = 48000;
65 const char *optstring = "hs:V";
67 const struct option longopts[] = {
68 { "help", 0, 0, 'h' },
69 { "samplerate", 1, 0, 's' },
70 { "version", 0, 0, 'V' },
74 while (EOF != (c = getopt_long (argc, argv,
75 optstring, longopts, (int *) 0))) {
79 const int sr = atoi (optarg);
80 if (sr >= 8000 && sr <= 192000) {
83 fprintf(stderr, "Invalid Samplerate\n");
89 printf ("ardour-utils version %s\n\n", VERSIONSTRING);
90 printf ("Copyright (C) GPL 2017 Robin Gareus <robin@gareus.org>\n");
99 cerr << "Error: unrecognized option. See --help for usage information.\n";
100 ::exit (EXIT_FAILURE);
105 std::string snapshot_name;
107 if (optind + 2 == argc) {
108 snapshot_name = argv[optind+1];
109 } else if (optind + 1 == argc) {
110 snapshot_name = Glib::path_get_basename (argv[optind]);
112 cerr << "Error: Missing parameter. See --help for usage information.\n";
113 ::exit (EXIT_FAILURE);
116 if (snapshot_name.empty ()) {
117 cerr << "Error: Invalid empty session/snapshot name.\n";
118 ::exit (EXIT_FAILURE);
123 SessionUtils::init();
126 s = SessionUtils::create_session (argv[optind], snapshot_name, sample_rate);
128 /* save is implicit when creating a new session */
131 std::cout << "Created session in '" << s->path () <<"'" << std::endl;
134 SessionUtils::unload_session (s);
135 SessionUtils::cleanup();