5 #include "pbd/failed_constructor.h"
9 #include "ardour/ardour.h"
10 #include "ardour/audioengine.h"
11 #include "ardour/session.h"
16 using namespace ARDOUR;
19 static const char* localedir = LOCALEDIR;
21 TestReceiver test_receiver;
23 /** @param dir Session directory.
24 * @param state Session state file, without .ardour suffix.
27 load_session (string dir, string state)
29 SessionEvent::create_per_thread_pool ("test", 512);
31 test_receiver.listen_to (error);
32 test_receiver.listen_to (info);
33 test_receiver.listen_to (fatal);
34 test_receiver.listen_to (warning);
36 AudioEngine* engine = AudioEngine::create ();
38 if (!engine->set_default_backend ()) {
39 std::cerr << "Cannot create Audio/MIDI engine\n";
45 if (engine->start () != 0) {
46 std::cerr << "Cannot start Audio/MIDI engine\n";
50 Session* session = new Session (*engine, dir, state);
51 engine->set_session (session);
55 string session_name = "";
56 string backend_client_name = "ardour";
57 string backend_session_uuid;
58 bool just_version = false;
60 bool try_hw_optimization = true;
61 bool no_connect_ports = false;
66 cout << "Usage: hardour [OPTIONS]... DIR SNAPSHOT_NAME\n\n"
67 << " DIR Directory/Folder to load session from\n"
68 << " SNAPSHOT_NAME Name of session/snapshot to load (without .ardour at end\n"
69 << " -v, --version Show version information\n"
70 << " -h, --help Print this message\n"
71 << " -c, --name <name> Use a specific backend client name, default is ardour\n"
72 << " -d, --disable-plugins Disable all plugins in an existing session\n"
73 << " -D, --debug <options> Set debug flags. Use \"-D list\" to see available options\n"
74 << " -O, --no-hw-optimizations Disable h/w specific optimizations\n"
75 << " -P, --no-connect-ports Do not connect any ports at startup\n"
76 #ifdef WINDOWS_VST_SUPPORT
77 << " -V, --novst Do not use VST support\n"
82 int main (int argc, char* argv[])
84 const char *optstring = "vhdD:c:VOU:P";
86 const struct option longopts[] = {
87 { "version", 0, 0, 'v' },
88 { "help", 0, 0, 'h' },
89 { "disable-plugins", 1, 0, 'd' },
90 { "debug", 1, 0, 'D' },
91 { "name", 1, 0, 'c' },
92 { "novst", 0, 0, 'V' },
93 { "no-hw-optimizations", 0, 0, 'O' },
94 { "uuid", 1, 0, 'U' },
95 { "no-connect-ports", 0, 0, 'P' },
103 c = getopt_long (argc, argv, optstring, longopts, &option_index);
123 backend_client_name = optarg;
127 ARDOUR::Session::set_disable_all_loaded_plugins (true);
131 if (PBD::parse_debug_options (optarg)) {
137 try_hw_optimization = false;
141 no_connect_ports = true;
145 #ifdef WINDOWS_VST_SUPPORT
147 #endif /* WINDOWS_VST_SUPPORT */
151 backend_session_uuid = optarg;
165 if (!ARDOUR::init (false, true, localedir)) {
166 cerr << "Ardour failed to initialize\n" << endl;
173 s = load_session (argv[optind], argv[optind+1]);
174 } catch (failed_constructor& e) {
175 cerr << "failed_constructor: " << e.what() << "\n";
177 } catch (AudioEngine::PortRegistrationFailure& e) {
178 cerr << "PortRegistrationFailure: " << e.what() << "\n";
180 } catch (exception& e) {
181 cerr << "exception: " << e.what() << "\n";
184 cerr << "unknown exception.\n";
188 s->request_transport_speed (1.0);
192 AudioEngine::instance()->remove_session ();
194 AudioEngine::instance()->stop ();
196 AudioEngine::destroy ();