Make Analyzer UI require instance-access
[calf.git] / src / calf / host_session.h
blob887f1865b6623aa4a4f315c375c06aa74c8b8d66
1 /* Calf DSP Library Utility Application - calfjackhost
2 * Class for managing calfjackhost's session.
4 * Copyright (C) 2007-2011 Krzysztof Foltman
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
21 #ifndef CALF_HOST_SESSION_H
22 #define CALF_HOST_SESSION_H
24 #include <config.h>
26 #include "gui.h"
27 #include "jackhost.h"
28 #include "session_mgr.h"
30 namespace calf_plugins {
32 class main_window;
34 class host_session: public main_window_owner_iface, public session_client_iface
36 private:
37 static host_session *instance;
39 static void session_callback(jack_session_event_t *event, void *arg);
40 void handle_jack_session_event(jack_session_event_t *event);
42 public:
43 /// Requested JACK client name.
44 std::string client_name;
45 /// Template for input names.
46 std::string input_name;
47 /// Template for output names.
48 std::string output_name;
49 /// Template for MIDI port names.
50 std::string midi_name;
51 /// Name of the file to load at start.
52 std::string load_name;
53 /// Use load_name as session state name - doesn't signal an error if the file doesn't exist, but uses it for saving.
54 bool only_load_if_exists;
55 /// Plugins to create on startup, in create_plugins_from_list (based on command line).
56 std::vector<std::string> plugin_names;
57 /// Requested presets for the plugins in plugin_names.
58 std::map<int, std::string> presets;
59 /// Selected session manager (if any).
60 session_manager_iface *session_manager;
61 /// Save has been requested from SIGUSR1 handler
62 volatile bool save_file_on_next_idle_call;
63 /// If non-zero, quit has been requested through signal with same value
64 volatile int quit_on_next_idle_call;
65 /// JACK session event to handle on the next idle call
66 jack_session_event_t *volatile handle_event_on_next_idle_call;
67 /// File name of the current rack
68 std::string current_filename;
69 /// Jack session ID, if given via command line, otherwise empty
70 std::string jack_session_id;
71 /// Command used to start the JACK host
72 std::string calfjackhost_cmd;
74 // these are not saved
75 jack_client client;
76 std::string autoconnect_midi;
77 int autoconnect_midi_index;
78 std::set<int> chains;
79 std::vector<jack_host *> plugins;
80 main_window_iface *main_win;
81 std::set<std::string> instances;
82 plugin_gui_window *gui_win;
83 session_environment_iface *session_env;
85 host_session(session_environment_iface *);
86 void open();
87 void add_plugin(std::string name, std::string preset, std::string instance_name = std::string());
88 void create_plugins_from_list();
89 void connect();
90 void close();
91 bool activate_preset(int plugin, const std::string &preset, bool builtin);
92 void remove_all_plugins();
93 std::string get_next_instance_name(const std::string &effect_name);
95 /// Set handlers for SIGUSR1 (that LADISH uses to invoke Save function), SIGTERM and SIGHUP
96 void set_signal_handlers();
98 /// unix signal handler
99 static void signal_handler(int signum);
101 /// Client name for window title bar
102 std::string get_client_name() const;
104 public:
105 /// Implementation of open file functionality (TODO)
106 virtual char *open_file(const char *name);
107 /// Implementation of save file functionality
108 virtual char *save_file(const char *name);
110 /// Load from session manager
111 virtual void load(session_load_iface *);
112 /// Save to session manager
113 virtual void save(session_save_iface *);
115 virtual void new_plugin(const char *name);
116 virtual void remove_plugin(plugin_ctl_iface *plugin);
117 virtual void on_main_window_destroy();
118 virtual void on_idle();
119 virtual void reorder_plugins();
120 virtual std::string get_current_filename() const;
121 virtual void set_current_filename(const std::string &name);
122 ~host_session();
127 #endif