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 #ifdef PLATFORM_WINDOWS
21 #define sleep(X) Sleep((X) * 1000)
24 static const char* localedir = LOCALEDIR;
26 TestReceiver test_receiver;
28 /** @param dir Session directory.
29 * @param state Session state file, without .ardour suffix.
32 load_session (string dir, string state)
34 SessionEvent::create_per_thread_pool ("test", 512);
36 test_receiver.listen_to (error);
37 test_receiver.listen_to (info);
38 test_receiver.listen_to (fatal);
39 test_receiver.listen_to (warning);
41 AudioEngine* engine = AudioEngine::create ();
43 if (!engine->set_default_backend ()) {
44 std::cerr << "Cannot create Audio/MIDI engine\n";
48 if (engine->start () != 0) {
49 std::cerr << "Cannot start Audio/MIDI engine\n";
53 Session* session = new Session (*engine, dir, state);
54 engine->set_session (session);
58 string session_name = "";
59 string backend_client_name = "ardour";
60 string backend_session_uuid;
61 bool just_version = false;
63 bool try_hw_optimization = true;
64 bool no_connect_ports = false;
69 cout << "Usage: hardour [OPTIONS]... DIR SNAPSHOT_NAME\n\n"
70 << " DIR Directory/Folder to load session from\n"
71 << " SNAPSHOT_NAME Name of session/snapshot to load (without .ardour at end\n"
72 << " -v, --version Show version information\n"
73 << " -h, --help Print this message\n"
74 << " -c, --name <name> Use a specific backend client name, default is ardour\n"
75 << " -d, --disable-plugins Disable all plugins in an existing session\n"
76 << " -D, --debug <options> Set debug flags. Use \"-D list\" to see available options\n"
77 << " -O, --no-hw-optimizations Disable h/w specific optimizations\n"
78 << " -P, --no-connect-ports Do not connect any ports at startup\n"
79 #ifdef WINDOWS_VST_SUPPORT
80 << " -V, --novst Do not use VST support\n"
85 int main (int argc, char* argv[])
87 const char *optstring = "vhBdD:c:VOU:P";
89 const struct option longopts[] = {
90 { "version", 0, 0, 'v' },
91 { "help", 0, 0, 'h' },
92 { "bypass-plugins", 1, 0, 'B' },
93 { "disable-plugins", 1, 0, 'd' },
94 { "debug", 1, 0, 'D' },
95 { "name", 1, 0, 'c' },
96 { "novst", 0, 0, 'V' },
97 { "no-hw-optimizations", 0, 0, 'O' },
98 { "uuid", 1, 0, 'U' },
99 { "no-connect-ports", 0, 0, 'P' },
103 int option_index = 0;
107 c = getopt_long (argc, argv, optstring, longopts, &option_index);
127 backend_client_name = optarg;
131 ARDOUR::Session::set_bypass_all_loaded_plugins (true);
135 ARDOUR::Session::set_disable_all_loaded_plugins (true);
139 if (PBD::parse_debug_options (optarg)) {
145 try_hw_optimization = false;
149 no_connect_ports = true;
153 #ifdef WINDOWS_VST_SUPPORT
155 #endif /* WINDOWS_VST_SUPPORT */
159 backend_session_uuid = optarg;
173 if (!ARDOUR::init (false, true, localedir)) {
174 cerr << "Ardour failed to initialize\n" << endl;
181 s = load_session (argv[optind], argv[optind+1]);
182 } catch (failed_constructor& e) {
183 cerr << "failed_constructor: " << e.what() << "\n";
185 } catch (AudioEngine::PortRegistrationFailure& e) {
186 cerr << "PortRegistrationFailure: " << e.what() << "\n";
188 } catch (exception& e) {
189 cerr << "exception: " << e.what() << "\n";
192 cerr << "unknown exception.\n";
196 s->request_transport_speed (1.0);
200 AudioEngine::instance()->remove_session ();
202 AudioEngine::instance()->stop ();
204 AudioEngine::destroy ();