2005-09-25 14:42:24 -04:00
/*
2019-08-02 17:26:43 -04:00
* Copyright ( C ) 2005 - 2007 Doug McLain < doug @ nostar . net >
* Copyright ( C ) 2005 - 2017 Tim Mayberry < mojofunk @ gmail . com >
* Copyright ( C ) 2005 - 2019 Paul Davis < paul @ linuxaudiosystems . com >
* Copyright ( C ) 2005 Karsten Wiese < fzuuzf @ googlemail . com >
* Copyright ( C ) 2005 Taybin Rutkin < taybin @ taybin . com >
* Copyright ( C ) 2006 - 2015 David Robillard < d @ drobilla . net >
* Copyright ( C ) 2007 - 2012 Carl Hetherington < carl @ carlh . net >
* Copyright ( C ) 2008 - 2010 Sakari Bergen < sakari . bergen @ beatwaves . net >
* Copyright ( C ) 2012 - 2019 Robin Gareus < robin @ gareus . org >
* Copyright ( C ) 2013 - 2015 Colin Fletcher < colin . m . fletcher @ googlemail . com >
* Copyright ( C ) 2013 - 2016 John Emmas < john @ creativepost . co . uk >
* Copyright ( C ) 2013 - 2016 Nick Mainsbridge < mainsbridge @ gmail . com >
* Copyright ( C ) 2014 - 2018 Ben Loftis < ben @ harrisonconsoles . com >
* Copyright ( C ) 2015 André Nusser < andre . nusser @ googlemail . com >
* Copyright ( C ) 2016 - 2018 Len Ovens < len @ ovenwerks . net >
* Copyright ( C ) 2017 Johannes Mueller < github @ johannes - mueller . org >
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA .
*/
2005-09-25 14:42:24 -04:00
2010-11-13 00:14:48 -05:00
# ifdef WAF_BUILD
# include "gtk2ardour-config.h"
2014-09-06 11:59:53 -04:00
# include "gtk2ardour-version.h"
2010-11-13 00:14:48 -05:00
# endif
2005-09-25 14:42:24 -04:00
# include <algorithm>
# include <cmath>
2013-05-04 22:02:05 -04:00
# include <iostream>
2015-06-29 16:27:49 -04:00
# include <stdarg.h>
2016-06-26 10:44:45 -04:00
# ifdef __FreeBSD__
# include <sys/types.h>
# include <sys/sysctl.h>
# endif
2013-05-04 22:02:05 -04:00
# include <stdint.h>
2005-09-25 14:42:24 -04:00
# include <fcntl.h>
# include <unistd.h>
2008-09-10 11:03:30 -04:00
# include <time.h>
2005-09-25 14:42:24 -04:00
2013-07-17 02:41:48 -04:00
# include <glib.h>
2015-10-05 16:10:58 -04:00
# include "pbd/gstdio_compat.h"
2007-03-18 02:07:08 -04:00
2006-03-29 22:38:33 -05:00
# include <gtkmm/accelmap.h>
2017-07-16 21:48:18 -04:00
# include <gtkmm/messagedialog.h>
2016-06-06 13:40:00 -04:00
# include <gtkmm/stock.h>
2017-07-16 21:48:18 -04:00
# include <gtkmm/uimanager.h>
2006-03-05 14:39:16 -05:00
2009-02-25 13:26:51 -05:00
# include "pbd/error.h"
# include "pbd/compose.h"
2015-07-07 22:12:21 -04:00
# include "pbd/convert.h"
2009-02-25 13:26:51 -05:00
# include "pbd/failed_constructor.h"
# include "pbd/memento_command.h"
2010-03-16 11:33:04 -04:00
# include "pbd/openuri.h"
2016-08-28 18:58:39 -04:00
# include "pbd/types_convert.h"
2009-02-25 13:26:51 -05:00
# include "pbd/file_utils.h"
2022-08-21 07:34:10 -04:00
# include <pbd/localtime_r.h>
2014-07-15 08:19:33 -04:00
# include "pbd/pthread_utils.h"
2015-06-29 16:27:49 -04:00
# include "pbd/replace_all.h"
2017-02-20 14:47:57 -05:00
# include "pbd/scoped_file_descriptor.h"
2015-06-29 16:27:49 -04:00
# include "pbd/xml++.h"
2007-05-14 10:13:59 -04:00
2010-08-20 18:36:35 -04:00
# include "gtkmm2ext/application.h"
2011-03-03 22:10:48 -05:00
# include "gtkmm2ext/bindings.h"
2009-12-04 15:52:04 -05:00
# include "gtkmm2ext/gtk_ui.h"
# include "gtkmm2ext/utils.h"
# include "gtkmm2ext/window_title.h"
2005-09-25 14:42:24 -04:00
2017-07-16 16:13:46 -04:00
# include "widgets/fastmeter.h"
2017-07-16 23:18:48 -04:00
# include "widgets/prompter.h"
2018-02-20 06:15:29 -05:00
# include "widgets/tooltips.h"
2017-07-16 16:13:46 -04:00
2009-02-25 13:26:51 -05:00
# include "ardour/ardour.h"
2013-08-03 11:57:56 -04:00
# include "ardour/audio_backend.h"
2016-03-28 12:07:43 -04:00
# include "ardour/audio_track.h"
2012-05-24 02:09:29 -04:00
# include "ardour/audioengine.h"
# include "ardour/audiofilesource.h"
2017-04-10 06:44:48 -04:00
# include "ardour/disk_reader.h"
# include "ardour/disk_writer.h"
2013-03-08 11:41:45 -05:00
# include "ardour/filesystem_paths.h"
2018-12-03 19:55:52 -05:00
# include "ardour/monitor_control.h"
2016-03-28 12:07:43 -04:00
# include "ardour/midi_track.h"
2012-05-24 02:09:29 -04:00
# include "ardour/port.h"
2014-02-23 21:53:53 -05:00
# include "ardour/plugin_manager.h"
2012-05-24 02:09:29 -04:00
# include "ardour/process_thread.h"
2009-02-25 13:26:51 -05:00
# include "ardour/profile.h"
2017-04-21 15:58:59 -04:00
# include "ardour/revision.h"
2009-02-25 13:26:51 -05:00
# include "ardour/session_directory.h"
# include "ardour/session_route.h"
2015-09-15 11:46:48 -04:00
# include "ardour/source_factory.h"
2018-09-18 18:52:20 -04:00
# include "ardour/transport_master.h"
# include "ardour/transport_master_manager.h"
2022-02-12 22:45:53 -05:00
# include "ardour/triggerbox.h"
2016-04-08 16:49:47 -04:00
# include "ardour/track.h"
2016-02-27 22:16:37 -05:00
# include "ardour/vca_manager.h"
2016-04-08 16:49:47 -04:00
# include "ardour/utils.h"
2005-09-25 14:42:24 -04:00
2016-02-22 17:10:55 -05:00
# include "LuaBridge/LuaBridge.h"
2014-02-21 20:44:34 -05:00
# ifdef WINDOWS_VST_SUPPORT
# include <fst.h>
# endif
2014-11-11 22:57:03 -05:00
# ifdef AUDIOUNIT_SUPPORT
# include "ardour/audio_unit.h"
# endif
2014-02-21 20:44:34 -05:00
2016-02-24 06:04:01 -05:00
// fix for OSX (nsm.h has a check function, AU/Apple defines check)
# ifdef check
# undef check
# endif
2017-09-24 12:03:54 -04:00
# include "temporal/time.h"
2012-10-12 12:25:57 -04:00
2011-02-16 23:45:49 -05:00
# include "about.h"
2016-08-28 18:58:39 -04:00
# include "enums_convert.h"
2005-11-25 19:06:46 -05:00
# include "actions.h"
2011-02-16 23:45:49 -05:00
# include "add_route_dialog.h"
2019-12-14 17:31:24 -05:00
# include "ardour_message.h"
2005-09-25 14:42:24 -04:00
# include "ardour_ui.h"
# include "audio_clock.h"
2015-09-15 08:42:43 -04:00
# include "audio_region_view.h"
2013-05-04 22:02:05 -04:00
# include "big_clock_window.h"
2017-12-22 14:21:27 -05:00
# include "big_transport_window.h"
2011-02-16 23:45:49 -05:00
# include "bundle_manager.h"
2021-06-11 23:17:44 -04:00
# include "dsp_stats_window.h"
2015-11-14 10:29:50 -05:00
# include "duplicate_routes_dialog.h"
2015-07-08 12:45:57 -04:00
# include "debug.h"
2011-02-16 23:45:49 -05:00
# include "engine_dialog.h"
2015-02-27 17:17:26 -05:00
# include "export_video_dialog.h"
2011-02-16 23:45:49 -05:00
# include "global_port_matrix.h"
2011-07-06 20:37:13 -04:00
# include "gui_object.h"
2011-02-16 23:45:49 -05:00
# include "gui_thread.h"
2017-03-15 06:34:05 -04:00
# include "idleometer.h"
2022-04-08 11:04:53 -04:00
# include "io_plugin_window.h"
2005-09-25 14:42:24 -04:00
# include "keyboard.h"
2013-05-04 22:02:05 -04:00
# include "keyeditor.h"
2022-09-07 19:02:50 -04:00
# include "library_download_dialog.h"
2011-02-16 23:45:49 -05:00
# include "location_ui.h"
2016-02-28 05:58:47 -05:00
# include "lua_script_manager.h"
2016-02-23 09:42:13 -05:00
# include "luawindow.h"
2012-05-31 19:14:03 -04:00
# include "main_clock.h"
2011-02-16 23:45:49 -05:00
# include "missing_plugin_dialog.h"
2005-09-25 14:42:24 -04:00
# include "mixer_ui.h"
2015-09-16 18:13:43 -04:00
# include "meterbridge.h"
2012-12-12 09:55:01 -05:00
# include "mouse_cursors.h"
2013-08-15 06:35:33 -04:00
# include "nsm.h"
2005-09-25 14:42:24 -04:00
# include "opts.h"
2018-09-24 18:12:42 -04:00
# include "plugin_dspload_window.h"
2021-05-26 19:02:11 -04:00
# include "plugin_manager_ui.h"
2011-02-16 23:45:49 -05:00
# include "processor_box.h"
# include "public_editor.h"
2013-05-04 22:02:05 -04:00
# include "rc_option_editor.h"
2020-10-26 17:55:00 -04:00
# include "recorder_ui.h"
2008-09-10 11:03:30 -04:00
# include "route_time_axis.h"
2013-05-04 22:02:05 -04:00
# include "route_params_ui.h"
2015-04-20 17:49:41 -04:00
# include "save_as_dialog.h"
2017-08-18 13:53:46 -04:00
# include "save_template_dialog.h"
2016-02-22 17:10:55 -05:00
# include "script_selector.h"
2016-09-20 13:46:49 -04:00
# include "session_archive_dialog.h"
2013-09-23 14:41:52 -04:00
# include "session_dialog.h"
2011-02-16 23:45:49 -05:00
# include "session_metadata_dialog.h"
2013-05-04 22:02:05 -04:00
# include "session_option_editor.h"
2011-02-16 23:45:49 -05:00
# include "speaker_dialog.h"
# include "splash.h"
2017-07-03 06:27:25 -04:00
# include "template_dialog.h"
2010-06-03 11:57:31 -04:00
# include "time_axis_view_item.h"
2016-12-19 21:11:21 -05:00
# include "time_info_box.h"
2014-12-25 10:02:00 -05:00
# include "timers.h"
2018-09-18 18:52:20 -04:00
# include "transport_masters_dialog.h"
2021-11-08 20:27:38 -05:00
# include "trigger_page.h"
2021-07-22 12:33:27 -04:00
# include "triggerbox_ui.h"
2011-02-16 23:45:49 -05:00
# include "utils.h"
2019-10-17 21:50:52 -04:00
# include "virtual_keyboard_window.h"
2013-03-12 17:00:09 -04:00
# include "add_video_dialog.h"
2020-11-24 23:33:16 -05:00
# include "plugin_selector.h"
2007-06-29 13:13:09 -04:00
2016-07-14 14:44:52 -04:00
# include "pbd/i18n.h"
2005-09-25 14:42:24 -04:00
using namespace ARDOUR ;
2014-06-25 15:27:37 -04:00
using namespace ARDOUR_UI_UTILS ;
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one)
Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now.
Relevant (significant) changes:
- Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...)
- IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why)
- AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output.
- (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise.
- MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here.
- Random cleanups and variable renamings etc. because I have OCD and can't help myself. :)
Known broken: Loading of sessions containing MIDI tracks.
git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
using namespace PBD ;
2005-09-25 16:33:00 -04:00
using namespace Gtkmm2ext ;
2017-07-15 11:38:28 -04:00
using namespace ArdourWidgets ;
2005-09-25 14:42:24 -04:00
using namespace Gtk ;
2012-05-24 02:09:29 -04:00
using namespace std ;
2015-04-21 11:16:00 -04:00
using namespace Editing ;
2005-09-25 14:42:24 -04:00
ARDOUR_UI * ARDOUR_UI : : theArdourUI = 0 ;
2020-10-19 14:37:54 -04:00
sigc : : signal < void , timepos_t > ARDOUR_UI : : Clock ;
2017-07-01 12:42:24 -04:00
sigc : : signal < void > ARDOUR_UI : : CloseAllDialogs ;
2005-09-25 14:42:24 -04:00
2022-09-19 16:47:59 -04:00
static const gchar * _record_mode_strings [ ] = {
2022-09-19 17:24:42 -04:00
N_ ( " Layered " ) ,
N_ ( " Non-Layered " ) ,
N_ ( " Snd on Snd " ) ,
2022-09-19 16:47:59 -04:00
0
} ;
2015-03-12 18:45:31 -04:00
static bool
ask_about_configuration_copy ( string const & old_dir , string const & new_dir , int version )
{
2019-12-14 17:31:24 -05:00
ArdourMessageDialog msg ( string_compose (
_ ( " %1 %2.x has discovered configuration files from %1 %3.x. \n \n "
" Would you like these files to be copied and used for %1 %2.x? \n \n "
" (This will require you to restart %1.) " ) ,
PROGRAM_NAME , PROGRAM_VERSION , version ) ,
false , /* no markup */
Gtk : : MESSAGE_INFO ,
Gtk : : BUTTONS_YES_NO ,
true /* modal, though it hardly matters since it is the only window */
2017-07-01 12:42:24 -04:00
) ;
2015-04-03 11:35:32 -04:00
msg . set_default_response ( Gtk : : RESPONSE_YES ) ;
2015-03-12 18:45:31 -04:00
msg . show_all ( ) ;
2015-04-03 11:35:32 -04:00
return ( msg . run ( ) = = Gtk : : RESPONSE_YES ) ;
2015-03-12 18:45:31 -04:00
}
2015-06-29 16:27:49 -04:00
static void
libxml_generic_error_func ( void * /* parsing_context*/ ,
2017-07-01 12:42:24 -04:00
const char * msg ,
. . . )
2015-06-29 16:27:49 -04:00
{
va_list ap ;
char buf [ 2048 ] ;
va_start ( ap , msg ) ;
vsnprintf ( buf , sizeof ( buf ) , msg , ap ) ;
error < < buf < < endmsg ;
va_end ( ap ) ;
}
static void
libxml_structured_error_func ( void * /* parsing_context*/ ,
xmlErrorPtr err )
{
2015-07-23 12:52:42 -04:00
string msg ;
if ( err - > message )
msg = err - > message ;
2015-06-29 16:27:49 -04:00
replace_all ( msg , " \n " , " " ) ;
2016-04-21 11:45:15 -04:00
if ( ! msg . empty ( ) ) {
if ( err - > file & & err - > line ) {
error < < X_ ( " XML error: " ) < < msg < < " in " < < err - > file < < " at line " < < err - > line ;
2015-07-23 12:52:42 -04:00
2016-04-21 11:45:15 -04:00
if ( err - > int2 ) {
error < < ' : ' < < err - > int2 ;
}
error < < endmsg ;
} else {
2016-04-22 02:18:15 -04:00
error < < X_ ( " XML error: " ) < < msg < < endmsg ;
2015-07-23 12:52:42 -04:00
}
2015-06-29 16:27:49 -04:00
}
}
2015-01-02 09:44:54 -05:00
ARDOUR_UI : : ARDOUR_UI ( int * argcp , char * * argvp [ ] , const char * localedir )
2015-12-29 05:03:43 -05:00
: Gtkmm2ext : : UI ( PROGRAM_NAME , X_ ( " gui " ) , argcp , argvp )
2017-06-30 21:10:50 -04:00
, session_load_in_progress ( false )
2011-07-06 20:37:13 -04:00
, gui_object_state ( new GUIObjectState )
2015-02-15 07:56:25 -05:00
, primary_clock ( new MainClock ( X_ ( " primary " ) , X_ ( " transport " ) , true ) )
, secondary_clock ( new MainClock ( X_ ( " secondary " ) , X_ ( " secondary " ) , false ) )
2011-11-17 17:49:13 -05:00
, big_clock ( new AudioClock ( X_ ( " bigclock " ) , false , " big " , true , true , false , false ) )
2013-07-06 22:14:41 -04:00
, video_timeline ( 0 )
2015-04-22 16:09:02 -04:00
, ignore_dual_punch ( false )
2016-05-10 10:03:45 -04:00
, main_window_visibility ( 0 )
2014-12-22 18:52:40 -05:00
, editor ( 0 )
, mixer ( 0 )
2020-10-26 17:55:00 -04:00
, recorder ( 0 )
2021-11-08 20:27:38 -05:00
, trigger_page ( 0 )
2013-05-07 18:09:12 -04:00
, nsm ( 0 )
, _was_dirty ( false )
, _mixer_on_top ( false )
2019-03-07 11:02:12 -05:00
, _shared_popup_menu ( 0 )
2019-10-09 22:50:34 -04:00
, startup_fsm ( 0 )
2016-12-21 17:01:34 -05:00
, secondary_clock_spacer ( 0 )
2019-09-28 19:23:48 -04:00
, latency_disable_button ( ArdourButton : : led_default_elements )
2022-02-12 22:45:53 -05:00
, _cue_rec_enable ( _ ( " Rec Cues " ) , ArdourButton : : led_default_elements )
, _cue_play_enable ( _ ( " Play Cues " ) , ArdourButton : : led_default_elements )
2017-01-16 16:30:39 -05:00
, time_info_box ( 0 )
2015-06-25 12:47:29 -04:00
, auto_return_button ( ArdourButton : : led_default_elements )
2012-11-20 14:43:43 -05:00
, follow_edits_button ( ArdourButton : : led_default_elements )
2014-08-01 15:31:18 -04:00
, auditioning_alert_button ( _ ( " Audition " ) )
, solo_alert_button ( _ ( " Solo " ) )
, feedback_alert_button ( _ ( " Feedback " ) )
2015-03-16 21:05:02 -04:00
, error_alert_button ( ArdourButton : : just_led_default_elements )
2013-08-03 07:59:22 -04:00
, editor_meter_peak_display ( )
2017-07-15 11:38:28 -04:00
, editor_meter ( 0 )
2020-04-10 17:36:17 -04:00
, _clear_editor_meter ( true )
, _editor_meter_peaked ( false )
2015-04-22 16:09:02 -04:00
, _numpad_locate_happening ( false )
, _session_is_new ( false )
, last_key_press_time ( 0 )
, save_as_dialog ( 0 )
, meterbridge ( 0 )
2015-04-21 15:10:49 -04:00
, rc_option_editor ( 0 )
2013-05-04 22:02:05 -04:00
, speaker_config_window ( X_ ( " speaker-config " ) , _ ( " Speaker Configuration " ) )
, add_route_dialog ( X_ ( " add-routes " ) , _ ( " Add Tracks/Busses " ) )
, about ( X_ ( " about " ) , _ ( " About " ) )
2016-06-07 12:32:57 -04:00
, location_ui ( X_ ( " locations " ) , S_ ( " Ranges|Locations " ) )
2013-05-04 22:02:05 -04:00
, route_params ( X_ ( " inspector " ) , _ ( " Tracks and Busses " ) )
2013-09-22 19:22:56 -04:00
, audio_midi_setup ( X_ ( " audio-midi-setup " ) , _ ( " Audio/MIDI Setup " ) )
2015-02-27 17:17:26 -05:00
, export_video_dialog ( X_ ( " video-export " ) , _ ( " Video Export Dialog " ) )
2016-02-23 09:42:53 -05:00
, lua_script_window ( X_ ( " script-manager " ) , _ ( " Script Manager " ) )
2017-03-15 06:34:05 -04:00
, idleometer ( X_ ( " idle-o-meter " ) , _ ( " Idle'o'Meter " ) )
2022-04-08 11:04:53 -04:00
, io_plugin_window ( X_ ( " io-plugins " ) , _ ( " I/O Plugins " ) )
2021-05-26 19:02:11 -04:00
, plugin_manager_ui ( X_ ( " plugin-manager " ) , _ ( " Plugin Manager " ) )
2018-09-24 18:12:42 -04:00
, plugin_dsp_load_window ( X_ ( " plugin-dsp-load " ) , _ ( " Plugin DSP Load " ) )
2021-06-11 23:07:47 -04:00
, dsp_statistics_window ( X_ ( " dsp-statistics " ) , _ ( " Performance Meters " ) )
2018-09-23 12:58:53 -04:00
, transport_masters_window ( X_ ( " transport-masters " ) , _ ( " Transport Masters " ) )
2013-05-04 22:02:05 -04:00
, session_option_editor ( X_ ( " session-options-editor " ) , _ ( " Properties " ) , boost : : bind ( & ARDOUR_UI : : create_session_option_editor , this ) )
2015-08-04 13:59:00 -04:00
, add_video_dialog ( X_ ( " add-video " ) , _ ( " Add Video " ) , boost : : bind ( & ARDOUR_UI : : create_add_video_dialog , this ) )
2013-05-04 22:02:05 -04:00
, bundle_manager ( X_ ( " bundle-manager " ) , _ ( " Bundle Manager " ) , boost : : bind ( & ARDOUR_UI : : create_bundle_manager , this ) )
, big_clock_window ( X_ ( " big-clock " ) , _ ( " Big Clock " ) , boost : : bind ( & ARDOUR_UI : : create_big_clock_window , this ) )
2017-12-22 14:21:27 -05:00
, big_transport_window ( X_ ( " big-transport " ) , _ ( " Transport Controls " ) , boost : : bind ( & ARDOUR_UI : : create_big_transport_window , this ) )
2019-10-17 21:50:52 -04:00
, virtual_keyboard_window ( X_ ( " virtual-keyboard " ) , _ ( " Virtual Keyboard " ) , boost : : bind ( & ARDOUR_UI : : create_virtual_keyboard_window , this ) )
2022-09-07 19:02:50 -04:00
, library_manager_window ( X_ ( " library-manager " ) , _ ( " Library Manager " ) , boost : : bind ( & ARDOUR_UI : : create_library_manager_window , this ) )
2013-05-04 22:02:05 -04:00
, audio_port_matrix ( X_ ( " audio-connection-manager " ) , _ ( " Audio Connections " ) , boost : : bind ( & ARDOUR_UI : : create_global_port_matrix , this , ARDOUR : : DataType : : AUDIO ) )
, midi_port_matrix ( X_ ( " midi-connection-manager " ) , _ ( " MIDI Connections " ) , boost : : bind ( & ARDOUR_UI : : create_global_port_matrix , this , ARDOUR : : DataType : : MIDI ) )
2017-01-12 11:08:50 -05:00
, key_editor ( X_ ( " key-editor " ) , _ ( " Keyboard Shortcuts " ) , boost : : bind ( & ARDOUR_UI : : create_key_editor , this ) )
2021-09-19 22:26:24 -04:00
, luawindow ( X_ ( " luawindow " ) , S_ ( " Window|Scripting " ) , boost : : bind ( & ARDOUR_UI : : create_luawindow , this ) )
2015-04-22 16:09:02 -04:00
, video_server_process ( 0 )
, have_configure_timeout ( false )
, last_configure_time ( 0 )
, last_peak_grab ( 0 )
, have_disk_speed_dialog_displayed ( false )
2011-10-29 16:07:00 -04:00
, _status_bar_visibility ( X_ ( " status-bar " ) )
2011-11-11 08:52:27 -05:00
, _feedback_exists ( false )
2021-03-30 15:19:55 -04:00
, _ambiguous_latency ( false )
2015-03-16 14:04:17 -04:00
, _log_not_acknowledged ( LogLevelNone )
2015-11-14 10:29:50 -05:00
, duplicate_routes_dialog ( 0 )
2021-02-25 07:58:07 -05:00
, editor_visibility_button ( S_ ( " Window|Edit " ) )
, mixer_visibility_button ( S_ ( " Window|Mix " ) )
2020-10-26 17:55:00 -04:00
, prefs_visibility_button ( S_ ( " Window|Prefs " ) )
, recorder_visibility_button ( S_ ( " Window|Rec " ) )
2022-01-25 18:54:52 -05:00
, trigger_page_visibility_button ( S_ ( " Window|Cue " ) )
2021-12-02 08:34:58 -05:00
, nsm_first_session_opened ( false )
2005-09-25 14:42:24 -04:00
{
2015-04-22 16:09:02 -04:00
Gtkmm2ext : : init ( localedir ) ;
2009-10-14 12:10:01 -04:00
2015-01-02 09:44:54 -05:00
UIConfiguration : : instance ( ) . post_gui_init ( ) ;
2022-09-19 16:47:59 -04:00
record_mode_strings = I18N ( _record_mode_strings ) ;
2015-03-23 13:31:55 -04:00
if ( ARDOUR : : handle_old_configuration_files ( boost : : bind ( ask_about_configuration_copy , _1 , _2 , _3 ) ) ) {
2017-02-20 14:47:57 -05:00
{
/* "touch" the been-here-before path now that config has been migrated */
PBD : : ScopedFileDescriptor fout ( g_open ( been_here_before_path ( ) . c_str ( ) , O_CREAT | O_TRUNC | O_RDWR , 0666 ) ) ;
}
2022-07-26 19:03:03 -04:00
{
Config - > load_state ( ) ; // need session-parent folder
copy_demo_sessions ( ) ;
}
2019-12-14 17:31:24 -05:00
ArdourMessageDialog msg ( string_compose ( _ ( " Your configuration files were copied. You can now restart %1. " ) , PROGRAM_NAME ) , true ) ;
2015-03-12 18:45:31 -04:00
msg . run ( ) ;
/* configuration was modified, exit immediately */
2019-07-04 16:21:49 -04:00
_exit ( EXIT_SUCCESS ) ;
2015-03-12 18:45:31 -04:00
}
2015-09-08 16:30:30 -04:00
2016-06-06 13:40:00 -04:00
2005-09-25 14:42:24 -04:00
if ( theArdourUI = = 0 ) {
theArdourUI = this ;
}
2005-11-25 19:06:46 -05:00
2016-05-10 10:03:45 -04:00
/* track main window visibility */
main_window_visibility = new VisibilityTracker ( _main_window ) ;
2015-06-29 16:27:49 -04:00
/* stop libxml from spewing to stdout/stderr */
xmlSetGenericErrorFunc ( this , libxml_generic_error_func ) ;
xmlSetStructuredErrorFunc ( this , libxml_structured_error_func ) ;
2015-10-05 10:17:49 -04:00
2019-01-13 13:01:18 -05:00
/* Set this up early */
ActionManager : : init ( ) ;
/* we like keyboards */
keyboard = new ArdourKeyboard ( * this ) ;
XMLNode * node = ARDOUR_UI : : instance ( ) - > keyboard_settings ( ) ;
if ( node ) {
keyboard - > set_state ( * node , Stateful : : loading_state_version ) ;
}
2019-02-16 03:12:07 -05:00
/* actions do not need to be defined when we load keybindings. They
* will be lazily discovered . But bindings do need to exist when we
* create windows / tabs with their own binding sets .
*/
keyboard - > setup_keybindings ( ) ;
if ( ( global_bindings = Bindings : : get_bindings ( X_ ( " Global " ) ) ) = = 0 ) {
error < < _ ( " Global keybindings are missing " ) < < endmsg ;
}
2019-01-13 13:01:18 -05:00
install_actions ( ) ;
2015-01-02 09:44:54 -05:00
UIConfiguration : : instance ( ) . ParameterChanged . connect ( sigc : : mem_fun ( * this , & ARDOUR_UI : : parameter_changed ) ) ;
2013-06-21 17:15:56 -04:00
boost : : function < void ( string ) > pc ( boost : : bind ( & ARDOUR_UI : : parameter_changed , this , _1 ) ) ;
2015-01-02 09:44:54 -05:00
UIConfiguration : : instance ( ) . map_parameters ( pc ) ;
2011-05-25 06:17:16 -04:00
2017-12-22 14:20:59 -05:00
transport_ctrl . setup ( this ) ;
2011-11-07 14:15:13 -05:00
2017-04-10 06:44:48 -04:00
ARDOUR : : DiskWriter : : Overrun . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : disk_overrun_handler , this ) , gui_context ( ) ) ;
ARDOUR : : DiskReader : : Underrun . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : disk_underrun_handler , this ) , gui_context ( ) ) ;
2005-09-25 14:42:24 -04:00
2013-03-04 16:57:29 -05:00
ARDOUR : : Session : : VersionMismatch . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : session_format_mismatch , this , _1 , _2 ) , gui_context ( ) ) ;
2022-02-12 22:45:53 -05:00
TriggerBox : : CueRecordingChanged . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : cue_rec_state_changed , this ) , gui_context ( ) ) ;
cue_rec_state_changed ( ) ;
2008-04-11 10:06:50 -04:00
/* handle dialog requests */
2012-04-25 08:58:19 -04:00
ARDOUR : : Session : : Dialog . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : session_dialog , this , _1 ) , gui_context ( ) ) ;
2008-04-11 10:06:50 -04:00
2009-12-21 13:23:07 -05:00
/* handle pending state with a dialog (PROBLEM: needs to return a value and thus cannot be x-thread) */
2005-09-25 14:42:24 -04:00
2009-12-21 13:23:07 -05:00
ARDOUR : : Session : : AskAboutPendingState . connect_same_thread ( forever_connections , boost : : bind ( & ARDOUR_UI : : pending_state_dialog , this ) ) ;
2005-09-25 14:42:24 -04:00
2009-12-21 13:23:07 -05:00
/* handle sr mismatch with a dialog (PROBLEM: needs to return a value and thus cannot be x-thread) */
2008-02-02 12:22:04 -05:00
2009-12-21 13:23:07 -05:00
ARDOUR : : Session : : AskAboutSampleRateMismatch . connect_same_thread ( forever_connections , boost : : bind ( & ARDOUR_UI : : sr_mismatch_dialog , this , _1 , _2 ) ) ;
2008-02-02 12:22:04 -05:00
2016-04-18 09:17:51 -04:00
/* handle sr mismatch with a dialog - cross-thread from engine */
ARDOUR : : Session : : NotifyAboutSampleRateMismatch . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : sr_mismatch_message , this , _1 , _2 ) , gui_context ( ) ) ;
2010-10-07 08:12:16 -04:00
/* handle requests to quit (coming from JACK session) */
2011-06-01 13:00:29 -04:00
2012-04-25 08:58:19 -04:00
ARDOUR : : Session : : Quit . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : finish , this ) , gui_context ( ) ) ;
2010-10-07 08:12:16 -04:00
2011-11-09 12:44:39 -05:00
/* tell the user about feedback */
2012-04-25 08:58:19 -04:00
ARDOUR : : Session : : FeedbackDetected . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : feedback_detected , this ) , gui_context ( ) ) ;
ARDOUR : : Session : : SuccessfulGraphSort . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : successful_graph_sort , this ) , gui_context ( ) ) ;
2011-11-09 12:44:39 -05:00
2019-09-28 19:23:48 -04:00
/* indicate global latency compensation en/disable */
ARDOUR : : Latent : : DisableSwitchChanged . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : latency_switch_changed , this ) , gui_context ( ) ) ;
2010-11-25 15:37:39 -05:00
/* handle requests to deal with missing files */
2010-11-09 01:03:51 -05:00
ARDOUR : : Session : : MissingFile . connect_same_thread ( forever_connections , boost : : bind ( & ARDOUR_UI : : missing_file , this , _1 , _2 , _3 ) ) ;
2010-12-13 21:45:41 -05:00
/* and ambiguous files */
2013-07-15 08:05:37 -04:00
ARDOUR : : FileSource : : AmbiguousFileName . connect_same_thread ( forever_connections , boost : : bind ( & ARDOUR_UI : : ambiguous_file , this , _1 , _2 ) ) ;
2010-12-13 21:45:41 -05:00
2014-02-25 06:56:20 -05:00
ARDOUR : : GUIIdle . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : gui_idle_handler , this ) , gui_context ( ) ) ;
2014-08-27 11:55:01 -04:00
Config - > ParameterChanged . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : set_flat_buttons , this ) , gui_context ( ) ) ;
set_flat_buttons ( ) ;
2019-08-26 12:58:34 -04:00
theme_changed . connect ( sigc : : mem_fun ( * this , & ARDOUR_UI : : on_theme_changed ) ) ;
UIConfiguration : : instance ( ) . ColorsChanged . connect ( sigc : : mem_fun ( * this , & ARDOUR_UI : : on_theme_changed ) ) ;
UIConfiguration : : instance ( ) . DPIReset . connect ( sigc : : mem_fun ( * this , & ARDOUR_UI : : on_theme_changed ) ) ;
2007-10-11 18:07:47 -04:00
/* lets get this party started */
2013-08-09 07:47:16 -04:00
setup_gtk_ardour_enums ( ) ;
setup_profile ( ) ;
2008-01-15 12:23:57 -05:00
2015-09-06 16:36:09 -04:00
SessionEvent : : create_per_thread_pool ( " GUI " , 4096 ) ;
2007-10-11 18:07:47 -04:00
2015-01-02 09:44:54 -05:00
UIConfiguration : : instance ( ) . reset_dpi ( ) ;
2008-03-17 16:54:03 -04:00
2010-11-25 15:37:39 -05:00
TimeAxisViewItem : : set_constant_heights ( ) ;
2010-06-03 11:57:31 -04:00
2013-05-04 22:02:05 -04:00
/* The following must happen after ARDOUR::init() so that Config is set up */
2011-06-01 13:00:29 -04:00
2013-05-04 22:02:05 -04:00
const XMLNode * ui_xml = Config - > extra_xml ( X_ ( " UI " ) ) ;
if ( ui_xml ) {
2015-07-07 22:12:21 -04:00
key_editor . set_state ( * ui_xml , 0 ) ;
session_option_editor . set_state ( * ui_xml , 0 ) ;
speaker_config_window . set_state ( * ui_xml , 0 ) ;
about . set_state ( * ui_xml , 0 ) ;
add_route_dialog . set_state ( * ui_xml , 0 ) ;
add_video_dialog . set_state ( * ui_xml , 0 ) ;
route_params . set_state ( * ui_xml , 0 ) ;
bundle_manager . set_state ( * ui_xml , 0 ) ;
location_ui . set_state ( * ui_xml , 0 ) ;
big_clock_window . set_state ( * ui_xml , 0 ) ;
2017-12-22 14:21:27 -05:00
big_transport_window . set_state ( * ui_xml , 0 ) ;
2019-10-17 21:50:52 -04:00
virtual_keyboard_window . set_state ( * ui_xml , 0 ) ;
2015-07-07 22:12:21 -04:00
audio_port_matrix . set_state ( * ui_xml , 0 ) ;
midi_port_matrix . set_state ( * ui_xml , 0 ) ;
2021-09-19 22:26:24 -04:00
luawindow . set_state ( * ui_xml , 0 ) ;
2015-07-07 22:12:21 -04:00
export_video_dialog . set_state ( * ui_xml , 0 ) ;
2016-02-23 09:42:53 -05:00
lua_script_window . set_state ( * ui_xml , 0 ) ;
2017-03-15 06:34:05 -04:00
idleometer . set_state ( * ui_xml , 0 ) ;
2022-04-08 11:04:53 -04:00
io_plugin_window . set_state ( * ui_xml , 0 ) ;
2021-05-26 19:02:11 -04:00
plugin_manager_ui . set_state ( * ui_xml , 0 ) ;
2018-09-24 18:12:42 -04:00
plugin_dsp_load_window . set_state ( * ui_xml , 0 ) ;
2021-06-11 23:10:20 -04:00
dsp_statistics_window . set_state ( * ui_xml , 0 ) ;
2018-09-23 12:58:53 -04:00
transport_masters_window . set_state ( * ui_xml , 0 ) ;
2013-05-04 22:02:05 -04:00
}
2020-09-26 20:07:04 -04:00
/* set default parent for dialogs and windows */
WM : : Manager : : instance ( ) . set_transient_for ( & _main_window ) ;
2015-07-09 12:40:51 -04:00
/* Separate windows */
2015-10-26 14:35:06 -04:00
2013-05-07 22:09:16 -04:00
WM : : Manager : : instance ( ) . register_window ( & key_editor ) ;
WM : : Manager : : instance ( ) . register_window ( & session_option_editor ) ;
WM : : Manager : : instance ( ) . register_window ( & speaker_config_window ) ;
WM : : Manager : : instance ( ) . register_window ( & about ) ;
WM : : Manager : : instance ( ) . register_window ( & add_route_dialog ) ;
WM : : Manager : : instance ( ) . register_window ( & add_video_dialog ) ;
WM : : Manager : : instance ( ) . register_window ( & route_params ) ;
2013-09-22 19:22:56 -04:00
WM : : Manager : : instance ( ) . register_window ( & audio_midi_setup ) ;
2015-02-27 17:17:26 -05:00
WM : : Manager : : instance ( ) . register_window ( & export_video_dialog ) ;
2016-02-23 09:42:53 -05:00
WM : : Manager : : instance ( ) . register_window ( & lua_script_window ) ;
2013-05-07 22:09:16 -04:00
WM : : Manager : : instance ( ) . register_window ( & bundle_manager ) ;
WM : : Manager : : instance ( ) . register_window ( & location_ui ) ;
WM : : Manager : : instance ( ) . register_window ( & big_clock_window ) ;
2017-12-22 14:21:27 -05:00
WM : : Manager : : instance ( ) . register_window ( & big_transport_window ) ;
2019-10-17 21:50:52 -04:00
WM : : Manager : : instance ( ) . register_window ( & virtual_keyboard_window ) ;
2022-09-07 19:02:50 -04:00
WM : : Manager : : instance ( ) . register_window ( & library_manager_window ) ;
2013-05-07 22:09:16 -04:00
WM : : Manager : : instance ( ) . register_window ( & audio_port_matrix ) ;
WM : : Manager : : instance ( ) . register_window ( & midi_port_matrix ) ;
2021-09-19 22:26:24 -04:00
WM : : Manager : : instance ( ) . register_window ( & luawindow ) ;
2017-03-15 06:34:05 -04:00
WM : : Manager : : instance ( ) . register_window ( & idleometer ) ;
2022-04-08 11:04:53 -04:00
WM : : Manager : : instance ( ) . register_window ( & io_plugin_window ) ;
2021-05-26 19:02:11 -04:00
WM : : Manager : : instance ( ) . register_window ( & plugin_manager_ui ) ;
2018-09-24 18:12:42 -04:00
WM : : Manager : : instance ( ) . register_window ( & plugin_dsp_load_window ) ;
2021-06-11 23:07:47 -04:00
WM : : Manager : : instance ( ) . register_window ( & dsp_statistics_window ) ;
2018-09-23 12:58:53 -04:00
WM : : Manager : : instance ( ) . register_window ( & transport_masters_window ) ;
2013-05-04 22:02:05 -04:00
2020-09-18 15:03:56 -04:00
/* session-sensitive windows */
ActionManager : : session_sensitive_actions . push_back ( ActionManager : : get_action ( X_ ( " Window " ) , X_ ( " toggle-session-options-editor " ) ) ) ;
ActionManager : : session_sensitive_actions . push_back ( ActionManager : : get_action ( X_ ( " Window " ) , X_ ( " toggle-transport-masters " ) ) ) ;
2016-05-18 22:39:37 -04:00
/* do not retain position for add route dialog */
add_route_dialog . set_state_mask ( WindowProxy : : Size ) ;
2016-06-29 17:38:40 -04:00
/* Trigger setting up the color scheme and loading the GTK RC file */
UIConfiguration : : instance ( ) . load_rc_file ( false ) ;
2011-11-01 19:19:03 -04:00
_process_thread = new ProcessThread ( ) ;
2011-11-14 06:31:27 -05:00
2019-10-24 23:11:16 -04:00
ARDOUR : : Port : : set_connecting_blocked ( ARDOUR_COMMAND_LINE : : no_connect_ports ) ;
2005-09-25 14:42:24 -04:00
}
2013-05-04 22:02:05 -04:00
GlobalPortMatrixWindow *
ARDOUR_UI : : create_global_port_matrix ( ARDOUR : : DataType type )
{
if ( ! _session ) {
return 0 ;
}
return new GlobalPortMatrixWindow ( _session , type ) ;
}
2012-12-13 08:44:11 -05:00
2013-08-03 11:57:56 -04:00
void
ARDOUR_UI : : attach_to_engine ( )
2005-09-25 14:42:24 -04:00
{
2022-08-06 15:44:55 -04:00
static bool first_time = true ;
if ( ! first_time ) {
return ;
}
2019-01-16 16:29:25 -05:00
AudioEngine : : instance ( ) - > Running . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : engine_running , this , _1 ) , gui_context ( ) ) ;
2019-10-24 23:11:16 -04:00
engine_running ( 0 ) ;
2022-08-06 15:44:55 -04:00
first_time = false ;
2007-10-11 18:07:47 -04:00
}
2013-08-08 16:31:08 -04:00
void
ARDOUR_UI : : engine_stopped ( )
{
ENSURE_GUI_THREAD ( * this , & ARDOUR_UI : : engine_stopped )
2013-09-04 12:49:52 -04:00
ActionManager : : set_sensitive ( ActionManager : : engine_sensitive_actions , false ) ;
ActionManager : : set_sensitive ( ActionManager : : engine_opposite_sensitive_actions , true ) ;
2015-10-02 21:20:37 -04:00
update_sample_rate ( 0 ) ;
update_cpu_load ( ) ;
2013-08-08 16:31:08 -04:00
}
void
2019-01-16 16:29:25 -05:00
ARDOUR_UI : : engine_running ( uint32_t cnt )
2013-08-08 16:31:08 -04:00
{
2019-01-16 16:29:25 -05:00
if ( cnt = = 0 ) {
2013-08-08 16:31:08 -04:00
post_engine ( ) ;
2015-09-08 16:30:30 -04:00
}
2013-09-17 22:25:21 -04:00
update_disk_space ( ) ;
update_cpu_load ( ) ;
update_sample_rate ( AudioEngine : : instance ( ) - > sample_rate ( ) ) ;
update_timecode_format ( ) ;
2015-09-15 11:46:48 -04:00
update_peak_thread_work ( ) ;
2015-10-15 15:50:01 -04:00
ActionManager : : set_sensitive ( ActionManager : : engine_sensitive_actions , true ) ;
ActionManager : : set_sensitive ( ActionManager : : engine_opposite_sensitive_actions , false ) ;
2013-08-08 16:31:08 -04:00
}
void
ARDOUR_UI : : engine_halted ( const char * reason , bool free_reason )
{
if ( ! Gtkmm2ext : : UI : : instance ( ) - > caller_is_ui_thread ( ) ) {
/* we can't rely on the original string continuing to exist when we are called
again in the GUI thread , so make a copy and note that we need to
free it later .
*/
char * copy = strdup ( reason ) ;
2015-03-08 21:27:36 -04:00
Gtkmm2ext : : UI : : instance ( ) - > call_slot ( MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : engine_halted , this , copy , true ) ) ;
2013-08-08 16:31:08 -04:00
return ;
2007-10-11 18:07:47 -04:00
}
2005-09-25 14:42:24 -04:00
2013-09-04 12:49:52 -04:00
ActionManager : : set_sensitive ( ActionManager : : engine_sensitive_actions , false ) ;
ActionManager : : set_sensitive ( ActionManager : : engine_opposite_sensitive_actions , true ) ;
2005-09-25 14:42:24 -04:00
2013-08-08 16:31:08 -04:00
update_sample_rate ( 0 ) ;
2010-04-20 22:24:38 -04:00
2013-08-08 16:31:08 -04:00
string msgstr ;
2010-06-02 12:21:02 -04:00
2013-08-08 16:31:08 -04:00
/* if the reason is a non-empty string, it means that the backend was shutdown
rather than just Ardour .
*/
2006-08-30 22:28:42 -04:00
2013-08-08 16:31:08 -04:00
if ( strlen ( reason ) ) {
2013-09-17 22:25:21 -04:00
msgstr = string_compose ( _ ( " The audio backend was shutdown because: \n \n %1 " ) , reason ) ;
2013-08-08 16:31:08 -04:00
} else {
msgstr = string_compose ( _ ( " \
2013-10-12 09:59:33 -04:00
The audio backend has either been shutdown or it \ n \
2013-08-08 16:31:08 -04:00
disconnected % 1 because % 1 \ n \
was not fast enough . Try to restart \ n \
2013-09-17 22:25:21 -04:00
the audio backend and save the session . " ), PROGRAM_NAME);
2013-08-08 16:31:08 -04:00
}
2019-12-14 17:31:24 -05:00
ArdourMessageDialog msg ( _main_window , msgstr ) ;
2013-08-08 16:31:08 -04:00
msg . run ( ) ;
2015-09-08 16:30:30 -04:00
2013-08-08 16:31:08 -04:00
if ( free_reason ) {
free ( const_cast < char * > ( reason ) ) ;
}
2007-10-11 18:07:47 -04:00
}
2005-09-25 14:42:24 -04:00
2007-10-11 18:07:47 -04:00
void
ARDOUR_UI : : post_engine ( )
{
2021-06-05 17:43:26 -04:00
/* Things to be done once (and once ONLY) after we have a backend running in the AudioEngine */
2014-11-11 22:57:03 -05:00
# ifdef AUDIOUNIT_SUPPORT
2021-06-05 17:43:26 -04:00
string aucrsh = Glib : : build_filename ( ARDOUR : : user_cache_directory ( ) , " au_crash " ) ;
if ( Glib : : file_test ( aucrsh , Glib : : FILE_TEST_EXISTS ) ) {
popup_error ( _ ( " Indexing Audio Unit Plugin Failed. \n Automatic AU scanning has been disabled \n (check with 'auval', then re-enable scanning the in preferences). " ) ) ;
: : g_unlink ( aucrsh . c_str ( ) ) ;
2014-11-11 22:57:03 -05:00
}
# endif
2007-10-11 18:07:47 -04:00
2013-09-12 16:28:51 -04:00
/* connect to important signals */
AudioEngine : : instance ( ) - > Stopped . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : engine_stopped , this ) , gui_context ( ) ) ;
AudioEngine : : instance ( ) - > SampleRateChanged . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : update_sample_rate , this , _1 ) , gui_context ( ) ) ;
2015-01-17 16:38:48 -05:00
AudioEngine : : instance ( ) - > BufferSizeChanged . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : update_sample_rate , this , _1 ) , gui_context ( ) ) ;
2013-09-12 16:28:51 -04:00
AudioEngine : : instance ( ) - > Halted . connect_same_thread ( halt_connection , boost : : bind ( & ARDOUR_UI : : engine_halted , this , _1 , false ) ) ;
2015-04-05 14:02:47 -04:00
AudioEngine : : instance ( ) - > BecameSilent . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : audioengine_became_silent , this ) , gui_context ( ) ) ;
2009-10-06 21:55:32 -04:00
2005-09-25 14:42:24 -04:00
if ( setup_windows ( ) ) {
2021-09-19 22:16:09 -04:00
throw failed_constructor ( ) ; // TODO catch me if you can
2005-09-25 14:42:24 -04:00
}
2011-06-01 13:00:29 -04:00
2017-12-22 14:20:59 -05:00
transport_ctrl . map_actions ( ) ;
2011-10-29 16:07:00 -04:00
/* Do this after setup_windows (), as that's when the _status_bar_visibility is created */
XMLNode * n = Config - > extra_xml ( X_ ( " UI " ) ) ;
if ( n ) {
_status_bar_visibility . set_state ( * n ) ;
}
2015-09-08 16:30:30 -04:00
2007-10-14 01:45:31 -04:00
check_memory_locking ( ) ;
2005-09-25 14:42:24 -04:00
2015-08-08 08:36:29 -04:00
/* this is the first point at which all the possible actions are
* available , because some of the available actions are dependent on
* aspects of the engine / backend .
*/
2007-10-11 18:07:47 -04:00
if ( ARDOUR_COMMAND_LINE : : show_key_actions ) {
2017-04-28 11:19:20 -04:00
stringstream sstr ;
Bindings : : save_all_bindings_as_html ( sstr ) ;
if ( sstr . str ( ) . empty ( ) ) {
return ;
}
2017-04-29 18:37:31 -04:00
gchar * file_name ;
GError * err = NULL ;
gint fd ;
if ( ( fd = g_file_open_tmp ( " akprintXXXXXX.html " , & file_name , & err ) ) < 0 ) {
if ( err ) {
error < < string_compose ( _ ( " Could not open temporary file to print bindings (%1) " ) , err - > message ) < < endmsg ;
g_error_free ( err ) ;
}
return ;
}
# ifdef PLATFORM_WINDOWS
: : close ( fd ) ;
# endif
err = NULL ;
if ( ! g_file_set_contents ( file_name , sstr . str ( ) . c_str ( ) , sstr . str ( ) . size ( ) , & err ) ) {
# ifndef PLATFORM_WINDOWS
: : close ( fd ) ;
# endif
g_unlink ( file_name ) ;
if ( err ) {
error < < string_compose ( _ ( " Could not save bindings to file (%1) " ) , err - > message ) < < endmsg ;
g_error_free ( err ) ;
}
return ;
}
# ifndef PLATFORM_WINDOWS
: : close ( fd ) ;
# endif
PBD : : open_uri ( string_compose ( " file:///%1 " , file_name ) ) ;
2017-04-28 11:19:20 -04:00
halt_connection . disconnect ( ) ;
AudioEngine : : instance ( ) - > stop ( ) ;
2019-07-04 16:21:49 -04:00
exit ( EXIT_SUCCESS ) ;
2017-04-28 11:19:20 -04:00
}
if ( ARDOUR_COMMAND_LINE : : show_actions ) {
2015-08-05 10:57:00 -04:00
2015-10-26 14:35:06 -04:00
2015-09-01 15:46:48 -04:00
vector < string > paths ;
vector < string > labels ;
vector < string > tooltips ;
vector < string > keys ;
vector < Glib : : RefPtr < Gtk : : Action > > actions ;
2017-04-22 11:07:35 -04:00
string ver_in = revision ;
string ver = ver_in . substr ( 0 , ver_in . find ( " - " ) ) ;
2015-10-26 14:35:06 -04:00
2017-04-30 01:47:24 -04:00
stringstream output ;
output < < " \n <h2>Menu actions</h2> " < < endl ;
output < < " <p> \n Every single menu item in " < < PROGRAM_NAME < < " 's GUI is accessible by control " < < endl ;
output < < " surfaces or scripts. \n </p> \n " < < endl ;
output < < " <p> \n The list below shows all available values of <em>action-name</em> as of " < < endl ;
output < < " " < < PROGRAM_NAME < < " " < < ver < < " . You can get the current list at any " < < endl ;
output < < " time by running " < < PROGRAM_NAME < < " with the -A flag. \n </p> \n " < < endl ;
output < < " <table class= \" dl \" > \n <thead> " < < endl ;
output < < " <tr><th>Action Name</th><th>Menu Name</th></tr> " < < endl ;
output < < " </thead> \n <tbody> " < < endl ;
2017-04-21 15:58:59 -04:00
2018-12-10 08:33:31 -05:00
ActionManager : : get_all_actions ( paths , labels , tooltips , keys , actions ) ;
2015-09-01 15:46:48 -04:00
vector < string > : : iterator p ;
2017-04-21 15:58:59 -04:00
vector < string > : : iterator l ;
2015-09-01 15:46:48 -04:00
2017-04-22 11:07:35 -04:00
for ( p = paths . begin ( ) , l = labels . begin ( ) ; p ! = paths . end ( ) ; + + p , + + l ) {
2019-04-13 11:48:27 -04:00
output < < " <tr><th><kbd class= \" osc \" > " < < * p < < " </kbd></th><td> " < < * l < < " </td></tr> " < < endl ;
2005-12-06 01:23:50 -05:00
}
2017-04-30 01:47:24 -04:00
output < < " </tbody> \n </table> " < < endl ;
// output this mess to a browser for easiest X-platform use
// it is not pretty HTML, but it works and it's main purpose
// is to create raw html to fit in Ardour's manual with no editing
gchar * file_name ;
GError * err = NULL ;
gint fd ;
2017-09-18 13:27:25 -04:00
if ( ( fd = g_file_open_tmp ( " list-of-menu-actionsXXXXXX.html " , & file_name , & err ) ) < 0 ) {
2017-04-30 01:47:24 -04:00
if ( err ) {
error < < string_compose ( _ ( " Could not open temporary file to print bindings (%1) " ) , err - > message ) < < endmsg ;
g_error_free ( err ) ;
}
return ;
}
# ifdef PLATFORM_WINDOWS
: : close ( fd ) ;
# endif
err = NULL ;
if ( ! g_file_set_contents ( file_name , output . str ( ) . c_str ( ) , output . str ( ) . size ( ) , & err ) ) {
# ifndef PLATFORM_WINDOWS
: : close ( fd ) ;
# endif
g_unlink ( file_name ) ;
if ( err ) {
error < < string_compose ( _ ( " Could not save bindings to file (%1) " ) , err - > message ) < < endmsg ;
g_error_free ( err ) ;
}
return ;
}
# ifndef PLATFORM_WINDOWS
: : close ( fd ) ;
# endif
PBD : : open_uri ( string_compose ( " file:///%1 " , file_name ) ) ;
2005-12-06 01:23:50 -05:00
2014-02-10 23:52:07 -05:00
halt_connection . disconnect ( ) ;
AudioEngine : : instance ( ) - > stop ( ) ;
2019-07-04 16:21:49 -04:00
exit ( EXIT_SUCCESS ) ;
2005-09-25 14:42:24 -04:00
}
2015-10-26 14:35:06 -04:00
2005-09-25 14:42:24 -04:00
/* this being a GUI and all, we want peakfiles */
2006-06-14 21:34:54 -04:00
AudioFileSource : : set_build_peakfiles ( true ) ;
AudioFileSource : : set_build_missing_peakfiles ( true ) ;
2005-09-25 14:42:24 -04:00
2007-01-11 14:50:49 -05:00
/* set default clock modes */
2007-01-09 18:24:54 -05:00
2022-03-15 10:00:19 -04:00
primary_clock - > set_mode ( AudioClock : : BBT ) ;
secondary_clock - > set_mode ( AudioClock : : Timecode ) ;
2007-01-09 18:24:54 -05:00
2005-09-25 14:42:24 -04:00
/* start the time-of-day-clock */
2009-10-14 12:10:01 -04:00
2015-10-27 13:43:31 -04:00
# ifndef __APPLE__
2010-03-18 22:49:01 -04:00
/* OS X provides a nearly-always visible wallclock, so don't be stupid */
2005-09-25 14:42:24 -04:00
update_wall_clock ( ) ;
2012-12-26 11:57:34 -05:00
Glib : : signal_timeout ( ) . connect_seconds ( sigc : : mem_fun ( * this , & ARDOUR_UI : : update_wall_clock ) , 1 ) ;
2007-10-11 18:07:47 -04:00
# endif
2005-09-25 14:42:24 -04:00
2014-09-06 06:52:29 -04:00
{
DisplaySuspender ds ;
Config - > ParameterChanged . connect ( forever_connections , MISSING_INVALIDATOR , boost : : bind ( & ARDOUR_UI : : parameter_changed , this , _1 ) , gui_context ( ) ) ;
boost : : function < void ( string ) > pc ( boost : : bind ( & ARDOUR_UI : : parameter_changed , this , _1 ) ) ;
Config - > map_parameters ( pc ) ;
2014-12-22 13:39:41 -05:00
2015-01-02 09:44:54 -05:00
UIConfiguration : : instance ( ) . map_parameters ( pc ) ;
2014-09-06 06:52:29 -04:00
}
2005-09-25 14:42:24 -04:00
}
ARDOUR_UI : : ~ ARDOUR_UI ( )
{
2015-01-02 09:44:54 -05:00
UIConfiguration : : instance ( ) . save_state ( ) ;
2013-10-07 20:27:54 -04:00
2019-08-11 14:37:07 -04:00
ARDOUR_UI_UTILS : : inhibit_screensaver ( false ) ;
2013-03-12 17:00:09 -04:00
stop_video_server ( ) ;
2014-09-10 20:37:42 -04:00
2020-10-26 17:55:00 -04:00
/* unsubscribe from AudioEngine::Stopped */
if ( recorder ) {
recorder - > cleanup ( ) ;
}
2014-09-10 20:37:42 -04:00
if ( getenv ( " ARDOUR_RUNNING_UNDER_VALGRIND " ) ) {
// don't bother at 'real' exit. the OS cleans up for us.
2016-03-15 15:31:41 -04:00
delete big_clock ; big_clock = 0 ;
delete primary_clock ; primary_clock = 0 ;
delete secondary_clock ; secondary_clock = 0 ;
delete _process_thread ; _process_thread = 0 ;
2016-12-19 21:11:21 -05:00
delete time_info_box ; time_info_box = 0 ;
2016-03-15 15:31:41 -04:00
delete meterbridge ; meterbridge = 0 ;
2022-01-24 15:24:55 -05:00
delete duplicate_routes_dialog ; duplicate_routes_dialog = 0 ;
2021-11-08 20:27:38 -05:00
delete trigger_page ; trigger_page = 0 ;
2020-10-26 17:55:00 -04:00
delete recorder ; recorder = 0 ;
2016-03-15 15:31:41 -04:00
delete editor ; editor = 0 ;
delete mixer ; mixer = 0 ;
2017-01-20 05:48:59 -05:00
delete rc_option_editor ; rc_option_editor = 0 ; // failed to wrap object warning
2016-03-15 15:31:41 -04:00
delete nsm ; nsm = 0 ;
delete gui_object_state ; gui_object_state = 0 ;
2019-03-07 11:02:12 -05:00
delete _shared_popup_menu ; _shared_popup_menu = 0 ;
2016-05-10 10:03:45 -04:00
delete main_window_visibility ;
2014-09-10 20:40:18 -04:00
FastMeter : : flush_pattern_cache ( ) ;
2017-07-16 16:13:46 -04:00
ArdourFader : : flush_pattern_cache ( ) ;
2020-11-24 23:33:16 -05:00
} else if ( mixer ) {
/* drop references to any PluginInfoPtr */
delete mixer - > plugin_selector ( ) ;
2014-09-10 20:37:42 -04:00
}
2015-09-11 18:29:25 -04:00
2020-11-24 23:33:16 -05:00
2015-09-11 18:29:25 -04:00
# ifndef NDEBUG
/* Small trick to flush main-thread event pool.
* Other thread - pools are destroyed at pthread_exit ( ) ,
* but tmain thread termination is too late to trigger Pool : : ~ Pool ( )
*/
SessionEvent * ev = new SessionEvent ( SessionEvent : : SetTransportSpeed , SessionEvent : : Clear , SessionEvent : : Immediate , 0 , 0 ) ; // get the pool reference, values don't matter since the event is never queued.
delete ev - > event_pool ( ) ;
# endif
2005-09-25 14:42:24 -04:00
}
gint
ARDOUR_UI : : configure_timeout ( )
{
2008-09-10 11:03:30 -04:00
if ( last_configure_time = = 0 ) {
2005-09-25 14:42:24 -04:00
/* no configure events yet */
2010-03-18 22:49:01 -04:00
return true ;
2005-09-25 14:42:24 -04:00
}
/* force a gap of 0.5 seconds since the last configure event
*/
2008-09-10 11:03:30 -04:00
if ( get_microseconds ( ) - last_configure_time < 500000 ) {
2010-03-18 22:49:01 -04:00
return true ;
2005-09-25 14:42:24 -04:00
} else {
have_configure_timeout = false ;
save_ardour_state ( ) ;
2010-03-18 22:49:01 -04:00
return false ;
2005-09-25 14:42:24 -04:00
}
}
gboolean
2009-07-21 11:55:17 -04:00
ARDOUR_UI : : configure_handler ( GdkEventConfigure * /*conf*/ )
2005-09-25 14:42:24 -04:00
{
if ( have_configure_timeout ) {
2008-09-10 11:03:30 -04:00
last_configure_time = get_microseconds ( ) ;
2005-09-25 14:42:24 -04:00
} else {
2009-12-11 18:29:48 -05:00
Glib : : signal_timeout ( ) . connect ( sigc : : mem_fun ( * this , & ARDOUR_UI : : configure_timeout ) , 100 ) ;
2005-09-25 14:42:24 -04:00
have_configure_timeout = true ;
}
2009-10-14 12:10:01 -04:00
2005-09-25 14:42:24 -04:00
return FALSE ;
}
2017-02-21 09:44:12 -05:00
void
ARDOUR_UI : : set_transport_controllable_state ( const XMLNode & node )
{
2016-08-28 18:58:39 -04:00
std : : string str ;
2017-02-21 09:44:12 -05:00
2016-08-28 18:58:39 -04:00
if ( node . get_property ( " roll " , str ) ) {
roll_controllable - > set_id ( str ) ;
2017-02-21 09:44:12 -05:00
}
2016-08-28 18:58:39 -04:00
if ( node . get_property ( " stop " , str ) ) {
stop_controllable - > set_id ( str ) ;
2017-02-21 09:44:12 -05:00
}
2016-08-28 18:58:39 -04:00
if ( node . get_property ( " goto-start " , str ) ) {
goto_start_controllable - > set_id ( str ) ;
2017-02-21 09:44:12 -05:00
}
2016-08-28 18:58:39 -04:00
if ( node . get_property ( " goto-end " , str ) ) {
goto_end_controllable - > set_id ( str ) ;
2017-02-21 09:44:12 -05:00
}
2016-08-28 18:58:39 -04:00
if ( node . get_property ( " auto-loop " , str ) ) {
auto_loop_controllable - > set_id ( str ) ;
2017-02-21 09:44:12 -05:00
}
2016-08-28 18:58:39 -04:00
if ( node . get_property ( " play-selection " , str ) ) {
play_selection_controllable - > set_id ( str ) ;
2017-02-21 09:44:12 -05:00
}
2016-08-28 18:58:39 -04:00
if ( node . get_property ( " rec " , str ) ) {
rec_controllable - > set_id ( str ) ;
2017-02-21 09:44:12 -05:00
}
2016-08-28 18:58:39 -04:00
if ( node . get_property ( " shuttle " , str ) ) {
shuttle_box . controllable ( ) - > set_id ( str ) ;
2017-02-21 09:44:12 -05:00
}
}
XMLNode &
ARDOUR_UI : : get_transport_controllable_state ( )
{
XMLNode * node = new XMLNode ( X_ ( " TransportControllables " ) ) ;
2016-08-19 07:41:31 -04:00
2016-08-28 18:58:39 -04:00
node - > set_property ( X_ ( " roll " ) , roll_controllable - > id ( ) ) ;
node - > set_property ( X_ ( " stop " ) , stop_controllable - > id ( ) ) ;
2017-05-25 06:42:45 -04:00
node - > set_property ( X_ ( " goto-start " ) , goto_start_controllable - > id ( ) ) ;
node - > set_property ( X_ ( " goto-end " ) , goto_end_controllable - > id ( ) ) ;
node - > set_property ( X_ ( " auto-loop " ) , auto_loop_controllable - > id ( ) ) ;
node - > set_property ( X_ ( " play-selection " ) , play_selection_controllable - > id ( ) ) ;
2016-08-28 18:58:39 -04:00
node - > set_property ( X_ ( " rec " ) , rec_controllable - > id ( ) ) ;
node - > set_property ( X_ ( " shuttle " ) , shuttle_box . controllable ( ) - > id ( ) ) ;
2017-02-21 09:44:12 -05:00
return * node ;
}
2007-04-22 14:01:10 -04:00
void
2015-07-09 13:56:12 -04:00
ARDOUR_UI : : session_dirty_changed ( )
2007-04-22 14:01:10 -04:00
{
2015-07-09 13:56:12 -04:00
update_autosave ( ) ;
update_title ( ) ;
}
2007-04-22 14:01:10 -04:00
2015-07-09 13:56:12 -04:00
void
ARDOUR_UI : : update_autosave ( )
{
2009-12-17 13:24:23 -05:00
if ( _session & & _session - > dirty ( ) ) {
2007-05-17 22:41:16 -04:00
if ( _autosave_connection . connected ( ) ) {
_autosave_connection . disconnect ( ) ;
}
2009-12-11 18:29:48 -05:00
_autosave_connection = Glib : : signal_timeout ( ) . connect ( sigc : : mem_fun ( * this , & ARDOUR_UI : : autosave_session ) ,
2007-05-17 22:41:16 -04:00
Config - > get_periodic_safety_backup_interval ( ) * 1000 ) ;
2007-04-22 14:01:10 -04:00
2007-05-17 22:41:16 -04:00
} else {
if ( _autosave_connection . connected ( ) ) {
_autosave_connection . disconnect ( ) ;
2009-10-14 12:10:01 -04:00
}
2007-05-17 22:41:16 -04:00
}
2007-04-22 14:01:10 -04:00
}
2010-08-16 15:58:34 -04:00
void
ARDOUR_UI : : queue_finish ( )
{
Glib : : signal_idle ( ) . connect ( mem_fun ( * this , & ARDOUR_UI : : idle_finish ) ) ;
}
bool
ARDOUR_UI : : idle_finish ( )
{
finish ( ) ;
return false ; /* do not call again */
}
2005-09-25 14:42:24 -04:00
void
ARDOUR_UI : : finish ( )
{
2020-03-24 20:26:12 -04:00
bool delete_unnamed_session = false ;
2013-04-08 22:05:07 -04:00
if ( _session ) {
2020-03-24 21:22:50 -04:00
const bool unnamed = _session - > unnamed ( ) ;
2013-04-08 22:05:07 -04:00
ARDOUR_UI : : instance ( ) - > video_timeline - > sync_session_state ( ) ;
2008-01-10 17:22:29 -05:00
2020-03-24 20:26:12 -04:00
if ( _session - > dirty ( ) | | unnamed ) {
2011-05-22 16:02:50 -04:00
vector < string > actions ;
actions . push_back ( _ ( " Don't quit " ) ) ;
2020-03-24 20:26:12 -04:00
if ( _session - > unnamed ( ) ) {
actions . push_back ( _ ( " Discard session " ) ) ;
actions . push_back ( _ ( " Name session and quit " ) ) ;
} else {
actions . push_back ( _ ( " Just quit " ) ) ;
actions . push_back ( _ ( " Save and quit " ) ) ;
}
switch ( ask_about_saving_session ( actions ) ) {
2008-01-10 17:22:29 -05:00
case - 1 :
return ;
break ;
case 1 :
2020-03-24 20:26:12 -04:00
if ( unnamed ) {
rename_session ( true ) ;
}
2008-01-10 17:22:29 -05:00
/* use the default name */
if ( save_state_canfail ( " " ) ) {
/* failed - don't quit */
2019-12-14 17:31:24 -05:00
ArdourMessageDialog msg ( _main_window ,
2012-04-22 21:02:33 -04:00
string_compose ( _ ( " \
% 1 was unable to save your session . \ n \ n \
2005-09-25 14:42:24 -04:00
If you still wish to quit , please use the \ n \ n \
2012-04-22 21:02:33 -04:00
\ " Just quit \" option. " ) , PROGRAM_NAME ) ) ;
2008-01-10 17:22:29 -05:00
msg . run ( ) ;
return ;
}
break ;
case 0 :
2020-03-24 20:26:12 -04:00
if ( unnamed ) {
delete_unnamed_session = true ;
}
2008-01-10 17:22:29 -05:00
break ;
2005-09-25 14:42:24 -04:00
}
}
2009-10-14 12:10:01 -04:00
2009-11-26 08:26:30 -05:00
second_connection . disconnect ( ) ;
point_one_second_connection . disconnect ( ) ;
2013-07-11 08:50:33 -04:00
point_zero_something_second_connection . disconnect ( ) ;
2014-08-30 14:57:22 -04:00
fps_connection . disconnect ( ) ;
2010-08-17 22:20:15 -04:00
}
/* Save state before deleting the session, as that causes some
windows to be destroyed before their visible state can be
saved .
*/
save_ardour_state ( ) ;
2016-09-18 04:03:37 -04:00
if ( key_editor . get ( false ) ) {
key_editor - > disconnect ( ) ;
}
2016-08-21 16:08:54 -04:00
2013-05-04 22:02:05 -04:00
close_all_dialogs ( ) ;
2010-08-17 22:20:15 -04:00
if ( _session ) {
2020-03-24 20:26:12 -04:00
if ( delete_unnamed_session ) {
2021-12-15 17:52:15 -05:00
/* This may run a recursive dialog, which will allow
* for the GTK idle handler to do things . Not a problem
* in itself , but something to keep in mind since it
* isn ' t visually apparent that this will allow a
* recursive main loop to execute .
*/
2020-03-24 22:58:38 -04:00
ask_about_scratch_deletion ( ) ;
2020-03-24 20:26:12 -04:00
}
2010-11-25 15:37:39 -05:00
_session - > set_clean ( ) ;
2009-12-17 13:24:23 -05:00
delete _session ;
_session = 0 ;
2020-03-24 20:26:12 -04:00
2007-01-09 18:24:54 -05:00
}
2008-01-10 17:22:29 -05:00
2021-12-15 17:52:15 -05:00
delete ARDOUR_UI : : instance ( ) - > video_timeline ;
ARDOUR_UI : : instance ( ) - > video_timeline = NULL ;
stop_video_server ( ) ;
2013-08-08 22:28:31 -04:00
halt_connection . disconnect ( ) ;
2013-09-09 13:17:53 -04:00
AudioEngine : : instance ( ) - > stop ( ) ;
2005-12-02 14:18:26 -05:00
quit ( ) ;
2005-09-25 14:42:24 -04:00
}
2020-03-24 22:58:38 -04:00
void
ARDOUR_UI : : ask_about_scratch_deletion ( )
{
if ( ! _session ) {
return ;
}
string path = _session - > path ( ) ;
ArdourMessageDialog msg ( _main_window ,
_ ( " DANGER! " ) ,
true ,
Gtk : : MESSAGE_WARNING ,
Gtk : : BUTTONS_NONE , true ) ;
msg . set_secondary_text ( string_compose ( _ ( " You have not named this session yet. \n "
" You can continue to use it as \n \n "
" %1 \n \n "
" or it will be deleted. \n \n "
" Deletion is permanent and irreversible. " ) , _session - > name ( ) ) ) ;
msg . set_title ( _ ( " SCRATCH SESSION - DANGER! " ) ) ;
msg . add_button ( _ ( " Delete this session (IRREVERSIBLE!) " ) , RESPONSE_OK ) ;
msg . add_button ( _ ( " Do not delete " ) , RESPONSE_CANCEL ) ;
msg . set_default_response ( RESPONSE_CANCEL ) ;
msg . set_position ( Gtk : : WIN_POS_MOUSE ) ;
int r = msg . run ( ) ;
if ( r = = Gtk : : RESPONSE_OK ) {
PBD : : remove_directory ( path ) ;
2020-03-25 12:25:00 -04:00
} else {
_session - > end_unnamed_status ( ) ;
2020-03-24 22:58:38 -04:00
}
}
2014-12-25 10:02:00 -05:00
void
2005-09-25 14:42:24 -04:00
ARDOUR_UI : : every_second ( )
{
update_cpu_load ( ) ;
update_disk_space ( ) ;
2012-10-12 12:25:57 -04:00
update_timecode_format ( ) ;
2015-09-15 11:46:48 -04:00
update_peak_thread_work ( ) ;
2013-03-21 16:16:48 -04:00
2013-04-02 14:33:39 -04:00
if ( nsm & & nsm - > is_active ( ) ) {
2013-03-21 16:16:48 -04:00
nsm - > check ( ) ;
if ( ! _was_dirty & & _session - > dirty ( ) ) {
nsm - > is_dirty ( ) ;
_was_dirty = true ;
}
else if ( _was_dirty & & ! _session - > dirty ( ) ) {
nsm - > is_clean ( ) ;
_was_dirty = false ;
}
}
2005-09-25 14:42:24 -04:00
}
2014-12-25 10:02:00 -05:00
void
2005-09-25 14:42:24 -04:00
ARDOUR_UI : : every_point_one_seconds ( )
{
2018-02-09 10:59:39 -05:00
if ( editor ) editor - > build_region_boundary_cache ( ) ;
2005-09-25 14:42:24 -04:00
}
2014-12-25 10:02:00 -05:00
void
2013-07-11 08:50:33 -04:00
ARDOUR_UI : : every_point_zero_something_seconds ( )
2005-09-25 14:42:24 -04:00
{
2013-07-11 08:50:33 -04:00
// august 2007: actual update frequency: 25Hz (40ms), not 100Hz
2007-10-11 18:07:47 -04:00
2022-01-26 15:17:53 -05:00
if ( editor_meter & & UIConfiguration : : instance ( ) . get_show_editor_meter ( ) & & editor_meter_peak_display . get_mapped ( ) ) {
2020-04-10 17:36:17 -04:00
if ( _clear_editor_meter ) {
editor_meter - > clear_meters ( ) ;
editor_meter_peak_display . set_active_state ( Gtkmm2ext : : Off ) ;
_clear_editor_meter = false ;
_editor_meter_peaked = false ;
}
const float mpeak = editor_meter - > update_meters ( ) ;
const bool peaking = mpeak > UIConfiguration : : instance ( ) . get_meter_peak ( ) ;
if ( ! _editor_meter_peaked & & peaking ) {
editor_meter_peak_display . set_active_state ( Gtkmm2ext : : ExplicitActive ) ;
_editor_meter_peaked = true ;
2013-08-03 07:59:22 -04:00
}
2013-07-24 16:04:46 -04:00
}
2014-08-30 14:57:22 -04:00
}
void
ARDOUR_UI : : set_fps_timeout_connection ( )
{
unsigned int interval = 40 ;
if ( ! _session ) return ;
if ( _session - > timecode_frames_per_second ( ) ! = 0 ) {
/* ideally we'll use a select() to sleep and not accumulate
* idle time to provide a regular periodic signal .
* See linux_vst_gui_support . cc ' elapsed_time_ms ' .
* However , that ' ll require a dedicated thread and cross - thread
* signals to the GUI Thread . .
*/
interval = floor ( 500. /* update twice per FPS, since Glib::signal_timeout is very irregular */
2017-09-18 12:39:17 -04:00
* _session - > sample_rate ( ) / _session - > nominal_sample_rate ( )
2014-08-30 14:57:22 -04:00
/ _session - > timecode_frames_per_second ( )
) ;
2014-10-25 13:21:15 -04:00
# ifdef PLATFORM_WINDOWS
// the smallest windows scheduler time-slice is ~15ms.
// periodic GUI timeouts shorter than that will cause
// WaitForSingleObject to spinlock (100% of one CPU Core)
// and gtk never enters idle mode.
// also changing timeBeginPeriod(1) does not affect that in
// any beneficial way, so we just limit the max rate for now.
interval = std : : max ( 30u , interval ) ; // at most ~33Hz.
# else
2014-08-30 14:57:22 -04:00
interval = std : : max ( 8u , interval ) ; // at most 120Hz.
2014-10-25 13:21:15 -04:00
# endif
2014-08-30 14:57:22 -04:00
}
fps_connection . disconnect ( ) ;
2014-12-25 10:02:00 -05:00
Timers : : set_fps_interval ( interval ) ;
2014-08-30 14:57:22 -04:00
}
2005-09-25 14:42:24 -04:00
void
2017-09-18 12:39:17 -04:00
ARDOUR_UI : : update_sample_rate ( samplecnt_t )
2005-09-25 14:42:24 -04:00
{
2020-03-29 15:02:26 -04:00
std : : string label = string_compose ( X_ ( " <span weight= \" ultralight \" >%1</span>: " ) , _ ( " Audio " ) ) ;
2005-09-25 14:42:24 -04:00
2009-12-11 18:29:48 -05:00
ENSURE_GUI_THREAD ( * this , & ARDOUR_UI : : update_sample_rate , ignored )
2005-09-25 14:42:24 -04:00
2018-11-28 09:19:39 -05:00
if ( ! AudioEngine : : instance ( ) - > running ( ) ) {
2005-09-25 14:42:24 -04:00
2020-03-29 15:02:26 -04:00
sample_rate_label . set_markup ( label + _ ( " none " ) ) ;
2005-09-25 14:42:24 -04:00
} else {
2017-09-18 12:39:17 -04:00
samplecnt_t rate = AudioEngine : : instance ( ) - > sample_rate ( ) ;
2009-10-14 12:10:01 -04:00
2013-08-07 22:22:11 -04:00
if ( rate = = 0 ) {
2020-03-29 12:56:08 -04:00
2013-08-07 22:22:11 -04:00
/* no sample rate available */
2020-03-29 15:02:26 -04:00
sample_rate_label . set_markup ( label + _ ( " none " ) ) ;
2020-03-29 12:56:08 -04:00
2005-09-25 14:42:24 -04:00
} else {
2020-03-29 12:56:08 -04:00
char buf [ 64 ] ;
2013-08-07 22:22:11 -04:00
if ( fmod ( rate , 1000.0 ) ! = 0.0 ) {
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " %.1f %s / %4.1f %s " ,
( float ) rate / 1000.0f , _ ( " kHz " ) ,
( AudioEngine : : instance ( ) - > usecs_per_cycle ( ) / 1000.0f ) , _ ( " ms " ) ) ;
2013-08-07 22:22:11 -04:00
} else {
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " % " PRId64 " %s / %4.1f %s " ,
rate / 1000 , _ ( " kHz " ) ,
( AudioEngine : : instance ( ) - > usecs_per_cycle ( ) / 1000.0f ) , _ ( " ms " ) ) ;
2013-08-07 22:22:11 -04:00
}
2020-03-29 15:02:26 -04:00
sample_rate_label . set_markup ( label + buf ) ;
2005-09-25 14:42:24 -04:00
}
}
}
2011-07-02 20:45:15 -04:00
void
ARDOUR_UI : : update_format ( )
{
if ( ! _session ) {
format_label . set_text ( " " ) ;
return ;
}
stringstream s ;
2020-03-29 15:02:26 -04:00
s < < X_ ( " <span weight= \" ultralight \" > " ) < < _ ( " File " ) < < X_ ( " </span>: " ) ;
2011-07-02 20:45:15 -04:00
switch ( _session - > config . get_native_file_header_format ( ) ) {
case BWF :
2011-11-22 07:35:25 -05:00
s < < _ ( " BWF " ) ;
2011-07-02 20:45:15 -04:00
break ;
case WAVE :
2011-11-22 07:35:25 -05:00
s < < _ ( " WAV " ) ;
2011-07-02 20:45:15 -04:00
break ;
case WAVE64 :
2011-11-22 07:35:25 -05:00
s < < _ ( " WAV64 " ) ;
2011-07-02 20:45:15 -04:00
break ;
case CAF :
2011-11-22 07:35:25 -05:00
s < < _ ( " CAF " ) ;
2011-07-02 20:45:15 -04:00
break ;
case AIFF :
2011-11-22 07:35:25 -05:00
s < < _ ( " AIFF " ) ;
2011-07-02 20:45:15 -04:00
break ;
case iXML :
2011-11-22 07:35:25 -05:00
s < < _ ( " iXML " ) ;
2011-07-02 20:45:15 -04:00
break ;
case RF64 :
2011-11-22 07:35:25 -05:00
s < < _ ( " RF64 " ) ;
2011-07-02 20:45:15 -04:00
break ;
2015-09-08 17:40:18 -04:00
case RF64_WAV :
s < < _ ( " RF64/WAV " ) ;
break ;
case MBWF :
s < < _ ( " MBWF " ) ;
break ;
2018-11-07 13:53:23 -05:00
case FLAC :
s < < _ ( " FLAC " ) ;
break ;
2011-07-02 20:45:15 -04:00
}
s < < " " ;
2015-09-08 16:30:30 -04:00
2011-07-02 20:45:15 -04:00
switch ( _session - > config . get_native_file_data_format ( ) ) {
case FormatFloat :
2011-11-22 07:35:25 -05:00
s < < _ ( " 32-float " ) ;
2011-07-02 20:45:15 -04:00
break ;
case FormatInt24 :
2011-11-22 07:35:25 -05:00
s < < _ ( " 24-int " ) ;
2011-07-02 20:45:15 -04:00
break ;
case FormatInt16 :
2011-11-22 07:35:25 -05:00
s < < _ ( " 16-int " ) ;
2011-07-02 20:45:15 -04:00
break ;
}
2011-10-22 20:15:35 -04:00
format_label . set_markup ( s . str ( ) ) ;
2011-07-02 20:45:15 -04:00
}
2020-03-29 18:14:25 -04:00
void
ARDOUR_UI : : update_path_label ( )
{
stringstream s ;
s < < X_ ( " <span weight= \" ultralight \" > " ) < < _ ( " Path " ) < < X_ ( " </span>: " ) ;
if ( _session ) {
s < < Gtkmm2ext : : markup_escape_text ( _session - > path ( ) ) ;
} else {
s < < " - " ;
}
session_path_label . set_markup ( s . str ( ) ) ;
}
2005-09-25 14:42:24 -04:00
void
2018-02-20 06:15:29 -05:00
ARDOUR_UI : : update_cpu_load ( )
2005-09-25 14:42:24 -04:00
{
2018-02-20 06:15:29 -05:00
const unsigned int x = _session ? _session - > get_xrun_count ( ) : 0 ;
2020-03-29 15:04:57 -04:00
const bool fw = AudioEngine : : instance ( ) - > freewheeling ( ) ;
2018-02-20 06:15:29 -05:00
double const c = AudioEngine : : instance ( ) - > get_dsp_load ( ) ;
2011-10-23 17:31:09 -04:00
2020-03-29 15:02:26 -04:00
std : : string label = string_compose ( X_ ( " <span weight= \" ultralight \" >%1</span>: " ) , _ ( " DSP " ) ) ;
2020-03-29 15:04:57 -04:00
const char * const bg = ( c > 90 & & ! fw ) ? " background= \" red \" foreground= \" white \" " : " " ;
2018-02-20 06:53:21 -05:00
2020-03-29 15:02:26 -04:00
char buf [ 256 ] ;
2018-02-20 06:15:29 -05:00
if ( x > 9999 ) {
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " <span face= \" monospace \" %s>%2.0f%%</span> (>10k) " , bg , c ) ;
2018-02-20 06:15:29 -05:00
} else if ( x > 0 ) {
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " <span face= \" monospace \" %s>%2.0f%%</span> (%d) " , bg , c , x ) ;
2015-04-28 21:10:27 -04:00
} else {
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " <span face= \" monospace \" %s>%2.0f%%</span> " , bg , c ) ;
2015-04-28 21:10:27 -04:00
}
2020-03-29 15:02:26 -04:00
dsp_load_label . set_markup ( label + buf ) ;
2015-04-28 21:10:27 -04:00
2018-02-20 06:15:29 -05:00
if ( x > 9999 ) {
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " %.1f%% X: >10k \n %s " , c , _ ( " Shift+Click to clear xruns. " ) ) ;
2018-02-20 06:15:29 -05:00
} else if ( x > 0 ) {
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " %.1f%% X: %u \n %s " , c , x , _ ( " Shift+Click to clear xruns. " ) ) ;
2018-02-20 06:15:29 -05:00
} else {
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " %.1f%% " , c ) ;
2018-02-20 06:15:29 -05:00
}
2020-03-29 15:02:26 -04:00
ArdourWidgets : : set_tooltip ( dsp_load_label , label + buf ) ;
2005-09-25 14:42:24 -04:00
}
2015-09-15 11:46:48 -04:00
void
ARDOUR_UI : : update_peak_thread_work ( )
{
char buf [ 64 ] ;
const int c = SourceFactory : : peak_work_queue_length ( ) ;
if ( c > 0 ) {
2020-03-29 15:02:26 -04:00
std : : string label = string_compose ( X_ ( " <span weight= \" ultralight \" >%1</span>: " ) , _ ( " PkBld " ) ) ;
2020-03-29 15:04:21 -04:00
const char * const bg = c > 2 ? " background= \" red \" foreground= \" white \" " : " " ;
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " <span %s>%d</span> " , bg , c ) ;
2020-03-29 15:02:26 -04:00
peak_thread_work_label . set_markup ( label + buf ) ;
2015-09-15 11:46:48 -04:00
} else {
peak_thread_work_label . set_markup ( X_ ( " " ) ) ;
}
}
2005-09-25 14:42:24 -04:00
void
2006-11-19 11:45:16 -05:00
ARDOUR_UI : : count_recenabled_streams ( Route & route )
2005-09-25 14:42:24 -04:00
{
2006-07-27 21:08:57 -04:00
Track * track = dynamic_cast < Track * > ( & route ) ;
2016-04-08 16:49:47 -04:00
if ( track & & track - > rec_enable_control ( ) - > get_value ( ) ) {
2007-06-03 20:05:33 -04:00
rec_enabled_streams + = track - > n_inputs ( ) . n_total ( ) ;
2005-09-25 14:42:24 -04:00
}
}
2018-02-20 06:15:29 -05:00
void
ARDOUR_UI : : format_disk_space_label ( float remain_sec )
{
if ( remain_sec < 0 ) {
disk_space_label . set_text ( _ ( " N/A " ) ) ;
ArdourWidgets : : set_tooltip ( disk_space_label , _ ( " Unknown " ) ) ;
return ;
}
char buf [ 64 ] ;
int sec = floor ( remain_sec ) ;
int hrs = sec / 3600 ;
int mins = ( sec / 60 ) % 60 ;
int secs = sec % 60 ;
snprintf ( buf , sizeof ( buf ) , _ ( " %02dh:%02dm:%02ds " ) , hrs , mins , secs ) ;
2020-03-29 21:52:20 -04:00
ArdourWidgets : : set_tooltip ( disk_space_label , string_compose ( " %1: %2 " , _ ( " Available record time " ) , buf ) ) ;
2018-02-20 06:15:29 -05:00
2020-03-29 15:02:26 -04:00
std : : string label = string_compose ( X_ ( " <span weight= \" ultralight \" >%1</span>: " ) , _ ( " Rec " ) ) ;
2020-03-29 12:56:08 -04:00
2018-02-20 06:15:29 -05:00
if ( remain_sec > 86400 ) {
2020-03-29 19:09:00 -04:00
disk_space_label . set_markup ( label + _ ( " >24h " ) ) ;
2018-02-20 06:15:29 -05:00
} else if ( remain_sec > 32400 /* 9 hours */ ) {
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " %.0f " , remain_sec / 3600.f ) ;
2020-03-29 15:02:26 -04:00
disk_space_label . set_markup ( label + buf + S_ ( " hours|h " ) ) ;
2018-02-20 06:15:29 -05:00
} else if ( remain_sec > 5940 /* 99 mins */ ) {
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " %.1f " , remain_sec / 3600.f ) ;
2020-03-29 15:02:26 -04:00
disk_space_label . set_markup ( label + buf + S_ ( " hours|h " ) ) ;
2018-02-20 06:15:29 -05:00
} else {
2020-03-29 12:56:08 -04:00
snprintf ( buf , sizeof ( buf ) , " %.0f " , remain_sec / 60.f ) ;
2020-03-29 15:02:26 -04:00
disk_space_label . set_markup ( label + buf + S_ ( " minutes|m " ) ) ;
2018-02-20 06:15:29 -05:00
}
}
2005-09-25 14:42:24 -04:00
void
ARDOUR_UI : : update_disk_space ( )
{
2009-12-17 13:24:23 -05:00
if ( _session = = 0 ) {
2018-02-20 06:15:29 -05:00
format_disk_space_label ( - 1 ) ;
2005-09-25 14:42:24 -04:00
return ;
}
2017-09-18 12:39:17 -04:00
boost : : optional < samplecnt_t > opt_samples = _session - > available_capture_duration ( ) ;
samplecnt_t fr = _session - > sample_rate ( ) ;
2009-10-14 12:10:01 -04:00
2013-08-07 22:22:11 -04:00
if ( fr = = 0 ) {
/* skip update - no SR available */
2018-02-20 06:15:29 -05:00
format_disk_space_label ( - 1 ) ;
2013-08-07 22:22:11 -04:00
return ;
}
2017-09-18 12:39:17 -04:00
if ( ! opt_samples ) {
2012-06-12 12:41:29 -04:00
/* Available space is unknown */
2018-02-20 06:15:29 -05:00
format_disk_space_label ( - 1 ) ;
2019-11-21 11:49:20 -05:00
} else if ( opt_samples . value_or ( 0 ) = = max_samplecnt ) {
2018-02-20 06:15:29 -05:00
format_disk_space_label ( max_samplecnt ) ;
2005-09-25 14:42:24 -04:00
} else {
2006-11-19 11:45:16 -05:00
rec_enabled_streams = 0 ;
2015-04-02 14:51:23 -04:00
_session - > foreach_route ( this , & ARDOUR_UI : : count_recenabled_streams , false ) ;
2009-10-14 12:10:01 -04:00
2019-11-21 11:49:20 -05:00
samplecnt_t samples = opt_samples . value_or ( 0 ) ;
2012-06-12 12:41:29 -04:00
2006-11-19 11:45:16 -05:00
if ( rec_enabled_streams ) {
2017-09-18 12:39:17 -04:00
samples / = rec_enabled_streams ;
2005-09-25 14:42:24 -04:00
}
2009-10-14 12:10:01 -04:00
2018-02-20 06:15:29 -05:00
format_disk_space_label ( samples / ( float ) fr ) ;
2005-09-25 14:42:24 -04:00
}
2009-10-14 12:10:01 -04:00
}
2005-09-25 14:42:24 -04:00
2012-10-12 12:25:57 -04:00
void
ARDOUR_UI : : update_timecode_format ( )
{
2020-03-29 15:02:26 -04:00
std : : string label = string_compose ( X_ ( " <span weight= \" ultralight \" >%1</span>: " ) , S_ ( " Timecode|TC " ) ) ;
2012-10-12 12:25:57 -04:00
if ( _session ) {
2012-10-12 18:04:21 -04:00
bool matching ;
2018-09-18 18:52:20 -04:00
boost : : shared_ptr < TimecodeTransportMaster > tcmaster ;
boost : : shared_ptr < TransportMaster > tm = TransportMasterManager : : instance ( ) . current ( ) ;
2012-10-12 18:04:21 -04:00
2020-01-12 12:04:12 -05:00
if ( ( tm - > type ( ) = = LTC | | tm - > type ( ) = = MTC ) & & ( tcmaster = boost : : dynamic_pointer_cast < TimecodeTransportMaster > ( tm ) ) ! = 0 & & tm - > locked ( ) ) {
2018-09-18 18:52:20 -04:00
matching = ( tcmaster - > apparent_timecode_format ( ) = = _session - > config . get_timecode_format ( ) ) ;
2012-10-12 18:04:21 -04:00
} else {
matching = true ;
}
2015-09-08 16:30:30 -04:00
2020-03-29 15:04:21 -04:00
const char * const bg = matching ? " " : " background= \" red \" foreground= \" white \" " ;
2020-03-29 12:56:08 -04:00
2020-03-29 15:02:26 -04:00
timecode_format_label . set_markup ( string_compose ( " %1<span%2>%3</span> " ,
label , bg ,
Timecode : : timecode_format_name ( _session - > config . get_timecode_format ( ) ) . c_str ( ) ) ) ;
2012-10-12 12:25:57 -04:00
} else {
2020-03-29 15:02:26 -04:00
timecode_format_label . set_markup ( label + _ ( " n/a " ) ) ;
2012-10-12 12:25:57 -04:00
}
2015-09-08 16:30:30 -04:00
}
2012-10-12 12:25:57 -04:00
2005-09-25 14:42:24 -04:00
gint
ARDOUR_UI : : update_wall_clock ( )
{
time_t now ;
struct tm * tm_now ;
2012-12-26 11:44:09 -05:00
static int last_min = - 1 ;
2005-09-25 14:42:24 -04:00
time ( & now ) ;
tm_now = localtime ( & now ) ;
2012-12-26 11:44:09 -05:00
if ( last_min ! = tm_now - > tm_min ) {
char buf [ 16 ] ;
sprintf ( buf , " %02d:%02d " , tm_now - > tm_hour , tm_now - > tm_min ) ;
wall_clock_label . set_text ( buf ) ;
last_min = tm_now - > tm_min ;
}
2005-09-25 14:42:24 -04:00
return TRUE ;
}
void
2020-03-19 11:03:28 -04:00
ARDOUR_UI : : session_add_midi_route (
bool disk ,
2016-03-28 12:07:43 -04:00
RouteGroup * route_group ,
uint32_t how_many ,
const string & name_template ,
bool strict_io ,
2016-05-06 10:04:05 -04:00
PluginInfoPtr instrument ,
2016-05-16 07:30:28 -04:00
Plugin : : PresetRecord * pset ,
2021-07-17 18:25:47 -04:00
ARDOUR : : PresentationInfo : : order_t order ,
2022-01-14 18:06:38 -05:00
bool trigger_visibility )
2005-09-25 14:42:24 -04:00
{
2020-03-19 11:03:28 -04:00
if ( _session = = 0 ) {
warning < < _ ( " You cannot add a track without a session already loaded. " ) < < endmsg ;
return ;
}
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one)
Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now.
Relevant (significant) changes:
- Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...)
- IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why)
- AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output.
- (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise.
- MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here.
- Random cleanups and variable renamings etc. because I have OCD and can't help myself. :)
Known broken: Loading of sessions containing MIDI tracks.
git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
2017-01-20 15:47:09 -05:00
if ( Profile - > get_mixbus ( ) ) {
strict_io = true ;
}
2009-10-14 12:10:01 -04:00
try {
2020-03-19 11:03:28 -04:00
if ( disk ) {
2015-09-08 16:30:30 -04:00
2020-03-19 11:03:28 -04:00
ChanCount one_midi_channel ;
one_midi_channel . set ( DataType : : MIDI , 1 ) ;
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one)
Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now.
Relevant (significant) changes:
- Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...)
- IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why)
- AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output.
- (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise.
- MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here.
- Random cleanups and variable renamings etc. because I have OCD and can't help myself. :)
Known broken: Loading of sessions containing MIDI tracks.
git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
2020-03-19 11:03:28 -04:00
list < boost : : shared_ptr < MidiTrack > > tracks ;
2022-01-14 18:06:38 -05:00
tracks = _session - > new_midi_track ( one_midi_channel , one_midi_channel , strict_io , instrument , pset , route_group , how_many , name_template , order , ARDOUR : : Normal , true , trigger_visibility ) ;
2015-09-08 16:30:30 -04:00
2020-03-19 11:03:28 -04:00
if ( tracks . size ( ) ! = how_many ) {
error < < string_compose ( P_ ( " could not create %1 new mixed track " , " could not create %1 new mixed tracks " , how_many ) , how_many ) < < endmsg ;
}
2016-03-15 23:41:19 -04:00
2020-03-19 11:03:28 -04:00
} else {
2016-05-16 07:30:28 -04:00
2020-03-19 11:03:28 -04:00
RouteList routes ;
routes = _session - > new_midi_route ( route_group , how_many , name_template , strict_io , instrument , pset , PresentationInfo : : MidiBus , order ) ;
2016-03-15 23:41:19 -04:00
2020-03-19 11:03:28 -04:00
if ( routes . size ( ) ! = how_many ) {
error < < string_compose ( P_ ( " could not create %1 new Midi Bus " , " could not create %1 new Midi Busses " , how_many ) , how_many ) < < endmsg ;
}
}
2016-03-15 23:41:19 -04:00
}
catch ( . . . ) {
2016-03-28 12:07:43 -04:00
display_insufficient_ports_message ( ) ;
return ;
}
2016-03-15 23:41:19 -04:00
}
2005-09-25 14:42:24 -04:00
void
2011-02-26 20:59:04 -05:00
ARDOUR_UI : : session_add_audio_route (
bool track ,
int32_t input_channels ,
int32_t output_channels ,
ARDOUR : : TrackMode mode ,
RouteGroup * route_group ,
uint32_t how_many ,
2016-03-28 12:07:43 -04:00
string const & name_template ,
2016-05-16 07:30:28 -04:00
bool strict_io ,
2021-10-08 15:38:39 -04:00
ARDOUR : : PresentationInfo : : order_t order ,
2022-01-14 18:06:38 -05:00
bool trigger_visibility )
2005-09-25 14:42:24 -04:00
{
2006-08-24 03:37:17 -04:00
list < boost : : shared_ptr < AudioTrack > > tracks ;
2009-01-30 02:40:13 -05:00
RouteList routes ;
2005-09-25 14:42:24 -04:00
2017-08-17 17:41:22 -04:00
assert ( _session ) ;
2005-09-25 14:42:24 -04:00
2009-10-14 12:10:01 -04:00
try {
2006-08-24 03:37:17 -04:00
if ( track ) {
2022-01-14 18:06:38 -05:00
tracks = _session - > new_audio_track ( input_channels , output_channels , route_group , how_many , name_template , order , mode , true , trigger_visibility ) ;
2006-08-24 03:37:17 -04:00
if ( tracks . size ( ) ! = how_many ) {
2015-09-08 16:30:30 -04:00
error < < string_compose ( P_ ( " could not create %1 new audio track " , " could not create %1 new audio tracks " , how_many ) , how_many )
2013-01-03 09:19:31 -05:00
< < endmsg ;
2005-09-25 14:42:24 -04:00
}
2006-08-24 03:37:17 -04:00
2005-09-25 14:42:24 -04:00
} else {
2006-08-24 03:37:17 -04:00
2016-05-16 07:30:28 -04:00
routes = _session - > new_audio_route ( input_channels , output_channels , route_group , how_many , name_template , PresentationInfo : : AudioBus , order ) ;
2006-08-24 03:37:17 -04:00
if ( routes . size ( ) ! = how_many ) {
2013-01-04 11:49:21 -05:00
error < < string_compose ( P_ ( " could not create %1 new audio bus " , " could not create %1 new audio busses " , how_many ) , how_many )
2013-01-03 09:19:31 -05:00
< < endmsg ;
2005-09-25 14:42:24 -04:00
}
}
}
catch ( . . . ) {
2016-03-28 12:07:43 -04:00
display_insufficient_ports_message ( ) ;
return ;
}
if ( strict_io ) {
for ( list < boost : : shared_ptr < AudioTrack > > : : iterator i = tracks . begin ( ) ; i ! = tracks . end ( ) ; + + i ) {
( * i ) - > set_strict_io ( true ) ;
}
for ( RouteList : : iterator i = routes . begin ( ) ; i ! = routes . end ( ) ; + + i ) {
( * i ) - > set_strict_io ( true ) ;
}
}
}
2018-11-01 16:13:06 -04:00
void
2019-08-06 16:16:44 -04:00
ARDOUR_UI : : session_add_foldback_bus ( int32_t channels , uint32_t how_many , string const & name_template )
2018-11-01 16:13:06 -04:00
{
RouteList routes ;
assert ( _session ) ;
try {
2019-08-06 16:16:44 -04:00
routes = _session - > new_audio_route ( channels , channels , 0 , how_many , name_template , PresentationInfo : : FoldbackBus , - 1 ) ;
2018-11-01 16:13:06 -04:00
if ( routes . size ( ) ! = how_many ) {
2018-11-13 01:29:27 -05:00
error < < string_compose ( P_ ( " could not create %1 new foldback bus " , " could not create %1 new foldback busses " , how_many ) , how_many )
2018-11-01 16:13:06 -04:00
< < endmsg ;
}
}
catch ( . . . ) {
display_insufficient_ports_message ( ) ;
return ;
}
}
2016-03-28 12:07:43 -04:00
void
ARDOUR_UI : : display_insufficient_ports_message ( )
{
2019-12-14 17:31:24 -05:00
ArdourMessageDialog msg ( _main_window ,
2016-03-28 12:07:43 -04:00
string_compose ( _ ( " There are insufficient ports available \n \
2005-09-25 14:42:24 -04:00
to create a new track or bus . \ n \
2010-08-16 20:28:20 -04:00
You should save % 1 , exit and \ n \
2014-04-10 10:21:47 -04:00
restart with more ports . " ), PROGRAM_NAME));
2016-03-28 12:07:43 -04:00
msg . run ( ) ;
2005-09-25 14:42:24 -04:00
}
void
2009-10-14 12:10:01 -04:00
ARDOUR_UI : : transport_goto_start ( )
2006-03-11 11:01:06 -05:00
{
2009-12-17 13:24:23 -05:00
if ( _session ) {
2019-09-22 13:44:06 -04:00
_session - > goto_start ( ) ;
2006-03-11 11:01:06 -05:00
/* force displayed area in editor to start no matter
what " follow playhead " setting is .
*/
2009-10-14 12:10:01 -04:00
2006-03-11 11:01:06 -05:00
if ( editor ) {
2017-09-18 12:39:17 -04:00
editor - > center_screen ( _session - > current_start_sample ( ) ) ;
2006-03-11 11:01:06 -05:00
}
}
}
void
ARDOUR_UI : : transport_goto_zero ( )
2005-09-25 14:42:24 -04:00
{
2009-12-17 13:24:23 -05:00
if ( _session ) {
_session - > request_locate ( 0 ) ;
2005-09-25 14:42:24 -04:00
/* force displayed area in editor to start no matter
what " follow playhead " setting is .
*/
2009-10-14 12:10:01 -04:00
2005-09-25 14:42:24 -04:00
if ( editor ) {
2007-01-11 15:36:35 -05:00
editor - > reset_x_origin ( 0 ) ;
2005-09-25 14:42:24 -04:00
}
}
}
2008-09-10 11:03:30 -04:00
void
ARDOUR_UI : : transport_goto_wallclock ( )
{
2009-12-17 13:24:23 -05:00
if ( _session & & editor ) {
2008-09-10 11:03:30 -04:00
time_t now ;
struct tm tmnow ;
2017-09-18 12:39:17 -04:00
samplepos_t samples ;
2009-10-14 12:10:01 -04:00
2008-09-10 11:03:30 -04:00
time ( & now ) ;
localtime_r ( & now , & tmnow ) ;
2015-09-08 16:30:30 -04:00
2017-09-18 12:39:17 -04:00
samplecnt_t sample_rate = _session - > sample_rate ( ) ;
2015-09-08 16:30:30 -04:00
2017-09-18 12:39:17 -04:00
if ( sample_rate = = 0 ) {
2013-08-07 22:22:11 -04:00
/* no frame rate available */
return ;
}
2009-10-14 12:10:01 -04:00
2017-09-18 12:39:17 -04:00
samples = tmnow . tm_hour * ( 60 * 60 * sample_rate ) ;
samples + = tmnow . tm_min * ( 60 * sample_rate ) ;
samples + = tmnow . tm_sec * sample_rate ;
2008-09-10 11:03:30 -04:00
2021-04-28 21:55:37 -04:00
_session - > request_locate ( samples ) ;
2008-09-10 11:03:30 -04:00
/* force displayed area in editor to start no matter
what " follow playhead " setting is .
*/
2009-10-14 12:10:01 -04:00
2008-09-10 11:03:30 -04:00
if ( editor ) {
2017-09-18 12:39:17 -04:00
editor - > center_screen ( samples ) ;
2008-09-10 11:03:30 -04:00
}
}
}
2005-09-25 14:42:24 -04:00
void
ARDOUR_UI : : transport_goto_end ( )
{
2009-12-17 13:24:23 -05:00
if ( _session ) {
2017-09-18 12:39:17 -04:00
samplepos_t const sample = _session - > current_end_sample ( ) ;
_session - > request_locate ( sample ) ;
2005-09-25 14:42:24 -04:00
/* force displayed area in editor to start no matter
what " follow playhead " setting is .
*/
2009-10-14 12:10:01 -04:00
2005-09-25 14:42:24 -04:00
if ( editor ) {
2017-09-18 12:39:17 -04:00
editor - > center_screen ( sample ) ;
2005-09-25 14:42:24 -04:00
}
}
}
void
ARDOUR_UI : : transport_stop ( )
{
2009-12-17 13:24:23 -05:00
if ( ! _session ) {
2005-09-25 14:42:24 -04:00
return ;
}
2009-12-17 13:24:23 -05:00
if ( _session - > is_auditioning ( ) ) {
_session - > cancel_audition ( ) ;
2005-09-25 14:42:24 -04:00
return ;
}
2009-10-14 12:10:01 -04:00
2010-04-20 22:24:38 -04:00
_session - > request_stop ( false , true ) ;
2005-09-25 14:42:24 -04:00
}
2014-07-10 08:14:41 -04:00
/** Check if any tracks are record enabled. If none are, record enable all of them.
* @ return true if track record - enabled status was changed , false otherwise .
2015-09-08 16:30:30 -04:00
*/
2014-07-09 12:07:05 -04:00
bool
ARDOUR_UI : : trx_record_enable_all_tracks ( )
{
if ( ! _session ) {
return false ;
}
boost : : shared_ptr < RouteList > rl = _session - > get_tracks ( ) ;
bool none_record_enabled = true ;
for ( RouteList : : iterator r = rl - > begin ( ) ; r ! = rl - > end ( ) ; + + r ) {
boost : : shared_ptr < Track > t = boost : : dynamic_pointer_cast < Track > ( * r ) ;
assert ( t ) ;
2016-04-08 16:49:47 -04:00
if ( t - > rec_enable_control ( ) - > get_value ( ) ) {
2014-07-09 12:07:05 -04:00
none_record_enabled = false ;
break ;
}
}
if ( none_record_enabled ) {
2016-05-27 16:13:10 -04:00
_session - > set_controls ( route_list_to_control_list ( rl , & Stripable : : rec_enable_control ) , 1.0 , Controllable : : NoGroup ) ;
2015-09-08 16:30:30 -04:00
}
2014-07-09 12:07:05 -04:00
return none_record_enabled ;
}
2005-09-25 14:42:24 -04:00
void
2008-01-10 16:20:59 -05:00
ARDOUR_UI : : transport_record ( bool roll )
2005-09-25 14:42:24 -04:00
{
2009-12-17 13:24:23 -05:00
if ( _session ) {
switch ( _session - > record_status ( ) ) {
2005-09-25 14:42:24 -04:00
case Session : : Disabled :
2009-12-17 13:24:23 -05:00
if ( _session - > ntracks ( ) = = 0 ) {
2019-12-14 17:31:24 -05:00
ArdourMessageDialog msg ( _main_window , _ ( " Please create one or more tracks before trying to record. \n You can do this with the \" Add Track or Bus \" option in the Session menu. " ) ) ;
2006-03-05 14:39:16 -05:00
msg . run ( ) ;
2005-09-25 14:42:24 -04:00
return ;
}
2009-12-17 13:24:23 -05:00
_session - > maybe_enable_record ( ) ;
2008-01-10 16:20:59 -05:00
if ( roll ) {
2022-04-18 11:56:36 -04:00
ActionManager : : get_action ( X_ ( " Region " ) , X_ ( " add-region-cue-marker " ) ) - > set_sensitive ( true ) ;
2008-01-10 16:20:59 -05:00
transport_roll ( ) ;
}
2005-09-25 14:42:24 -04:00
break ;
case Session : : Recording :
2008-01-10 16:20:59 -05:00
if ( roll ) {
2009-12-17 13:24:23 -05:00
_session - > request_stop ( ) ;
2008-01-10 16:20:59 -05:00
} else {
2009-12-17 13:24:23 -05:00
_session - > disable_record ( false , true ) ;
2008-01-10 16:20:59 -05:00
}
break ;
2005-09-25 14:42:24 -04:00
case Session : : Enabled :
2019-12-16 14:06:04 -05:00
if ( roll ) {
transport_roll ( ) ;
} else {
_session - > disable_record ( false , true ) ;
}
2005-09-25 14:42:24 -04:00
}
}
}
2011-06-01 13:00:29 -04:00
void
2005-09-25 14:42:24 -04:00
ARDOUR_UI : : transport_roll ( )
{
2009-12-17 13:24:23 -05:00
if ( ! _session ) {
2005-09-25 14:42:24 -04:00
return ;
}
2009-12-17 13:24:23 -05:00
if ( _session - > is_auditioning ( ) ) {
2009-10-30 14:14:25 -04:00
return ;
}
2010-12-14 15:27:54 -05:00
2009-12-17 13:24:23 -05:00
if ( _session - > config . get_external_sync ( ) ) {
2018-10-05 12:35:13 -04:00
switch ( TransportMasterManager : : instance ( ) . current ( ) - > type ( ) ) {
2013-09-19 17:34:23 -04:00
case Engine :
2009-11-09 15:05:18 -05:00
break ;
default :
/* transport controlled by the master */
return ;
}
2009-10-30 14:14:25 -04:00
}
2005-09-25 14:42:24 -04:00
2009-12-17 13:24:23 -05:00
bool rolling = _session - > transport_rolling ( ) ;
2008-04-11 10:06:50 -04:00
2009-12-17 13:24:23 -05:00
if ( _session - > get_play_loop ( ) ) {
2014-04-17 09:47:06 -04:00
/* If loop playback is not a mode, then we should cancel
it when this action is requested . If it is a mode
we just leave it in place .
2010-04-20 22:24:38 -04:00
*/
2014-04-17 09:47:06 -04:00
if ( ! Config - > get_loop_is_mode ( ) ) {
2019-11-01 16:04:16 -04:00
/* stop loop playback but keep transport state */
_session - > request_play_loop ( false , false ) ;
2015-09-08 16:30:30 -04:00
}
2014-04-17 09:47:06 -04:00
2014-07-03 13:25:35 -04:00
} else if ( _session - > get_play_range ( ) ) {
2010-01-01 17:11:15 -05:00
/* stop playing a range if we currently are */
_session - > request_play_range ( 0 , true ) ;
}
2009-10-30 14:14:25 -04:00
if ( ! rolling ) {
2021-04-12 20:57:52 -04:00
_session - > request_roll ( ) ;
2009-10-30 14:14:25 -04:00
}
}
2012-11-20 14:43:43 -05:00
bool
ARDOUR_UI : : get_smart_mode ( ) const
{
return ( editor - > get_smart_mode ( ) ) ;
}
2009-10-30 14:14:25 -04:00
void
2009-11-08 11:28:21 -05:00
ARDOUR_UI : : toggle_roll ( bool with_abort , bool roll_out_of_bounded_mode )
2009-10-30 14:14:25 -04:00
{
2009-12-17 13:24:23 -05:00
if ( ! _session ) {
2009-10-30 14:14:25 -04:00
return ;
}
2009-12-17 13:24:23 -05:00
if ( _session - > is_auditioning ( ) ) {
_session - > cancel_audition ( ) ;
2009-10-30 14:14:25 -04:00
return ;
}
2010-08-02 17:52:21 -04:00
2009-12-17 13:24:23 -05:00
if ( _session - > config . get_external_sync ( ) ) {
2018-10-05 12:35:13 -04:00
switch ( TransportMasterManager : : instance ( ) . current ( ) - > type ( ) ) {
2013-09-19 17:34:23 -04:00
case Engine :
2009-11-09 15:05:18 -05:00
break ;
default :
/* transport controlled by the master */
return ;
}
2009-10-30 14:14:25 -04:00
}
2009-12-17 13:24:23 -05:00
bool rolling = _session - > transport_rolling ( ) ;
2009-10-30 14:14:25 -04:00
2019-11-02 18:12:28 -04:00
if ( rolling ) {
2015-09-22 13:24:04 -04:00
2019-11-02 18:12:28 -04:00
if ( roll_out_of_bounded_mode ) {
/* drop out of loop/range playback but leave transport rolling */
2015-09-22 13:24:04 -04:00
2019-11-02 18:12:28 -04:00
if ( _session - > get_play_loop ( ) ) {
if ( _session - > actively_recording ( ) ) {
/* actually stop transport because
otherwise the captured data will make
no sense .
*/
_session - > request_play_loop ( false , true ) ;
} else {
_session - > request_play_loop ( false , false ) ;
}
} else if ( _session - > get_play_range ( ) ) {
_session - > request_cancel_play_range ( ) ;
2009-11-08 11:28:21 -05:00
}
2005-09-25 14:42:24 -04:00
2019-11-02 18:12:28 -04:00
} else {
2009-12-17 13:24:23 -05:00
_session - > request_stop ( with_abort , true ) ;
2019-11-02 18:12:28 -04:00
}
2016-07-04 09:41:21 -04:00
2019-11-02 18:12:28 -04:00
} else { /* not rolling */
2016-07-04 09:41:21 -04:00
2019-11-02 18:12:28 -04:00
if ( with_abort ) { /* with_abort == true means the command was intended to stop transport, not start. */
return ;
}
2016-01-12 08:28:54 -05:00
2019-11-02 18:12:28 -04:00
if ( _session - > get_play_loop ( ) & & Config - > get_loop_is_mode ( ) ) {
2022-05-27 20:49:23 -04:00
_session - > request_locate ( _session - > locations ( ) - > auto_loop_location ( ) - > start ( ) . samples ( ) , false , MustRoll ) ;
2019-11-02 18:12:28 -04:00
} else {
if ( UIConfiguration : : instance ( ) . get_follow_edits ( ) ) {
2020-09-26 11:14:59 -04:00
list < TimelineRange > & range = editor - > get_selection ( ) . time ;
if ( range . front ( ) . start ( ) . samples ( ) = = _session - > transport_sample ( ) ) { // if playhead is exactly at the start of a range, we assume it was placed there by follow_edits
2019-11-02 18:12:28 -04:00
_session - > request_play_range ( & range , true ) ;
2020-09-26 11:14:59 -04:00
_session - > set_requested_return_sample ( range . front ( ) . start ( ) . samples ( ) ) ; //force an auto-return here
2019-11-02 18:12:28 -04:00
}
2010-01-01 17:11:15 -05:00
}
2021-04-12 20:57:52 -04:00
_session - > request_roll ( ) ;
2009-10-30 14:14:25 -04:00
}
}
2005-09-25 14:42:24 -04:00
}
void
2009-10-30 14:14:25 -04:00
ARDOUR_UI : : toggle_session_auto_loop ( )
2005-09-25 14:42:24 -04:00
{
2015-12-10 06:46:24 -05:00
if ( ! _session ) {
return ;
}
2012-03-06 17:56:56 -05:00
Location * looploc = _session - > locations ( ) - > auto_loop_location ( ) ;
2015-12-10 06:46:24 -05:00
if ( ! looploc ) {
2011-01-09 18:14:47 -05:00
return ;
}
2011-06-01 13:00:29 -04:00
2011-01-09 18:14:47 -05:00
if ( _session - > get_play_loop ( ) ) {
2014-04-17 09:47:06 -04:00
/* looping enabled, our job is to disable it */
_session - > request_play_loop ( false ) ;
} else {
2011-06-01 13:00:29 -04:00
2014-04-17 09:47:06 -04:00
/* looping not enabled, our job is to enable it.
2011-06-01 13:00:29 -04:00
2014-04-17 09:47:06 -04:00
loop - is - NOT - mode : this action always starts the transport rolling .
loop - IS - mode : this action simply sets the loop play mechanism , but
does not start transport .
*/
if ( Config - > get_loop_is_mode ( ) ) {
_session - > request_play_loop ( true , false ) ;
2011-01-09 18:14:47 -05:00
} else {
2014-04-17 09:47:06 -04:00
_session - > request_play_loop ( true , true ) ;
2011-01-09 18:14:47 -05:00
}
2005-09-25 14:42:24 -04:00
}
2015-09-08 16:30:30 -04:00
2012-03-06 17:56:56 -05:00
//show the loop markers
looploc - > set_hidden ( false , this ) ;
2005-09-25 14:42:24 -04:00
}
void
ARDOUR_UI : : transport_play_selection ( )
{
2009-12-17 13:24:23 -05:00
if ( ! _session ) {
2005-09-25 14:42:24 -04:00
return ;
}
editor - > play_selection ( ) ;
}
2012-11-20 14:43:43 -05:00
void
ARDOUR_UI : : transport_play_preroll ( )
{
if ( ! _session ) {
return ;
}
editor - > play_with_preroll ( ) ;
}
2017-01-18 09:16:05 -05:00
void
ARDOUR_UI : : transport_rec_preroll ( )
{
if ( ! _session ) {
return ;
}
editor - > rec_with_preroll ( ) ;
}
2017-02-13 16:59:51 -05:00
void
ARDOUR_UI : : transport_rec_count_in ( )
{
if ( ! _session ) {
return ;
}
editor - > rec_with_count_in ( ) ;
}
2005-09-25 14:42:24 -04:00
void
2021-05-04 18:56:19 -04:00
ARDOUR_UI : : transport_ffwd_rewind ( bool fwd )
2005-09-25 14:42:24 -04:00
{
2012-04-22 21:13:34 -04:00
if ( ! _session ) {
return ;
}
2021-05-04 18:56:19 -04:00
// incrementally increase speed by semitones
// (keypress auto-repeat is 100ms)
const float maxspeed = Config - > get_shuttle_max_speed ( ) ;
float semitone_ratio = exp2f ( 1.0f / 12.0f ) ;
2021-05-08 23:59:29 -04:00
const float octave_down = powf ( 1.f / semitone_ratio , 12.f ) ;
2021-05-05 01:14:48 -04:00
float transport_speed = _session - > actual_speed ( ) ;
float speed ;
2015-09-08 16:30:30 -04:00
2021-05-05 01:14:48 -04:00
if ( Config - > get_rewind_ffwd_like_tape_decks ( ) ) {
2020-04-22 04:50:43 -04:00
2021-05-04 18:56:19 -04:00
if ( fwd ) {
if ( transport_speed < = 0 ) {
2021-06-18 13:22:59 -04:00
_session - > request_transport_speed ( 1.0 ) ;
2021-05-04 18:56:19 -04:00
_session - > request_roll ( TRS_UI ) ;
2021-05-05 01:14:48 -04:00
return ;
2021-05-04 18:56:19 -04:00
}
} else {
if ( transport_speed > = 0 ) {
2021-06-18 13:22:59 -04:00
_session - > request_transport_speed ( - 1.0 ) ;
2021-05-04 18:56:19 -04:00
_session - > request_roll ( TRS_UI ) ;
2021-05-05 01:14:48 -04:00
return ;
2021-05-04 18:56:19 -04:00
}
}
2020-04-23 11:05:18 -04:00
2021-05-05 01:14:48 -04:00
} else {
2021-05-08 10:16:05 -04:00
if ( fabs ( transport_speed ) < = 0.1 ) {
2021-05-05 01:14:48 -04:00
/* close to zero, maybe flip direction */
2021-05-19 00:59:22 -04:00
if ( fwd ) {
if ( transport_speed < = 0 ) {
2021-06-18 13:22:59 -04:00
_session - > request_transport_speed ( 1.0 ) ;
2021-05-19 00:59:22 -04:00
_session - > request_roll ( TRS_UI ) ;
}
} else {
if ( transport_speed > = 0 ) {
2021-06-18 13:22:59 -04:00
_session - > request_transport_speed ( - 1.0 ) ;
2021-05-19 00:59:22 -04:00
_session - > request_roll ( TRS_UI ) ;
2021-05-05 01:14:48 -04:00
}
}
2020-04-20 19:18:27 -04:00
2021-05-05 01:14:48 -04:00
/* either we've just started, or we're moving as slowly as we
* ever should
*/
return ;
2021-05-04 18:56:19 -04:00
}
2021-05-05 01:14:48 -04:00
if ( fwd ) {
if ( transport_speed < 0.f ) {
2021-05-08 11:13:32 -04:00
if ( fabs ( transport_speed ) < octave_down ) {
2021-05-08 11:43:04 -04:00
/* we need to move the speed back towards zero */
2021-05-08 23:59:29 -04:00
semitone_ratio = powf ( 1.f / semitone_ratio , 4.f ) ;
2021-05-08 11:13:32 -04:00
} else {
2021-05-08 23:59:29 -04:00
semitone_ratio = 1.f / semitone_ratio ;
2021-05-08 11:13:32 -04:00
}
2021-05-08 11:43:04 -04:00
} else {
if ( fabs ( transport_speed ) < octave_down ) {
/* moving very slowly, use 4 semitone steps */
2021-05-08 23:59:29 -04:00
semitone_ratio = powf ( semitone_ratio , 4.f ) ;
2021-05-08 11:43:04 -04:00
}
2021-05-05 01:14:48 -04:00
}
} else {
if ( transport_speed > 0.f ) {
/* we need to move the speed back towards zero */
2021-05-08 11:13:32 -04:00
if ( transport_speed < octave_down ) {
2021-05-08 23:59:29 -04:00
semitone_ratio = powf ( 1.f / semitone_ratio , 4.f ) ;
2021-05-08 11:13:32 -04:00
} else {
2021-05-08 23:59:29 -04:00
semitone_ratio = 1.f / semitone_ratio ;
2021-05-08 11:13:32 -04:00
}
2021-05-08 11:43:04 -04:00
} else {
if ( fabs ( transport_speed ) < octave_down ) {
/* moving very slowly, use 4 semitone steps */
2021-05-08 23:59:29 -04:00
semitone_ratio = powf ( semitone_ratio , 4.f ) ;
2021-05-08 11:43:04 -04:00
}
2021-05-05 01:14:48 -04:00
}
2021-05-04 18:56:19 -04:00
}
2021-05-05 01:14:48 -04:00
}
2021-05-04 18:56:19 -04:00
2021-05-05 01:14:48 -04:00
speed = semitone_ratio * transport_speed ;
2021-05-04 18:56:19 -04:00
speed = std : : max ( - maxspeed , std : : min ( maxspeed , speed ) ) ;
2021-06-18 13:22:59 -04:00
_session - > request_transport_speed ( speed ) ;
2021-05-04 18:56:19 -04:00
_session - > request_roll ( TRS_UI ) ;
2021-05-05 01:14:48 -04:00
2020-04-20 19:18:27 -04:00
}
void
2021-05-04 18:56:19 -04:00
ARDOUR_UI : : transport_rewind ( )
2020-04-20 19:18:27 -04:00
{
2021-05-04 18:56:19 -04:00
transport_ffwd_rewind ( false ) ;
2020-04-20 19:18:27 -04:00
}
void
2021-05-04 18:56:19 -04:00
ARDOUR_UI : : transport_forward ( )
2020-04-20 19:18:27 -04:00
{
2021-05-04 18:56:19 -04:00
transport_ffwd_rewind ( true ) ;
2005-09-25 14:42:24 -04:00
}
void
2016-05-16 07:30:28 -04:00
ARDOUR_UI : : toggle_record_enable ( uint16_t rid )
2005-09-25 14:42:24 -04:00
{
2012-04-22 21:13:34 -04:00
if ( ! _session ) {
2005-09-25 14:42:24 -04:00
return ;
}
2006-07-27 21:08:57 -04:00
boost : : shared_ptr < Route > r ;
2009-10-14 12:10:01 -04:00
2016-05-16 07:30:28 -04:00
if ( ( r = _session - > get_remote_nth_route ( rid ) ) ! = 0 ) {
2006-07-13 23:43:32 -04:00
2016-01-21 11:03:14 -05:00
boost : : shared_ptr < Track > t ;
2005-09-25 14:42:24 -04:00
2016-01-21 11:03:14 -05:00
if ( ( t = boost : : dynamic_pointer_cast < Track > ( r ) ) ! = 0 ) {
2016-04-08 16:49:47 -04:00
t - > rec_enable_control ( ) - > set_value ( ! t - > rec_enable_control ( ) - > get_value ( ) , Controllable : : UseGroup ) ;
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one)
Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now.
Relevant (significant) changes:
- Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...)
- IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why)
- AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output.
- (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise.
- MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here.
- Random cleanups and variable renamings etc. because I have OCD and can't help myself. :)
Known broken: Loading of sessions containing MIDI tracks.
git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
}
2005-09-25 14:42:24 -04:00
}
}
void
ARDOUR_UI : : map_transport_state ( )
{
2009-12-17 13:24:23 -05:00
if ( ! _session ) {
2022-09-19 16:47:59 -04:00
record_mode_selector . set_sensitive ( false ) ;
2019-12-13 10:33:12 -05:00
if ( UIConfiguration : : instance ( ) . get_screen_saver_mode ( ) = = InhibitWhileRecording ) {
inhibit_screensaver ( false ) ;
}
2009-10-30 14:14:25 -04:00
return ;
}
2016-12-19 18:00:14 -05:00
shuttle_box . map_transport_state ( ) ;
2005-09-25 14:42:24 -04:00
2011-04-19 22:48:20 -04:00
float sp = _session - > transport_speed ( ) ;
2009-10-30 14:14:25 -04:00
2011-04-19 22:48:20 -04:00
if ( sp ! = 0.0f ) {
2022-09-19 16:47:59 -04:00
record_mode_selector . set_sensitive ( ! _session - > actively_recording ( ) ) ;
2005-09-25 14:42:24 -04:00
} else {
2022-09-19 16:47:59 -04:00
record_mode_selector . set_sensitive ( true ) ;
2011-04-19 22:48:20 -04:00
update_disk_space ( ) ;
2005-09-25 14:42:24 -04:00
}
2019-08-11 14:37:07 -04:00
if ( UIConfiguration : : instance ( ) . get_screen_saver_mode ( ) = = InhibitWhileRecording ) {
inhibit_screensaver ( _session - > actively_recording ( ) ) ;
}
2005-09-25 14:42:24 -04:00
}
2014-12-25 10:02:00 -05:00
void
ARDOUR_UI : : blink_handler ( bool blink_on )
{
sync_blink ( blink_on ) ;
2017-03-26 15:42:01 -04:00
if ( ! UIConfiguration : : instance ( ) . get_blink_alert_indicators ( ) ) {
blink_on = true ;
}
error_blink ( blink_on ) ;
solo_blink ( blink_on ) ;
2014-12-25 10:02:00 -05:00
audition_blink ( blink_on ) ;
feedback_blink ( blink_on ) ;
}
2005-09-25 14:42:24 -04:00
void
ARDOUR_UI : : update_clocks ( )
{
2014-12-25 10:02:00 -05:00
if ( ! _session ) return ;
2020-03-25 21:19:46 -04:00
if ( editor & & ! editor - > dragging_playhead ( ) & & ! editor - > pending_locate_request ( ) ) {
2020-10-01 12:32:06 -04:00
Clock ( timepos_t ( _session - > audible_sample ( ) ) ) ; /* EMIT_SIGNAL */
2007-01-09 18:24:54 -05:00
}
2005-09-25 14:42:24 -04:00
}
void
ARDOUR_UI : : start_clocking ( )
{
2015-01-02 09:44:54 -05:00
if ( UIConfiguration : : instance ( ) . get_super_rapid_clock_update ( ) ) {
2014-12-25 10:02:00 -05:00
clock_signal_connection = Timers : : fps_connect ( sigc : : mem_fun ( * this , & ARDOUR_UI : : update_clocks ) ) ;
2013-03-03 08:45:32 -05:00
} else {
2014-12-25 10:02:00 -05:00
clock_signal_connection = Timers : : rapid_connect ( sigc : : mem_fun ( * this , & ARDOUR_UI : : update_clocks ) ) ;
2013-03-03 08:45:32 -05:00
}
2005-09-25 14:42:24 -04:00
}
void
ARDOUR_UI : : stop_clocking ( )
{
clock_signal_connection . disconnect ( ) ;
}
2009-10-14 12:10:01 -04:00
2019-09-23 16:49:06 -04:00
void
ARDOUR_UI : : save_state ( const string & name , bool switch_to_it )
2015-01-14 17:54:26 -05:00
{
2019-09-23 16:49:06 -04:00
if ( ! _session | | _session - > deletion_in_progress ( ) ) {
return ;
}
2020-03-24 16:10:26 -04:00
if ( _session - > unnamed ( ) ) {
rename_session ( true ) ;
}
2019-09-23 16:49:06 -04:00
XMLNode * node = new XMLNode ( X_ ( " UI " ) ) ;
2015-01-14 17:54:26 -05:00
2019-09-23 16:49:06 -04:00
WM : : Manager : : instance ( ) . add_state ( * node ) ;
2015-01-14 17:54:26 -05:00
2019-09-23 16:49:06 -04:00
node - > add_child_nocopy ( gui_object_state - > get_state ( ) ) ;
2015-01-14 17:54:26 -05:00
2019-09-23 16:49:06 -04:00
_session - > add_extra_xml ( * node ) ;
2015-09-08 16:30:30 -04:00
2019-09-23 16:49:06 -04:00
if ( export_video_dialog ) {
_session - > add_extra_xml ( export_video_dialog - > get_state ( ) ) ;
2015-01-14 17:54:26 -05:00
}
2019-09-23 16:49:06 -04:00
save_state_canfail ( name , switch_to_it ) ;
2005-09-25 14:42:24 -04:00
}
2009-10-14 12:10:01 -04:00
2005-09-25 14:42:24 -04:00
int
2010-04-20 22:24:38 -04:00
ARDOUR_UI : : save_state_canfail ( string name , bool switch_to_it )
2005-09-25 14:42:24 -04:00
{
2009-12-17 13:24:23 -05:00
if ( _session ) {
2005-09-25 14:42:24 -04:00
int ret ;
2010-04-20 22:24:38 -04:00
if ( ( ret = _session - > save_state ( name , false , switch_to_it ) ) ! = 0 ) {
2005-09-25 14:42:24 -04:00
return ret ;
}
}
2011-05-04 07:32:35 -04:00
2005-09-25 14:42:24 -04:00
save_ardour_state ( ) ; /* XXX cannot fail? yeah, right ... */
return 0 ;
}
void
ARDOUR_UI : : primary_clock_value_changed ( )
{
2009-12-17 13:24:23 -05:00
if ( _session ) {
2020-10-19 14:37:54 -04:00
_session - > request_locate ( primary_clock - > current_time ( ) . samples ( ) ) ;
2005-09-25 14:42:24 -04:00
}
}
2008-01-10 16:20:59 -05:00
void
ARDOUR_UI : : big_clock_value_changed ( )
{
2009-12-17 13:24:23 -05:00
if ( _session ) {
2020-10-19 14:37:54 -04:00
_session - > request_locate ( big_clock - > current_time ( ) . samples ( ) ) ;
2008-01-10 16:20:59 -05:00
}
}
2005-09-25 14:42:24 -04:00
void
ARDOUR_UI : : secondary_clock_value_changed ( )
{
2009-12-17 13:24:23 -05:00
if ( _session ) {
2020-10-19 14:37:54 -04:00
_session - > request_locate ( secondary_clock - > current_time ( ) . samples ( ) ) ;
2005-09-25 14:42:24 -04:00
}
}
2017-08-18 13:53:46 -04:00
void
ARDOUR_UI : : save_template_dialog_response ( int response , SaveTemplateDialog * d )
2015-11-01 15:00:05 -05:00
{
2017-08-18 13:53:46 -04:00
if ( response = = RESPONSE_ACCEPT ) {
2022-05-15 13:52:54 -04:00
const string name = legalize_for_path ( d - > get_template_name ( ) ) ;
2017-08-18 13:53:46 -04:00
const string desc = d - > get_description ( ) ;
2015-11-01 15:00:05 -05:00
2017-08-18 13:53:46 -04:00
int failed = _session - > save_template ( name , desc ) ;
2015-11-01 15:00:05 -05:00
if ( failed = = - 2 ) { /* file already exists. */
2017-08-18 13:53:46 -04:00
bool overwrite = overwrite_file_dialog ( * d ,
2015-11-01 15:00:05 -05:00
_ ( " Confirm Template Overwrite " ) ,
_ ( " A template already exists with that name. Do you want to overwrite it? " ) ) ;
if ( overwrite ) {
2017-08-18 13:53:46 -04:00
_session - > save_template ( name , desc , true ) ;
2015-11-01 15:00:05 -05:00
}
else {
2017-08-18 13:53:46 -04:00
d - > show ( ) ;
return ;
2015-11-01 15:00:05 -05:00
}
}
}
2017-08-18 13:53:46 -04:00
delete d ;
2015-11-01 15:00:05 -05:00
}
2005-09-25 14:42:24 -04:00
void
ARDOUR_UI : : save_template ( )
{
2017-08-19 08:52:38 -04:00
const std : : string desc = SessionMetadata : : Metadata ( ) - > description ( ) ;
SaveTemplateDialog * d = new SaveTemplateDialog ( _session - > name ( ) , desc ) ;
2017-08-18 13:53:46 -04:00
d - > signal_response ( ) . connect ( sigc : : bind ( sigc : : mem_fun ( * this , & ARDOUR_UI : : save_template_dialog_response ) , d ) ) ;
d - > show ( ) ;
2005-09-25 14:42:24 -04:00
}
2017-07-03 06:27:25 -04:00
void ARDOUR_UI : : manage_templates ( )
{
TemplateDialog td ;
td . run ( ) ;
}
2008-09-17 04:44:51 -04:00
void
ARDOUR_UI : : edit_metadata ( )
{
SessionMetadataEditor dialog ;
2009-12-17 13:24:23 -05:00
dialog . set_session ( _session ) ;
2015-01-07 20:56:39 -05:00
dialog . grab_focus ( ) ;
2008-09-17 04:44:51 -04:00
dialog . run ( ) ;
}
void
ARDOUR_UI : : import_metadata ( )
{
SessionMetadataImporter dialog ;
2009-12-17 13:24:23 -05:00
dialog . set_session ( _session ) ;
2008-09-17 04:44:51 -04:00
dialog . run ( ) ;
}
2019-09-23 16:49:06 -04:00
static void _lua_print ( std : : string s ) {
# ifndef NDEBUG
2020-04-18 12:13:32 -04:00
std : : cout < < " LuaTemplate: " < < s < < " \n " ;
2019-09-23 16:49:06 -04:00
# endif
2020-04-18 12:13:32 -04:00
PBD : : info < < " LuaTemplate: " < < s < < endmsg ;
2008-01-18 22:49:52 -05:00
}
2019-09-23 16:49:06 -04:00
std : : map < std : : string , std : : string >
ARDOUR_UI : : route_setup_info ( const std : : string & script_path )
2008-01-18 22:49:52 -05:00
{
2019-09-23 16:49:06 -04:00
std : : map < std : : string , std : : string > rv ;
2009-10-14 12:10:01 -04:00
2019-09-23 16:49:06 -04:00
if ( ! Glib : : file_test ( script_path , Glib : : FILE_TEST_EXISTS | Glib : : FILE_TEST_IS_REGULAR ) ) {
return rv ;
2008-01-18 22:49:52 -05:00
}
2009-10-14 12:10:01 -04:00
2019-09-23 16:49:06 -04:00
LuaState lua ;
lua . Print . connect ( & _lua_print ) ;
lua . sandbox ( true ) ;
2008-01-18 22:49:52 -05:00
2019-09-23 16:49:06 -04:00
lua_State * L = lua . getState ( ) ;
LuaInstance : : register_classes ( L ) ;
LuaBindings : : set_session ( L , _session ) ;
luabridge : : push < PublicEditor * > ( L , & PublicEditor : : instance ( ) ) ;
lua_setglobal ( L , " Editor " ) ;
lua . do_command ( " function ardour () end " ) ;
lua . do_file ( script_path ) ;
try {
luabridge : : LuaRef fn = luabridge : : getGlobal ( L , " route_setup " ) ;
if ( ! fn . isFunction ( ) ) {
return rv ;
}
luabridge : : LuaRef rs = fn ( ) ;
if ( ! rs . isTable ( ) ) {
return rv ;
}
for ( luabridge : : Iterator i ( rs ) ; ! i . isNil ( ) ; + + i ) {
if ( ! i . key ( ) . isString ( ) ) {
continue ;
}
std : : string key = i . key ( ) . tostring ( ) ;
if ( i . value ( ) . isString ( ) | | i . value ( ) . isNumber ( ) | | i . value ( ) . isBoolean ( ) ) {
rv [ key ] = i . value ( ) . tostring ( ) ;
}
}
} catch ( luabridge : : LuaException const & e ) {
2020-04-18 12:13:32 -04:00
# ifndef NDEBUG
2019-09-23 16:49:06 -04:00
cerr < < " LuaException: " < < e . what ( ) < < endl ;
2020-04-18 12:13:32 -04:00
# endif
PBD : : warning < < " LuaException: " < < e . what ( ) < < endmsg ;
2019-09-23 16:49:06 -04:00
} catch ( . . . ) { }
return rv ;
2008-01-18 22:49:52 -05:00
}
2009-08-08 18:36:32 -04:00
void
2019-09-23 16:49:06 -04:00
ARDOUR_UI : : meta_route_setup ( const std : : string & script_path )
2009-08-08 18:36:32 -04:00
{
2019-09-23 16:49:06 -04:00
if ( ! Glib : : file_test ( script_path , Glib : : FILE_TEST_EXISTS | Glib : : FILE_TEST_IS_REGULAR ) ) {
2016-09-29 13:05:38 -04:00
return ;
}
2019-09-23 16:49:06 -04:00
assert ( add_route_dialog ) ;
2016-09-29 13:05:38 -04:00
2019-09-23 16:49:06 -04:00
int count ;
if ( ( count = add_route_dialog - > count ( ) ) < = 0 ) {
return ;
}
2016-09-29 13:05:38 -04:00
2019-09-23 16:49:06 -04:00
LuaState lua ;
lua . Print . connect ( & _lua_print ) ;
lua . sandbox ( true ) ;
2015-09-15 08:42:43 -04:00
2019-09-23 16:49:06 -04:00
lua_State * L = lua . getState ( ) ;
LuaInstance : : register_classes ( L ) ;
LuaBindings : : set_session ( L , _session ) ;
luabridge : : push < PublicEditor * > ( L , & PublicEditor : : instance ( ) ) ;
lua_setglobal ( L , " Editor " ) ;
2015-09-15 08:42:43 -04:00
2019-09-23 16:49:06 -04:00
lua . do_command ( " function ardour () end " ) ;
lua . do_file ( script_path ) ;
2015-09-08 16:30:30 -04:00
2019-09-23 16:49:06 -04:00
luabridge : : LuaRef args ( luabridge : : newTable ( L ) ) ;
2016-05-16 07:30:28 -04:00
2019-09-23 16:49:06 -04:00
args [ " name " ] = add_route_dialog - > name_template ( ) ;
args [ " insert_at " ] = translate_order ( add_route_dialog - > insert_at ( ) ) ;
args [ " group " ] = add_route_dialog - > route_group ( ) ;
args [ " strict_io " ] = add_route_dialog - > use_strict_io ( ) ;
args [ " instrument " ] = add_route_dialog - > requested_instrument ( ) ;
args [ " track_mode " ] = add_route_dialog - > mode ( ) ;
args [ " channels " ] = add_route_dialog - > channel_count ( ) ;
args [ " how_many " ] = count ;
2015-09-08 16:30:30 -04:00
2019-09-23 16:49:06 -04:00
try {
luabridge : : LuaRef fn = luabridge : : getGlobal ( L , " factory " ) ;
if ( fn . isFunction ( ) ) {
fn ( args ) ( ) ;
2013-10-23 10:27:13 -04:00
}
2019-09-23 16:49:06 -04:00
} catch ( luabridge : : LuaException const & e ) {
2020-04-18 12:13:32 -04:00
# ifndef NDEBUG
2019-09-23 16:49:06 -04:00
cerr < < " LuaException: " < < e . what ( ) < < endl ;
2020-04-18 12:13:32 -04:00
# endif
PBD : : warning < < " LuaException: " < < e . what ( ) < < endmsg ;
2019-09-23 16:49:06 -04:00
} catch ( . . . ) {
display_insufficient_ports_message ( ) ;
2013-10-23 10:27:13 -04:00
}
}
2015-11-13 16:14:42 -05:00
void
2019-09-23 16:49:06 -04:00
ARDOUR_UI : : meta_session_setup ( const std : : string & script_path )
2015-11-13 16:14:42 -05:00
{
2019-09-23 16:49:06 -04:00
if ( ! Glib : : file_test ( script_path , Glib : : FILE_TEST_EXISTS | Glib : : FILE_TEST_IS_REGULAR ) ) {
2015-11-14 16:02:05 -05:00
return ;
2015-11-13 16:14:42 -05:00
}
2015-11-14 16:02:05 -05:00
2019-09-23 16:49:06 -04:00
LuaState lua ;
lua . Print . connect ( & _lua_print ) ;
2022-04-20 17:42:11 -04:00
lua . sandbox ( false ) ;
2015-11-13 16:14:42 -05:00
2019-09-23 16:49:06 -04:00
lua_State * L = lua . getState ( ) ;
LuaInstance : : register_classes ( L ) ;
LuaBindings : : set_session ( L , _session ) ;
luabridge : : push < PublicEditor * > ( L , & PublicEditor : : instance ( ) ) ;
lua_setglobal ( L , " Editor " ) ;
2005-09-25 14:42:24 -04:00
2019-09-23 16:49:06 -04:00
lua . do_command ( " function ardour () end " ) ;
lua . do_file ( script_path ) ;
2005-09-25 14:42:24 -04:00
2019-09-23 16:49:06 -04:00
try {
luabridge : : LuaRef fn = luabridge : : getGlobal ( L , " factory " ) ;
if ( fn . isFunction ( ) ) {
fn ( ) ( ) ;
}
} catch ( luabridge : : LuaException const & e ) {
2020-04-18 12:13:32 -04:00
# ifndef NDEBUG
2019-09-23 16:49:06 -04:00
cerr < < " LuaException: " < < e . what ( ) < < endl ;
2020-04-18 12:13:32 -04:00
# endif
PBD : : warning < < " LuaException: " < < e . what ( ) < < endmsg ;
2019-09-23 16:49:06 -04:00
} catch ( . . . ) {
display_insufficient_ports_message ( ) ;
2005-09-25 14:42:24 -04:00
}
2016-06-12 14:53:55 -04:00
}
void
2020-01-30 17:35:37 -05:00
ARDOUR_UI : : display_cleanup_results ( ARDOUR : : CleanupReport const & rep , const gchar * list_title , const bool msg_delete )
2016-06-12 14:53:55 -04:00
{
2019-09-23 16:49:06 -04:00
size_t removed ;
2006-08-24 03:37:17 -04:00
2019-09-23 16:49:06 -04:00
removed = rep . paths . size ( ) ;
2005-09-25 14:42:24 -04:00
2019-09-23 16:49:06 -04:00
if ( removed = = 0 ) {
2019-12-14 17:31:24 -05:00
ArdourMessageDialog msgd ( _main_window ,
_ ( " No files were ready for clean-up " ) ,
true ,
Gtk : : MESSAGE_INFO ,
Gtk : : BUTTONS_OK ) ;
2019-09-23 16:49:06 -04:00
msgd . set_title ( _ ( " Clean-up " ) ) ;
msgd . set_secondary_text ( _ ( " If this seems surprising, \n \
check for any existing snapshots . \ n \
These may still include regions that \ n \
require some unused files to continue to exist . " ));
2017-08-17 14:24:49 -04:00
2019-09-23 16:49:06 -04:00
msgd . run ( ) ;
2005-09-25 14:42:24 -04:00
return ;
}
2019-09-23 16:49:06 -04:00
ArdourDialog results ( _ ( " Clean-up " ) , true , false ) ;
2009-10-14 12:10:01 -04:00
2019-09-23 16:49:06 -04:00
struct CleanupResultsModelColumns : public Gtk : : TreeModel : : ColumnRecord {
CleanupResultsModelColumns ( ) {
add ( visible_name ) ;
add ( fullpath ) ;
2013-04-01 20:45:57 -04:00
}
2019-09-23 16:49:06 -04:00
Gtk : : TreeModelColumn < std : : string > visible_name ;
Gtk : : TreeModelColumn < std : : string > fullpath ;
} ;
2009-03-02 13:08:15 -05:00
2005-09-25 14:42:24 -04:00
2019-09-23 16:49:06 -04:00
CleanupResultsModelColumns results_columns ;
Glib : : RefPtr < Gtk : : ListStore > results_model ;
Gtk : : TreeView results_display ;
2005-09-25 14:42:24 -04:00
2019-09-23 16:49:06 -04:00
results_model = ListStore : : create ( results_columns ) ;
results_display . set_model ( results_model ) ;
results_display . append_column ( list_title , results_columns . visible_name ) ;
2009-10-14 12:10:01 -04:00
2019-09-23 16:49:06 -04:00
results_display . set_name ( " CleanupResultsList " ) ;
results_display . set_headers_visible ( true ) ;
results_display . set_headers_clickable ( false ) ;
results_display . set_reorderable ( false ) ;
2016-11-25 12:07:59 -05:00
2019-09-23 16:49:06 -04:00
Gtk : : ScrolledWindow list_scroller ;
Gtk : : Label txt ;
Gtk : : VBox dvbox ;
Gtk : : HBox dhbox ; // the hbox for the image and text
Gtk : : HBox ddhbox ; // the hbox we eventually pack into the dialog's vbox
Gtk : : Image * dimage = manage ( new Gtk : : Image ( Stock : : DIALOG_INFO , Gtk : : ICON_SIZE_DIALOG ) ) ;
2022-01-26 18:04:44 -05:00
dimage - > set_alignment ( ALIGN_START , ALIGN_START ) ;
2005-09-25 14:42:24 -04:00
2019-09-23 16:49:06 -04:00
const string dead_directory = _session - > session_directory ( ) . dead_path ( ) ;
2013-03-12 17:00:09 -04:00
2019-09-23 16:49:06 -04:00
/* subst:
% 1 - number of files removed
% 2 - location of " dead "
% 3 - size of files affected
% 4 - prefix for " bytes " to produce sensible results ( e . g . mega , kilo , giga )
*/
2013-03-12 17:00:09 -04:00
2019-09-23 16:49:06 -04:00
const char * bprefix ;
double space_adjusted = 0 ;
if ( rep . space < 1000 ) {
bprefix = X_ ( " " ) ;
space_adjusted = rep . space ;
} else if ( rep . space < 1000000 ) {
bprefix = _ ( " kilo " ) ;
space_adjusted = floorf ( ( float ) rep . space / 1000.0 ) ;
} else if ( rep . space < 1000000 * 1000 ) {
bprefix = _ ( " mega " ) ;
space_adjusted = floorf ( ( float ) rep . space / ( 1000.0 * 1000.0 ) ) ;
} else {
bprefix = _ ( " giga " ) ;
space_adjusted = floorf ( ( float ) rep . space / ( 1000.0 * 1000 * 1000.0 ) ) ;
2013-03-12 17:00:09 -04:00
}
2019-09-23 16:49:06 -04:00
if ( msg_delete ) {
txt . set_markup ( string_compose ( P_ ( " \
The following file was deleted from % 2 , \ n \
releasing % 3 % 4 bytes of disk space " , " \
The following % 1 files were deleted from % 2 , \ n \
releasing % 3 % 4 bytes of disk space " , removed),
removed , Gtkmm2ext : : markup_escape_text ( dead_directory ) , space_adjusted , bprefix , PROGRAM_NAME ) ) ;
} else {
txt . set_markup ( string_compose ( P_ ( " \
The following file was not in use and \ n \
has been moved to : % 2 \ n \ n \
After a restart of % 5 \ n \ n \
< span face = \ " mono \" >Session -> Clean-up -> Flush Wastebasket</span> \n \n \
will release an additional % 3 % 4 bytes of disk space . \ n " , " \
The following % 1 files were not in use and \ n \
have been moved to : % 2 \ n \ n \
After a restart of % 5 \ n \ n \
< span face = \ " mono \" >Session -> Clean-up -> Flush Wastebasket</span> \n \n \
will release an additional % 3 % 4 bytes of disk space . \ n " , removed),
removed , Gtkmm2ext : : markup_escape_text ( dead_directory ) , space_adjusted , bprefix , PROGRAM_NAME ) ) ;
2013-03-12 17:00:09 -04:00
}
2019-09-23 16:49:06 -04:00
dhbox . pack_start ( * dimage , true , false , 5 ) ;
dhbox . pack_start ( txt , true , false , 5 ) ;
2013-03-12 17:00:09 -04:00
2020-01-30 17:35:37 -05:00
for ( vector < string > : : const_iterator i = rep . paths . begin ( ) ; i ! = rep . paths . end ( ) ; + + i ) {
2019-09-23 16:49:06 -04:00
TreeModel : : Row row = * ( results_model - > append ( ) ) ;
row [ results_columns . visible_name ] = * i ;
row [ results_columns . fullpath ] = * i ;
}
2013-03-12 17:00:09 -04:00
2019-09-23 16:49:06 -04:00
list_scroller . add ( results_display ) ;
list_scroller . set_size_request ( - 1 , 150 ) ;
list_scroller . set_policy ( Gtk : : POLICY_NEVER , Gtk : : POLICY_AUTOMATIC ) ;
2013-03-12 17:00:09 -04:00
2019-09-23 16:49:06 -04:00
dvbox . pack_start ( dhbox , true , false , 5 ) ;
dvbox . pack_start ( list_scroller , true , false , 5 ) ;
ddhbox . pack_start ( dvbox , true , false , 5 ) ;
2013-03-12 17:00:09 -04:00
2019-09-23 16:49:06 -04:00
results . get_vbox ( ) - > pack_start ( ddhbox , true , false , 5 ) ;
results . add_button ( Stock : : CLOSE , RESPONSE_CLOSE ) ;
results . set_default_response ( RESPONSE_CLOSE ) ;
results . set_position ( Gtk : : WIN_POS_MOUSE ) ;
2013-03-12 17:00:09 -04:00
2019-09-23 16:49:06 -04:00
results_display . show ( ) ;
list_scroller . show ( ) ;
txt . show ( ) ;
dvbox . show ( ) ;
dhbox . show ( ) ;
ddhbox . show ( ) ;
dimage - > show ( ) ;
2013-03-28 08:41:36 -04:00
2019-09-23 16:49:06 -04:00
//results.get_vbox()->show();
results . set_resizable ( false ) ;
results . run ( ) ;
2013-06-07 14:12:39 -04:00
2013-03-12 17:00:09 -04:00
}
void
2019-09-23 16:49:06 -04:00
ARDOUR_UI : : cleanup ( )
2013-03-12 17:00:09 -04:00
{
2019-09-23 16:49:06 -04:00
if ( _session = = 0 ) {
/* shouldn't happen: menu item is insensitive */
2013-03-12 17:00:09 -04:00
return ;
}
2019-12-14 17:31:24 -05:00
ArdourMessageDialog checker ( _ ( " Are you sure you want to clean-up? " ) ,
true ,
Gtk : : MESSAGE_QUESTION ,
Gtk : : BUTTONS_NONE ) ;
2013-05-04 22:02:05 -04:00
2019-09-23 16:49:06 -04:00
checker . set_title ( _ ( " Clean-up " ) ) ;
2013-03-12 17:00:09 -04:00
2019-09-23 16:49:06 -04:00
checker . set_secondary_text ( _ ( " Clean-up is a destructive operation. \n \
ALL undo / redo information will be lost if you clean - up . \ n \
Clean - up will move all unused files to a \ " dead \" location. " ) ) ;
2013-06-17 03:46:01 -04:00
2019-09-23 16:49:06 -04:00
checker . add_button ( Stock : : CANCEL , RESPONSE_CANCEL ) ;
checker . add_button ( _ ( " Clean-up " ) , RESPONSE_ACCEPT ) ;
checker . set_default_response ( RESPONSE_CANCEL ) ;
2013-06-17 03:46:01 -04:00
2019-09-23 16:49:06 -04:00
checker . set_name ( _ ( " CleanupDialog " ) ) ;
checker . set_wmclass ( X_ ( " ardour_cleanup " ) , PROGRAM_NAME ) ;
checker . set_position ( Gtk : : WIN_POS_MOUSE ) ;
2013-03-12 17:00:09 -04:00
2019-09-23 16:49:06 -04:00
switch ( checker . run ( ) ) {
case RESPONSE_ACCEPT :
break ;
default :
2013-03-12 17:00:09 -04:00
return ;
}
2019-09-23 16:49:06 -04:00
checker . hide ( ) ;
2013-03-12 17:00:09 -04:00
2019-09-23 16:49:06 -04:00
ARDOUR : : CleanupReport rep ;
2015-09-20 12:37:39 -04:00
2019-09-23 16:49:06 -04:00
editor - > prepare_for_cleanup ( ) ;
2015-09-20 12:37:39 -04:00
2019-09-23 16:49:06 -04:00
/* do not allow flush until a session is reloaded */
ActionManager : : get_action ( X_ ( " Main " ) , X_ ( " FlushWastebasket " ) ) - > set_sensitive ( false ) ;
2013-03-12 17:00:09 -04:00
2019-09-23 16:49:06 -04:00
if ( _session - > cleanup_sources ( rep ) ) {
editor - > finish_cleanup ( ) ;
return ;
2013-03-12 17:00:09 -04:00
}
2019-09-23 16:49:06 -04:00
editor - > finish_cleanup ( ) ;
2013-03-12 17:00:09 -04:00
2019-09-23 16:49:06 -04:00
display_cleanup_results ( rep , _ ( " Cleaned Files " ) , false ) ;
}
2015-09-20 12:37:39 -04:00
2019-09-23 16:49:06 -04:00
void
ARDOUR_UI : : flush_trash ( )
{
if ( _session = = 0 ) {
/* shouldn't happen: menu item is insensitive */
return ;
}
2015-09-20 12:37:39 -04:00
2019-09-23 16:49:06 -04:00
ARDOUR : : CleanupReport rep ;
2015-09-20 12:37:39 -04:00
2019-09-23 16:49:06 -04:00
if ( _session - > cleanup_trash_sources ( rep ) ) {
return ;
}
2015-09-20 12:37:39 -04:00
2019-09-23 16:49:06 -04:00
display_cleanup_results ( rep , _ ( " deleted file " ) , true ) ;
}
2015-09-20 12:37:39 -04:00
2019-09-23 16:49:06 -04:00
void
ARDOUR_UI : : cleanup_peakfiles ( )
{
if ( _session = = 0 ) {
/* shouldn't happen: menu item is insensitive */
return ;
}
2015-09-20 12:37:39 -04:00
2019-09-23 16:49:06 -04:00
if ( ! _session - > can_cleanup_peakfiles ( ) ) {
return ;
}
2013-04-02 12:06:02 -04:00
2019-09-23 16:49:06 -04:00
// get all region-views in this session
RegionSelection rs ;
TrackViewList empty ;
empty . clear ( ) ;
2020-10-19 14:37:54 -04:00
editor - > get_regions_after ( rs , timepos_t ( ) , empty ) ;
2019-09-23 16:49:06 -04:00
std : : list < RegionView * > views = rs . by_layer ( ) ;
2013-04-02 12:06:02 -04:00
2019-09-23 16:49:06 -04:00
// remove displayed audio-region-views waveforms
for ( list < RegionView * > : : iterator i = views . begin ( ) ; i ! = views . end ( ) ; + + i ) {
AudioRegionView * arv = dynamic_cast < AudioRegionView * > ( * i ) ;
if ( ! arv ) { continue ; }
arv - > delete_waves ( ) ;
2013-03-12 17:00:09 -04:00
}
2019-09-23 16:49:06 -04:00
// cleanup peak files:
// - stop pending peakfile threads
// - close peakfiles if any
// - remove peak dir in session
// - setup peakfiles (background thread)
_session - > cleanup_peakfiles ( ) ;
2013-03-29 04:46:29 -04:00
2020-12-21 15:13:13 -05:00
ArdourWaveView : : WaveView : : clear_cache ( ) ;
2019-09-23 16:49:06 -04:00
// re-add waves to ARV
for ( list < RegionView * > : : iterator i = views . begin ( ) ; i ! = views . end ( ) ; + + i ) {
AudioRegionView * arv = dynamic_cast < AudioRegionView * > ( * i ) ;
if ( ! arv ) { continue ; }
arv - > create_waves ( ) ;
2013-03-12 17:00:09 -04:00
}
}
2019-09-23 16:49:06 -04:00
PresentationInfo : : order_t
ARDOUR_UI : : translate_order ( RouteDialogs : : InsertAt place )
2015-02-27 17:17:26 -05:00
{
2019-09-23 16:49:06 -04:00
if ( editor - > get_selection ( ) . tracks . empty ( ) ) {
return place = = RouteDialogs : : First ? 0 : PresentationInfo : : max_order ;
2015-02-27 17:17:26 -05:00
}
2019-09-23 16:49:06 -04:00
PresentationInfo : : order_t order_hint = PresentationInfo : : max_order ;
2016-07-13 16:38:08 -04:00
2019-09-23 16:49:06 -04:00
/*
we want the new routes to have their order keys set starting from
the highest order key in the selection + 1 ( if available ) .
*/
if ( place = = RouteDialogs : : AfterSelection ) {
RouteTimeAxisView * rtav = dynamic_cast < RouteTimeAxisView * > ( editor - > get_selection ( ) . tracks . back ( ) ) ;
if ( rtav ) {
order_hint = rtav - > route ( ) - > presentation_info ( ) . order ( ) ;
order_hint + + ;
}
} else if ( place = = RouteDialogs : : BeforeSelection ) {
RouteTimeAxisView * rtav = dynamic_cast < RouteTimeAxisView * > ( editor - > get_selection ( ) . tracks . front ( ) ) ;
if ( rtav ) {
order_hint = rtav - > route ( ) - > presentation_info ( ) . order ( ) ;
}
} else if ( place = = RouteDialogs : : First ) {
order_hint = 0 ;
2016-07-13 16:38:08 -04:00
} else {
2019-09-23 16:49:06 -04:00
/* leave order_hint at max_order */
2016-07-13 16:38:08 -04:00
}
2019-09-23 16:49:06 -04:00
return order_hint ;
2016-07-13 16:38:08 -04:00
}
2019-09-23 16:49:06 -04:00
void
ARDOUR_UI : : start_duplicate_routes ( )
2005-09-25 14:42:24 -04:00
{
2019-09-23 16:49:06 -04:00
if ( ! duplicate_routes_dialog ) {
duplicate_routes_dialog = new DuplicateRouteDialog ;
2005-09-25 14:42:24 -04:00
}
2019-09-23 16:49:06 -04:00
if ( duplicate_routes_dialog - > restart ( _session ) ) {
return ;
2005-09-25 14:42:24 -04:00
}
2019-09-23 16:49:06 -04:00
duplicate_routes_dialog - > present ( ) ;
2005-09-25 14:42:24 -04:00
}
2019-09-23 16:49:06 -04:00
void
ARDOUR_UI : : add_route ( )
2015-07-09 19:22:06 -04:00
{
2020-03-17 17:30:11 -04:00
if ( ! _session | | ! _session - > writable ( ) | | _session - > actively_recording ( ) ) {
return ;
2015-07-09 19:22:06 -04:00
}
2020-03-17 17:30:11 -04:00
if ( ! add_route_dialog . get ( false ) ) {
add_route_dialog - > signal_response ( ) . connect ( sigc : : mem_fun ( * this , & ARDOUR_UI : : add_route_dialog_response ) ) ;
2015-07-09 19:22:06 -04:00
}
2022-01-26 15:21:06 -05:00
if ( add_route_dialog - > get_visible ( ) ) {
2019-09-23 16:49:06 -04:00
/* we're already doing this */
return ;
2015-07-09 19:22:06 -04:00
}
2019-09-23 16:49:06 -04:00
add_route_dialog - > set_position ( WIN_POS_MOUSE ) ;
add_route_dialog - > present ( ) ;
2015-07-09 19:22:06 -04:00
}
2019-09-23 16:49:06 -04:00
void
ARDOUR_UI : : add_route_dialog_response ( int r )
2005-09-25 14:42:24 -04:00
{
2019-09-23 16:49:06 -04:00
if ( ! _session ) {
warning < < _ ( " You cannot add tracks or busses without a session already loaded. " ) < < endmsg ;
return ;
2005-09-25 14:42:24 -04:00
}
2011-06-01 13:00:29 -04:00
2019-09-23 16:49:06 -04:00
if ( ! AudioEngine : : instance ( ) - > running ( ) ) {
switch ( r ) {
case AddRouteDialog : : Add :
case AddRouteDialog : : AddAndClose :
break ;
default :
return ;
2008-12-12 09:43:24 -05:00
}
2019-09-23 16:49:06 -04:00
add_route_dialog - > ArdourDialog : : on_response ( r ) ;
ARDOUR_UI_UTILS : : engine_is_running ( ) ;
return ;
2008-12-12 09:43:24 -05:00
}
2005-09-25 14:42:24 -04:00
2019-09-23 16:49:06 -04:00
int count ;
2009-10-14 12:10:01 -04:00
2019-09-23 16:49:06 -04:00
switch ( r ) {
case AddRouteDialog : : Add :
add_route_dialog - > reset_name_edited ( ) ;
break ;
case AddRouteDialog : : AddAndClose :
add_route_dialog - > ArdourDialog : : on_response ( r ) ;
break ;
default :
add_route_dialog - > ArdourDialog : : on_response ( r ) ;
return ;
2005-09-25 14:42:24 -04:00
}
2011-03-03 22:10:48 -05:00
2019-09-23 16:49:06 -04:00
std : : string template_path = add_route_dialog - > get_template_path ( ) ;
if ( ! template_path . empty ( ) & & template_path . substr ( 0 , 11 ) = = " urn:ardour: " ) {
meta_route_setup ( template_path . substr ( 11 ) ) ;
return ;
}
2005-09-25 14:42:24 -04:00
2019-09-23 16:49:06 -04:00
if ( ( count = add_route_dialog - > count ( ) ) < = 0 ) {
return ;
2015-02-06 18:56:34 -05:00
}
2005-09-25 14:42:24 -04:00
2019-09-23 16:49:06 -04:00
PresentationInfo : : order_t order = translate_order ( add_route_dialog - > insert_at ( ) ) ;
const string name_template = add_route_dialog - > name_template ( ) ;
DisplaySuspender ds ;
2005-09-25 14:42:24 -04:00
2019-09-23 16:49:06 -04:00
if ( ! template_path . empty ( ) ) {
if ( add_route_dialog - > name_template_is_default ( ) ) {
_session - > new_route_from_template ( count , order , template_path , string ( ) ) ;
} else {
_session - > new_route_from_template ( count , order , template_path , name_template ) ;
}
2008-12-12 09:43:24 -05:00
return ;
}
2019-09-23 16:49:06 -04:00
ChanCount input_chan = add_route_dialog - > channels ( ) ;
ChanCount output_chan ;
PluginInfoPtr instrument = add_route_dialog - > requested_instrument ( ) ;
RouteGroup * route_group = add_route_dialog - > route_group ( ) ;
AutoConnectOption oac = Config - > get_output_auto_connect ( ) ;
bool strict_io = add_route_dialog - > use_strict_io ( ) ;
2022-03-18 19:36:06 -04:00
bool trigger_visibility = add_route_dialog - > show_on_cue_page ( ) ;
2008-09-10 11:03:30 -04:00
2019-09-23 16:49:06 -04:00
if ( oac & AutoConnectMaster ) {
output_chan . set ( DataType : : AUDIO , ( _session - > master_out ( ) ? _session - > master_out ( ) - > n_inputs ( ) . n_audio ( ) : input_chan . n_audio ( ) ) ) ;
output_chan . set ( DataType : : MIDI , 0 ) ;
} else {
output_chan = input_chan ;
2008-02-16 17:43:18 -05:00
}
2019-09-23 16:49:06 -04:00
/* XXX do something with name template */
Session : : ProcessorChangeBlocker pcb ( _session ) ;
switch ( add_route_dialog - > type_wanted ( ) ) {
case AddRouteDialog : : AudioTrack :
2022-01-14 18:06:38 -05:00
session_add_audio_route ( true , input_chan . n_audio ( ) , output_chan . n_audio ( ) , add_route_dialog - > mode ( ) , route_group , count , name_template , strict_io , order , trigger_visibility ) ;
2019-09-23 16:49:06 -04:00
break ;
case AddRouteDialog : : AudioBus :
2021-10-08 15:38:39 -04:00
session_add_audio_route ( false , input_chan . n_audio ( ) , output_chan . n_audio ( ) , ARDOUR : : Normal , route_group , count , name_template , strict_io , order , false ) ;
2019-09-23 16:49:06 -04:00
break ;
2020-03-19 11:03:28 -04:00
case AddRouteDialog : : MidiTrack :
2022-01-14 18:06:38 -05:00
session_add_midi_route ( true , route_group , count , name_template , strict_io , instrument , 0 , order , trigger_visibility ) ;
2020-03-19 11:03:28 -04:00
break ;
2019-09-23 16:49:06 -04:00
case AddRouteDialog : : MidiBus :
2021-07-17 18:25:47 -04:00
session_add_midi_route ( false , route_group , count , name_template , strict_io , instrument , 0 , order , false ) ;
2019-09-23 16:49:06 -04:00
break ;
case AddRouteDialog : : VCAMaster :
_session - > vca_manager ( ) . create_vca ( count , name_template ) ;
break ;
case AddRouteDialog : : FoldbackBus :
session_add_foldback_bus ( input_chan . n_audio ( ) , count , name_template ) ;
ActionManager : : get_toggle_action ( X_ ( " Mixer " ) , X_ ( " ToggleFoldbackStrip " ) ) - > set_active ( true ) ;
break ;
2008-02-16 17:43:18 -05:00
}
}
2005-09-25 14:42:24 -04:00
void
ARDOUR_UI : : disk_overrun_handler ( )
{
2009-12-11 18:29:48 -05:00
ENSURE_GUI_THREAD ( * this , & ARDOUR_UI : : disk_overrun_handler )
2005-09-25 14:42:24 -04:00
2007-03-18 02:07:08 -04:00
if ( ! have_disk_speed_dialog_displayed ) {
have_disk_speed_dialog_displayed = true ;
2019-12-14 17:31:24 -05:00
ArdourMessageDialog * msg = new ArdourMessageDialog ( _main_window , string_compose ( _ ( " \
2005-09-25 14:42:24 -04:00
The disk system on your computer \ n \
2010-08-16 20:28:20 -04:00
was not able to keep up with % 1. \ n \
2005-09-25 14:42:24 -04:00
\ n \
Specifically , it failed to write data to disk \ n \
2010-08-16 20:28:20 -04:00
quickly enough to keep up with recording . \ n " ), PROGRAM_NAME));
2009-12-11 18:29:48 -05:00
msg - > signal_response ( ) . connect ( sigc : : bind ( sigc : : mem_fun ( * this , & ARDOUR_UI : : disk_speed_dialog_gone ) , msg ) ) ;
2007-07-06 17:54:30 -04:00
msg - > show ( ) ;
2005-09-25 14:42:24 -04:00
}
}
2014-02-25 06:56:20 -05:00
void
ARDOUR_UI : : gui_idle_handler ( )
{
int timeout = 30 ;
2014-02-27 17:41:48 -05:00
/* due to idle calls, gtk_events_pending() may always return true */
2014-02-25 06:56:20 -05:00
while ( gtk_events_pending ( ) & & - - timeout ) {
gtk_main_iteration ( ) ;
}
}
2005-09-25 14:42:24 -04:00
void
ARDOUR_UI : : disk_underrun_handler ( )
{
2009-12-11 18:29:48 -05:00
ENSURE_GUI_THREAD ( * this , & ARDOUR_UI : : disk_underrun_handler )
2005-09-25 14:42:24 -04:00
2007-03-18 02:07:08 -04:00
if ( ! have_disk_speed_dialog_displayed ) {
have_disk_speed_dialog_displayed = true ;
2019-12-14 17:31:24 -05:00
ArdourMessageDialog * msg = new ArdourMessageDialog (
2015-07-07 22:12:21 -04:00
_main_window , string_compose ( _ ( " The disk system on your computer \n \
2010-08-16 20:28:20 -04:00
was not able to keep up with % 1. \ n \
2005-09-25 14:42:24 -04:00
\ n \
Specifically , it failed to read data from disk \ n \
2010-08-16 20:28:20 -04:00
quickly enough to keep up with playback . \ n " ), PROGRAM_NAME));
2009-12-11 18:29:48 -05:00
msg - > signal_response ( ) . connect ( sigc : : bind ( sigc : : mem_fun ( * this , & ARDOUR_UI : : disk_speed_dialog_gone ) , msg ) ) ;
2007-07-06 17:54:30 -04:00
msg - > show ( ) ;
2009-10-14 12:10:01 -04:00
}
2005-09-25 14:42:24 -04:00
}
void
2009-07-21 11:55:17 -04:00
ARDOUR_UI : : disk_speed_dialog_gone ( int /*ignored_response*/ , MessageDialog * msg )
2005-09-25 14:42:24 -04:00
{
2007-03-18 02:07:08 -04:00
have_disk_speed_dialog_displayed = false ;
delete msg ;
2005-09-25 14:42:24 -04:00
}
2008-04-11 10:06:50 -04:00
void
ARDOUR_UI : : session_dialog ( std : : string msg )
{
2009-12-11 18:29:48 -05:00
ENSURE_GUI_THREAD ( * this , & ARDOUR_UI : : session_dialog , msg )
2019-12-14 17:31:24 -05:00
ArdourMessageDialog d ( msg , false , MESSAGE_INFO , BUTTONS_OK , true ) ;
d . run ( ) ;
2009-10-14 12:10:01 -04:00
}
2008-04-11 10:06:50 -04:00
2005-09-25 14:42:24 -04:00
int
ARDOUR_UI : : pending_state_dialog ( )
{
2013-07-31 05:38:32 -04:00
HBox * hbox = manage ( new HBox ( ) ) ;
Image * image = manage ( new Image ( Stock : : DIALOG_QUESTION , ICON_SIZE_DIALOG ) ) ;
2008-01-10 17:22:29 -05:00
ArdourDialog dialog ( _ ( " Crash Recovery " ) , true ) ;
2012-04-22 21:02:33 -04:00
Label message ( string_compose ( _ ( " \
2020-01-28 11:28:58 -05:00
This session appears to have been modified \ n \
without save , or in middle of recording when \ n \
% 1 or the computer was shutdown . \ n \
2005-09-25 14:42:24 -04:00
\ n \
2020-01-28 11:28:58 -05:00
% 1 can recover any changes for \ n \
2005-09-25 14:42:24 -04:00
you , or it can ignore it . Please decide \ n \
2012-04-22 21:02:33 -04:00
what you would like to do . \ n " ), PROGRAM_NAME));
2022-01-26 18:04:44 -05:00
image - > set_alignment ( ALIGN_CENTER , ALIGN_START ) ;
2007-10-26 11:31:46 -04:00
hbox - > pack_start ( * image , PACK_EXPAND_WIDGET , 12 ) ;
hbox - > pack_end ( message , PACK_EXPAND_PADDING , 12 ) ;
dialog . get_vbox ( ) - > pack_start ( * hbox , PACK_EXPAND_PADDING , 6 ) ;
2005-11-27 16:17:41 -05:00
dialog . add_button ( _ ( " Ignore crash data " ) , RESPONSE_REJECT ) ;
2007-10-26 11:31:46 -04:00
dialog . add_button ( _ ( " Recover from crash " ) , RESPONSE_ACCEPT ) ;
dialog . set_default_response ( RESPONSE_ACCEPT ) ;
2005-10-06 14:24:23 -04:00
dialog . set_position ( WIN_POS_CENTER ) ;
2007-07-06 17:54:30 -04:00
message . show ( ) ;
2007-10-26 11:31:46 -04:00
image - > show ( ) ;
hbox - > show ( ) ;
2008-01-10 17:22:29 -05:00
2021-07-06 19:02:13 -04:00
if ( Splash : : exists ( ) ) {
Splash : : instance ( ) - > hide ( ) ;
}
2021-05-25 15:56:42 -04:00
2005-11-27 16:17:41 -05:00
switch ( dialog . run ( ) ) {
case RESPONSE_ACCEPT :
2005-09-25 14:42:24 -04:00
return 1 ;
2006-03-29 13:52:55 -05:00
default :
2019-09-23 16:49:06 -04:00
return 0 ;
2008-03-17 16:54:03 -04:00
}
2007-01-09 18:24:54 -05:00
}
void
ARDOUR_UI : : store_clock_modes ( )
{
2019-11-08 14:39:58 -05:00
if ( session_load_in_progress ) {
/* Do not overwrite clock modes while loading them (with a session) */
return ;
}
2007-01-09 18:24:54 -05:00
XMLNode * node = new XMLNode ( X_ ( " ClockModes " ) ) ;
for ( vector < AudioClock * > : : iterator x = AudioClock : : clocks . begin ( ) ; x ! = AudioClock : : clocks . end ( ) ; + + x ) {
2011-06-07 19:07:08 -04:00
XMLNode * child = new XMLNode ( X_ ( " Clock " ) ) ;
2015-09-08 16:30:30 -04:00
2016-08-28 18:58:39 -04:00
child - > set_property ( X_ ( " name " ) , ( * x ) - > name ( ) ) ;
child - > set_property ( X_ ( " mode " ) , ( * x ) - > mode ( ) ) ;
child - > set_property ( X_ ( " on " ) , ( * x ) - > on ( ) ) ;
2011-06-07 19:07:08 -04:00
node - > add_child_nocopy ( * child ) ;
2007-01-09 18:24:54 -05:00
}
2009-12-17 13:24:23 -05:00
_session - > add_extra_xml ( * node ) ;
_session - > set_dirty ( ) ;
2007-01-09 18:24:54 -05:00
}
2011-11-01 19:19:03 -04:00
/** Allocate our thread-local buffers */
void
ARDOUR_UI : : get_process_buffers ( )
{
_process_thread - > get_buffers ( ) ;
}
/** Drop our thread-local buffers */
void
ARDOUR_UI : : drop_process_buffers ( )
{
_process_thread - > drop_buffers ( ) ;
}
2011-11-09 12:44:39 -05:00
void
ARDOUR_UI : : feedback_detected ( )
{
2011-11-11 08:52:27 -05:00
_feedback_exists = true ;
}
2011-11-09 12:44:39 -05:00
2011-11-11 08:52:27 -05:00
void
ARDOUR_UI : : successful_graph_sort ( )
{
_feedback_exists = false ;
2011-11-09 12:44:39 -05:00
}
2011-11-10 13:04:34 -05:00
void
ARDOUR_UI : : midi_panic ( )
{
if ( _session ) {
_session - > midi_panic ( ) ;
}
}
2013-03-04 16:57:29 -05:00
2013-07-24 16:04:46 -04:00
void
ARDOUR_UI : : reset_peak_display ( )
{
if ( ! _session | | ! _session - > master_out ( ) | | ! editor_meter ) return ;
2020-04-10 17:36:17 -04:00
_clear_editor_meter = true ;
2013-07-24 16:04:46 -04:00
}
void
ARDOUR_UI : : reset_group_peak_display ( RouteGroup * group )
{
if ( ! _session | | ! _session - > master_out ( ) ) return ;
if ( group = = _session - > master_out ( ) - > route_group ( ) ) {
reset_peak_display ( ) ;
}
}
void
ARDOUR_UI : : reset_route_peak_display ( Route * route )
{
if ( ! _session | | ! _session - > master_out ( ) ) return ;
if ( _session - > master_out ( ) . get ( ) = = route ) {
reset_peak_display ( ) ;
}
}
2013-09-05 14:21:25 -04:00
2015-02-08 10:18:39 -05:00
void
ARDOUR_UI : : hide_application ( )
{
2017-07-01 12:42:24 -04:00
Application : : instance ( ) - > hide ( ) ;
2015-02-08 10:18:39 -05:00
}
2015-10-02 07:32:49 -04:00
void
2015-07-07 22:12:21 -04:00
ARDOUR_UI : : setup_toplevel_window ( Gtk : : Window & window , const string & name , void * owner )
2015-10-02 07:32:49 -04:00
{
2015-07-07 22:12:21 -04:00
/* icons, titles, WM stuff */
static list < Glib : : RefPtr < Gdk : : Pixbuf > > window_icons ;
if ( window_icons . empty ( ) ) {
Glib : : RefPtr < Gdk : : Pixbuf > icon ;
2016-08-04 03:48:47 -04:00
if ( ( icon = : : get_icon ( PROGRAM_NAME " -icon_16px " ) ) ) {
2015-07-07 22:12:21 -04:00
window_icons . push_back ( icon ) ;
}
2016-08-04 03:48:47 -04:00
if ( ( icon = : : get_icon ( PROGRAM_NAME " -icon_22px " ) ) ) {
2015-07-07 22:12:21 -04:00
window_icons . push_back ( icon ) ;
}
2016-08-04 03:48:47 -04:00
if ( ( icon = : : get_icon ( PROGRAM_NAME " -icon_32px " ) ) ) {
2015-07-07 22:12:21 -04:00
window_icons . push_back ( icon ) ;
}
2016-08-04 03:48:47 -04:00
if ( ( icon = : : get_icon ( PROGRAM_NAME " -icon_48px " ) ) ) {
2015-07-07 22:12:21 -04:00
window_icons . push_back ( icon ) ;
}
}
if ( ! window_icons . empty ( ) ) {
window . set_default_icon_list ( window_icons ) ;
}
2015-10-26 14:35:06 -04:00
2015-07-07 22:12:21 -04:00
Gtkmm2ext : : WindowTitle title ( Glib : : get_application_name ( ) ) ;
2015-07-08 12:45:57 -04:00
if ( ! name . empty ( ) ) {
title + = name ;
}
2015-07-07 22:12:21 -04:00
window . set_title ( title . get_string ( ) ) ;
2017-01-20 05:48:59 -05:00
window . set_wmclass ( string_compose ( X_ ( " %1_%1 " ) , downcase ( std : : string ( PROGRAM_NAME ) ) , downcase ( name ) ) , PROGRAM_NAME ) ;
2015-07-07 22:12:21 -04:00
2022-01-26 16:29:36 -05:00
window . set_can_focus ( ) ;
2015-07-07 22:12:21 -04:00
window . add_events ( Gdk : : KEY_PRESS_MASK | Gdk : : KEY_RELEASE_MASK ) ;
2015-07-22 18:05:25 -04:00
/* This is a hack to ensure that GTK-accelerators continue to
* work . Once we switch over to entirely native bindings , this will be
* unnecessary and should be removed
*/
2015-07-08 12:45:57 -04:00
window . add_accel_group ( ActionManager : : ui_manager - > get_accel_group ( ) ) ;
2015-07-07 22:12:21 -04:00
window . signal_configure_event ( ) . connect ( sigc : : mem_fun ( * this , & ARDOUR_UI : : configure_handler ) ) ;
window . signal_window_state_event ( ) . connect ( sigc : : bind ( sigc : : mem_fun ( * this , & ARDOUR_UI : : tabbed_window_state_event_handler ) , owner ) ) ;
window . signal_key_press_event ( ) . connect ( sigc : : bind ( sigc : : mem_fun ( * this , & ARDOUR_UI : : key_event_handler ) , & window ) , false ) ;
window . signal_key_release_event ( ) . connect ( sigc : : bind ( sigc : : mem_fun ( * this , & ARDOUR_UI : : key_event_handler ) , & window ) , false ) ;
}
2020-11-19 21:20:34 -05:00