2 Copyright (C) 2006 Paul Davis
4 This program is free software; you can redistribute it
5 and/or modify it under the terms of the GNU Lesser
6 General Public License as published by the Free Software
7 Foundation; either version 2 of the License, or (at your
8 option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <pbd/pthread_utils.h>
23 #include <ardour/session.h>
24 #include <ardour/location.h>
26 #include <control_protocol/basic_ui.h>
30 using namespace ARDOUR;
31 using ARDOUR::nframes_t;
33 sigc::signal<void,std::string,std::string> BasicUI::AccessAction;
35 BasicUI::BasicUI (Session& s)
51 BasicUI::register_thread (std::string name)
53 PBD::ThreadCreated (pthread_self(), name);
58 BasicUI::access_action ( std::string action_path )
60 int split_at = action_path.find( "/" );
61 std::string group = action_path.substr( 0, split_at );
62 std::string item = action_path.substr( split_at + 1 );
64 AccessAction( group, item );
68 BasicUI::loop_toggle ()
70 if (session->get_play_loop()) {
71 session->request_play_loop (false);
73 session->request_play_loop (true);
74 if (!session->transport_rolling()) {
75 session->request_transport_speed (1.0);
81 BasicUI::goto_start ()
83 session->goto_start ();
93 BasicUI::add_marker ()
95 nframes_t when = session->audible_frame();
96 session->locations()->add (new Location (when, when, _("unnamed"), Location::IsMark));
102 session->request_transport_speed (-2.0f);
108 session->request_transport_speed (2.0f);
112 BasicUI::transport_stop ()
114 session->request_transport_speed (0.0);
118 BasicUI::transport_play (bool from_last_start)
120 bool rolling = session->transport_rolling ();
122 if (session->get_play_loop()) {
123 session->request_play_loop (false);
126 if (session->get_play_range ()) {
127 session->request_play_range (false);
130 if (from_last_start && rolling) {
131 session->request_locate (session->last_transport_start(), true);
135 session->request_transport_speed (1.0f);
139 BasicUI::rec_enable_toggle ()
141 switch (session->record_status()) {
142 case Session::Disabled:
143 if (session->ntracks() == 0) {
144 // string txt = _("Please create 1 or more track\nbefore trying to record.\nCheck the Session menu.");
145 // MessageDialog msg (*editor, txt);
149 session->maybe_enable_record ();
151 case Session::Recording:
152 case Session::Enabled:
153 session->disable_record (true);
158 BasicUI::save_state ()
160 session->save_state ("");
164 BasicUI::prev_marker ()
166 Location *location = session->locations()->first_location_before (session->transport_frame());
169 session->request_locate (location->start(), session->transport_rolling());
171 session->goto_start ();
176 BasicUI::next_marker ()
178 Location *location = session->locations()->first_location_after (session->transport_frame());
181 session->request_locate (location->start(), session->transport_rolling());
183 session->request_locate (session->current_end_frame());
188 BasicUI::set_transport_speed (float speed)
190 session->request_transport_speed (speed);
194 BasicUI::get_transport_speed ()
196 return session->transport_speed ();
212 BasicUI::toggle_all_rec_enables ()
214 if (session->get_record_enabled()) {
215 session->record_disenable_all ();
217 session->record_enable_all ();
222 BasicUI::toggle_punch_in ()
224 Config->set_punch_in (!Config->get_punch_in());
228 BasicUI::toggle_punch_out ()
230 Config->set_punch_out (!Config->get_punch_out());
234 BasicUI::get_record_enabled ()
236 return session->get_record_enabled();
240 BasicUI::set_record_enable (bool yn)
243 session->maybe_enable_record ();
245 session->disable_record (false, true);
250 BasicUI::transport_frame ()
252 return session->transport_frame();
256 BasicUI::locate (nframes_t where, bool roll_after_locate)
258 session->request_locate (where, roll_after_locate);
264 return session->locate_pending();
270 return session->transport_locked ();
274 BasicUI::smpte_frames_per_hour ()
276 return session->smpte_frames_per_hour ();
280 BasicUI::smpte_time (nframes_t where, SMPTE::Time& smpte)
282 session->smpte_time (where, *((SMPTE::Time *) &smpte));
286 BasicUI::smpte_to_sample (SMPTE::Time& smpte, nframes_t& sample, bool use_offset, bool use_subframes) const
288 session->smpte_to_sample (*((SMPTE::Time*)&smpte), sample, use_offset, use_subframes);
292 BasicUI::sample_to_smpte (nframes_t sample, SMPTE::Time& smpte, bool use_offset, bool use_subframes) const
294 session->sample_to_smpte (sample, *((SMPTE::Time*)&smpte), use_offset, use_subframes);