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";
50 if (engine->start () != 0) {
51 std::cerr << "Cannot start Audio/MIDI engine\n";
55 Session* session = new Session (*engine, dir, state);
56 engine->set_session (session);
60 string session_name = "";
61 string backend_client_name = "ardour";
62 string backend_session_uuid;
63 bool just_version = false;
65 bool try_hw_optimization = true;
66 bool no_connect_ports = false;
71 cout << "Usage: hardour [OPTIONS]... DIR SNAPSHOT_NAME\n\n"
72 << " DIR Directory/Folder to load session from\n"
73 << " SNAPSHOT_NAME Name of session/snapshot to load (without .ardour at end\n"
74 << " -v, --version Show version information\n"
75 << " -h, --help Print this message\n"
76 << " -c, --name <name> Use a specific backend client name, default is ardour\n"
77 << " -d, --disable-plugins Disable all plugins in an existing session\n"
78 << " -D, --debug <options> Set debug flags. Use \"-D list\" to see available options\n"
79 << " -O, --no-hw-optimizations Disable h/w specific optimizations\n"
80 << " -P, --no-connect-ports Do not connect any ports at startup\n"
81 #ifdef WINDOWS_VST_SUPPORT
82 << " -V, --novst Do not use VST support\n"
87 int main (int argc, char* argv[])
89 const char *optstring = "vhBdD:c:VOU:P";
91 const struct option longopts[] = {
92 { "version", 0, 0, 'v' },
93 { "help", 0, 0, 'h' },
94 { "bypass-plugins", 1, 0, 'B' },
95 { "disable-plugins", 1, 0, 'd' },
96 { "debug", 1, 0, 'D' },
97 { "name", 1, 0, 'c' },
98 { "novst", 0, 0, 'V' },
99 { "no-hw-optimizations", 0, 0, 'O' },
100 { "uuid", 1, 0, 'U' },
101 { "no-connect-ports", 0, 0, 'P' },
105 int option_index = 0;
109 c = getopt_long (argc, argv, optstring, longopts, &option_index);
129 backend_client_name = optarg;
133 ARDOUR::Session::set_bypass_all_loaded_plugins (true);
137 ARDOUR::Session::set_disable_all_loaded_plugins (true);
141 if (PBD::parse_debug_options (optarg)) {
147 try_hw_optimization = false;
151 no_connect_ports = true;
155 #ifdef WINDOWS_VST_SUPPORT
157 #endif /* WINDOWS_VST_SUPPORT */
161 backend_session_uuid = optarg;
175 if (!ARDOUR::init (false, true, localedir)) {
176 cerr << "Ardour failed to initialize\n" << endl;
183 s = load_session (argv[optind], argv[optind+1]);
184 } catch (failed_constructor& e) {
185 cerr << "failed_constructor: " << e.what() << "\n";
187 } catch (AudioEngine::PortRegistrationFailure& e) {
188 cerr << "PortRegistrationFailure: " << e.what() << "\n";
190 } catch (exception& e) {
191 cerr << "exception: " << e.what() << "\n";
194 cerr << "unknown exception.\n";
198 s->request_transport_speed (1.0);
202 AudioEngine::instance()->remove_session ();
204 AudioEngine::instance()->stop ();
206 AudioEngine::destroy ();