summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/ardour_ui.cc23
-rw-r--r--gtk2_ardour/editor_videotimeline.cc2
-rw-r--r--gtk2_ardour/engine_dialog.cc131
-rw-r--r--gtk2_ardour/engine_dialog.h8
-rw-r--r--gtk2_ardour/export_video_dialog.cc39
-rw-r--r--gtk2_ardour/export_video_dialog.h5
-rw-r--r--gtk2_ardour/gain_meter.cc11
-rw-r--r--gtk2_ardour/utils.cc9
8 files changed, 159 insertions, 69 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 307eb925b3..50a903cf6c 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -388,25 +388,8 @@ ARDOUR_UI::create_global_port_matrix (ARDOUR::DataType type)
void
ARDOUR_UI::attach_to_engine ()
{
- AudioEngine::instance()->Stopped.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_stopped, this), gui_context());
AudioEngine::instance()->Running.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_running, this), gui_context());
- AudioEngine::instance()->SampleRateChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context());
-
- AudioEngine::instance()->Halted.connect_same_thread (halt_connection, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false));
-
ARDOUR::Port::set_connecting_blocked (ARDOUR_COMMAND_LINE::no_connect_ports);
-
- /* if there is only one audio/midi backend, and it does not require setup, get our use of it underway
- * right here (we need to know the client name and potential session ID
- * to do this, which is why this is here, rather than in, say,
- * ARDOUR::init().
- */
-
- if (!AudioEngine::instance()->setup_required()) {
- const AudioBackendInfo* backend = AudioEngine::instance()->available_backends().front();
- AudioEngine::instance()->set_backend (backend->name, ARDOUR_COMMAND_LINE::backend_client_name, ARDOUR_COMMAND_LINE::backend_session_uuid);
- AudioEngine::instance()->start ();
- }
}
void
@@ -528,6 +511,12 @@ ARDOUR_UI::post_engine ()
*/
ARDOUR::init_post_engine ();
+
+ /* 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());
+ AudioEngine::instance()->Halted.connect_same_thread (halt_connection, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false));
_tooltips.enable();
diff --git a/gtk2_ardour/editor_videotimeline.cc b/gtk2_ardour/editor_videotimeline.cc
index e9360d9d09..ce373f0406 100644
--- a/gtk2_ardour/editor_videotimeline.cc
+++ b/gtk2_ardour/editor_videotimeline.cc
@@ -140,7 +140,7 @@ Editor::export_video ()
break;
}
}
- ExportVideoDialog dialog (*this, _session);
+ ExportVideoDialog dialog (_session, get_selection().time);
Gtk::ResponseType r = (Gtk::ResponseType) dialog.run();
dialog.hide();
#if 0
diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc
index 873498f6ec..d724f4f4d3 100644
--- a/gtk2_ardour/engine_dialog.cc
+++ b/gtk2_ardour/engine_dialog.cc
@@ -29,6 +29,7 @@
#include "pbd/error.h"
#include "pbd/xml++.h"
+#include "pbd/unwind.h"
#include <gtkmm/stock.h>
#include <gtkmm/notebook.h>
@@ -95,15 +96,6 @@ EngineControl::EngineControl ()
if (audio_setup) {
set_state (*audio_setup);
}
-
- ARDOUR::AudioEngine::instance()->Stopped.connect (*this, MISSING_INVALIDATOR, boost::bind (&EngineControl::disable_latency_tab, this), gui_context());
-
- if (!ARDOUR::AudioEngine::instance()->connected()) {
- ARDOUR::AudioEngine::instance()->Running.connect (*this, MISSING_INVALIDATOR, boost::bind (&EngineControl::enable_latency_tab, this), gui_context());
- disable_latency_tab ();
- } else {
- enable_latency_tab ();
- }
}
void
@@ -281,9 +273,18 @@ and microphone.\n\n\
driver_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::driver_changed));
sample_rate_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::sample_rate_changed));
buffer_size_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::buffer_size_changed));
+ device_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::device_changed));
+
+ input_latency.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
+ output_latency.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
+ input_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
+ output_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
+
+
input_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &input_channels));
output_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &output_channels));
- device_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::device_changed));
+
+ notebook.signal_switch_page().connect (sigc::mem_fun (*this, &EngineControl::on_switch_page));
}
EngineControl::~EngineControl ()
@@ -297,6 +298,8 @@ EngineControl::disable_latency_tab ()
vector<string> empty;
set_popdown_strings (lm_output_channel_combo, empty);
set_popdown_strings (lm_input_channel_combo, empty);
+ lm_measure_button.set_sensitive (false);
+ lm_use_button.set_sensitive (false);
}
void
@@ -311,6 +314,9 @@ EngineControl::enable_latency_tab ()
ARDOUR::AudioEngine::instance()->get_physical_inputs (ARDOUR::DataType::AUDIO, inputs);
set_popdown_strings (lm_input_channel_combo, inputs);
lm_input_channel_combo.set_active_text (inputs.front());
+
+ lm_measure_button.set_sensitive (true);
+ lm_use_button.set_sensitive (true);
}
void
@@ -384,10 +390,26 @@ EngineControl::list_devices ()
set_popdown_strings (device_combo, available_devices);
if (!available_devices.empty()) {
+ sample_rate_combo.set_sensitive (true);
+ buffer_size_combo.set_sensitive (true);
+ input_latency.set_sensitive (true);
+ output_latency.set_sensitive (true);
+ input_channels.set_sensitive (true);
+ output_channels.set_sensitive (true);
+
+ /* changing the text in the combo will trigger device_changed()
+ which should populate the parameter controls
+ */
+
device_combo.set_active_text (available_devices.front());
+ } else {
+ sample_rate_combo.set_sensitive (true);
+ buffer_size_combo.set_sensitive (true);
+ input_latency.set_sensitive (true);
+ output_latency.set_sensitive (true);
+ input_channels.set_sensitive (true);
+ output_channels.set_sensitive (true);
}
-
- device_changed ();
}
void
@@ -468,7 +490,13 @@ EngineControl::device_changed ()
ignore_changes--;
+ /* pick up any saved state for this device */
+
maybe_display_saved_state ();
+
+ /* and push it to the backend */
+
+ push_state_to_backend (false);
}
void
@@ -483,6 +511,7 @@ EngineControl::sample_rate_changed ()
*/
show_buffer_duration ();
+ push_state_to_backend (false);
save_state ();
}
@@ -495,6 +524,7 @@ EngineControl::buffer_size_changed ()
}
show_buffer_duration ();
+ push_state_to_backend (false);
save_state ();
}
@@ -522,6 +552,14 @@ EngineControl::show_buffer_duration ()
buffer_size_duration_label.set_text (buf);
}
+void
+EngineControl::parameter_changed ()
+{
+ if (!ignore_changes) {
+ save_state ();
+ }
+}
+
EngineControl::State*
EngineControl::get_matching_state (const string& backend,
const string& driver,
@@ -538,7 +576,7 @@ EngineControl::get_matching_state (const string& backend,
}
EngineControl::State*
-EngineControl::get_current_state ()
+EngineControl::get_saved_state_for_currently_displayed_backend_and_device ()
{
boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
@@ -554,11 +592,11 @@ EngineControl::get_current_state ()
device_combo.get_active_text());
}
-void
+EngineControl::State*
EngineControl::save_state ()
{
bool existing = true;
- State* state = get_current_state ();
+ State* state = get_saved_state_for_currently_displayed_backend_and_device ();
if (!state) {
existing = false;
@@ -578,12 +616,14 @@ EngineControl::save_state ()
if (!existing) {
states.push_back (*state);
}
+
+ return state;
}
void
EngineControl::maybe_display_saved_state ()
{
- State* state = get_current_state ();
+ State* state = get_saved_state_for_currently_displayed_backend_and_device ();
if (state) {
ignore_changes++;
@@ -792,11 +832,10 @@ EngineControl::push_state_to_backend (bool start)
* necessary
*/
- State* state = get_current_state ();
+ State* state = get_saved_state_for_currently_displayed_backend_and_device ();
if (!state) {
- save_state ();
- state = get_current_state ();
+ state = save_state ();
assert (state);
}
@@ -926,23 +965,47 @@ EngineControl::set_desired_sample_rate (uint32_t sr)
device_changed ();
}
-/* latency measurement */
-
void
-EngineControl::update_latency_display ()
+EngineControl::on_switch_page (GtkNotebookPage*, guint page_num)
{
- ARDOUR::framecnt_t const sample_rate = ARDOUR::AudioEngine::instance()->sample_rate();
- if (sample_rate == 0) {
- lm_results.set_text (_("Disconnected from audio engine"));
- } else {
- char buf[64];
- //snprintf (buf, sizeof (buf), "%10.3lf frames %10.3lf ms",
- //(float)_pi->latency(), (float)_pi->latency() * 1000.0f/sample_rate);
- strcpy (buf, "got something");
- lm_results.set_text(buf);
- }
+ if (page_num == 2) {
+ /* latency tab */
+
+ if (!ARDOUR::AudioEngine::instance()->running()) {
+
+ PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
+
+ /* save any existing latency values */
+
+ uint32_t il = (uint32_t) input_latency.get_value ();
+ uint32_t ol = (uint32_t) input_latency.get_value ();
+
+ /* reset to zero so that our new test instance of JACK
+ will be clean of any existing latency measures.
+ */
+
+ input_latency.set_value (0);
+ output_latency.set_value (0);
+
+ push_state_to_backend (false);
+
+ /* reset control */
+
+ input_latency.set_value (il);
+ output_latency.set_value (ol);
+ }
+
+ if (ARDOUR::AudioEngine::instance()->prepare_for_latency_measurement()) {
+ disable_latency_tab ();
+ }
+ enable_latency_tab ();
+ } else {
+ ARDOUR::AudioEngine::instance()->stop_latency_detection();
+ }
}
+/* latency measurement */
+
bool
EngineControl::check_latency_measurement ()
{
@@ -974,6 +1037,7 @@ EngineControl::check_latency_measurement ()
}
uint32_t frames_total = mtdm->del();
+ cerr << "total = " << frames_total << " delay = " << ARDOUR::AudioEngine::instance()->latency_signal_delay() << endl;
uint32_t extra = frames_total - ARDOUR::AudioEngine::instance()->latency_signal_delay();
snprintf (buf, sizeof (buf), "%u samples %10.3lf ms", extra, extra * 1000.0f/sample_rate);
@@ -991,7 +1055,6 @@ EngineControl::check_latency_measurement ()
}
if (solid) {
- // _pi->set_measured_latency (rint (mtdm->del()));
lm_measure_button.set_active (false);
lm_use_button.set_sensitive (true);
strcat (buf, " (set)");
@@ -1009,7 +1072,6 @@ EngineControl::latency_button_toggled ()
ARDOUR::AudioEngine::instance()->set_latency_input_port (lm_input_channel_combo.get_active_text());
ARDOUR::AudioEngine::instance()->set_latency_output_port (lm_output_channel_combo.get_active_text());
- cerr << "latency detection on " << lm_input_channel_combo.get_active_text() << " => " << lm_output_channel_combo.get_active_text() << endl;
ARDOUR::AudioEngine::instance()->start_latency_detection ();
lm_results.set_text (_("Detecting ..."));
latency_timeout = Glib::signal_timeout().connect (mem_fun (*this, &EngineControl::check_latency_measurement), 250);
@@ -1017,7 +1079,6 @@ EngineControl::latency_button_toggled ()
} else {
ARDOUR::AudioEngine::instance()->stop_latency_detection ();
latency_timeout.disconnect ();
- update_latency_display ();
}
}
diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h
index 3872917add..98ddf2c1b3 100644
--- a/gtk2_ardour/engine_dialog.h
+++ b/gtk2_ardour/engine_dialog.h
@@ -118,6 +118,7 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
void backend_changed ();
void sample_rate_changed ();
void buffer_size_changed ();
+ void parameter_changed ();
uint32_t get_rate() const;
uint32_t get_buffer_size() const;
@@ -154,9 +155,9 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
State* get_matching_state (const std::string& backend,
const std::string& driver,
const std::string& device);
- State* get_current_state ();
+ State* get_saved_state_for_currently_displayed_backend_and_device ();
void maybe_display_saved_state ();
- void save_state ();
+ State* save_state ();
static bool print_channel_count (Gtk::SpinButton*);
@@ -172,10 +173,11 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
/* latency measurement */
void latency_button_toggled ();
bool check_latency_measurement ();
- void update_latency_display ();
sigc::connection latency_timeout;
void enable_latency_tab ();
void disable_latency_tab ();
+
+ void on_switch_page (GtkNotebookPage*, guint page_num);
};
#endif /* __gtk2_ardour_engine_dialog_h__ */
diff --git a/gtk2_ardour/export_video_dialog.cc b/gtk2_ardour/export_video_dialog.cc
index f54232a681..7f6fcc2a8a 100644
--- a/gtk2_ardour/export_video_dialog.cc
+++ b/gtk2_ardour/export_video_dialog.cc
@@ -64,9 +64,9 @@ using namespace PBD;
using namespace ARDOUR;
using namespace VideoUtils;
-ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s)
+ExportVideoDialog::ExportVideoDialog (Session* s, TimeSelection &tme)
: ArdourDialog (_("Export Video File "))
- , editor (ed)
+ , export_range (tme)
, outfn_path_label (_("File:"), Gtk::ALIGN_LEFT)
, outfn_browse_button (_("Browse"))
, invid_path_label (_("Video:"), Gtk::ALIGN_LEFT)
@@ -152,6 +152,9 @@ ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s)
} else {
insnd_combo.append_text (_("from the video's start to the video's end"));
}
+ if (!export_range.empty()) {
+ insnd_combo.append_text (_("Selected range")); // TODO show export_range.start() -> export_range.end_frame()
+ }
insnd_combo.set_active(0);
outfn_path_entry.set_width_chars(38);
@@ -509,6 +512,11 @@ ExportVideoDialog::launch_export ()
}
end += av_offset;
}
+ else if (insnd_combo.get_active_row_number() == 2) {
+ // TODO quantize to video-frame ?!
+ start = export_range.start();
+ end = export_range.end_frame();
+ }
if (end <= 0) {
start = _session->current_start_frame();
end = _session->current_end_frame();
@@ -696,9 +704,14 @@ ExportVideoDialog::encode_pass (int pass)
double duration_s = 0;
if (insnd_combo.get_active_row_number() == 0) {
+ /* session start to session end */
framecnt_t duration_f = _session->current_end_frame() - _session->current_start_frame();
duration_s = (double)duration_f / (double)_session->nominal_frame_rate();
+ } else if (insnd_combo.get_active_row_number() == 2) {
+ /* selected range */
+ duration_s = export_range.length() / (double)_session->nominal_frame_rate();
} else {
+ /* video start to end */
framecnt_t duration_f = ARDOUR_UI::instance()->video_timeline->get_duration();
if (av_offset < 0 ) {
duration_f += av_offset;
@@ -714,10 +727,16 @@ ExportVideoDialog::encode_pass (int pass)
transcoder->set_duration(duration_s * transcoder->get_fps());
}
- if (insnd_combo.get_active_row_number() == 0) {
- const framepos_t start = _session->current_start_frame();
- const framepos_t snend = _session->current_end_frame();
+ if (insnd_combo.get_active_row_number() == 0 || insnd_combo.get_active_row_number() == 2) {
+ framepos_t start, snend;
const frameoffset_t vid_duration = ARDOUR_UI::instance()->video_timeline->get_duration();
+ if (insnd_combo.get_active_row_number() == 0) {
+ start = _session->current_start_frame();
+ snend = _session->current_end_frame();
+ } else {
+ start = export_range.start();
+ snend = export_range.end_frame();
+ }
#if 0 /* DEBUG */
printf("AV offset: %lld Vid-len: %lld Vid-end: %lld || start:%lld || end:%lld\n",
@@ -732,9 +751,17 @@ ExportVideoDialog::encode_pass (int pass)
} else if (av_offset + vid_duration < snend) {
transcoder->set_leadinout(0, (snend - (av_offset + vid_duration)) / (double)_session->nominal_frame_rate());
transcoder->set_avoffset((av_offset - start) / (double)_session->nominal_frame_rate());
- } else {
+ }
+#if 0
+ else if (start > av_offset) {
+ std::ostringstream osstream; osstream << ((start - av_offset) / (double)_session->nominal_frame_rate());
+ ffs["-ss"] = osstream.str();
+ }
+#endif
+ else {
transcoder->set_avoffset((av_offset - start) / (double)_session->nominal_frame_rate());
}
+
} else if (av_offset < 0) {
/* from 00:00:00:00 to video-end */
transcoder->set_avoffset(av_offset / (double)_session->nominal_frame_rate());
diff --git a/gtk2_ardour/export_video_dialog.h b/gtk2_ardour/export_video_dialog.h
index 2594c2073b..7e3cf442a7 100644
--- a/gtk2_ardour/export_video_dialog.h
+++ b/gtk2_ardour/export_video_dialog.h
@@ -28,6 +28,7 @@
#include "ardour/template_utils.h"
#include "ardour_dialog.h"
+#include "time_selection.h"
#include "transcode_ffmpeg.h"
/** @class ExportVideoDialog
@@ -40,13 +41,13 @@
class ExportVideoDialog : public ArdourDialog , public PBD::ScopedConnectionList
{
public:
- ExportVideoDialog (PublicEditor&, ARDOUR::Session*);
+ ExportVideoDialog (ARDOUR::Session*, TimeSelection &tme);
~ExportVideoDialog ();
std::string get_exported_filename () { return outfn_path_entry.get_text(); }
private:
- PublicEditor& editor;
+ TimeSelection &export_range;
void on_show ();
void abort_clicked ();
diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc
index d4610da601..f9ab062750 100644
--- a/gtk2_ardour/gain_meter.cc
+++ b/gtk2_ardour/gain_meter.cc
@@ -277,16 +277,19 @@ GainMeterBase::setup_meters (int len)
switch (_width) {
case Wide:
- meter_ticks1_area.show();
- meter_ticks2_area.show();
+ //meter_ticks1_area.show();
+ //meter_ticks2_area.show();
meter_metric_area.show();
if (_route && _route->shared_peak_meter()->input_streams().n_total() == 1) {
meter_width = 10;
}
break;
case Narrow:
- meter_ticks1_area.hide();
- meter_ticks2_area.hide();
+ if (_route && _route->shared_peak_meter()->input_streams().n_total() > 1) {
+ meter_width = 4;
+ }
+ //meter_ticks1_area.hide();
+ //meter_ticks2_area.hide();
meter_metric_area.hide();
break;
}
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index 28e0907f44..a35d171690 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -363,8 +363,15 @@ set_color (Gdk::Color& c, int rgb)
bool
relay_key_press (GdkEventKey* ev, Gtk::Window* win)
{
+ PublicEditor& ed (PublicEditor::instance());
+
+ if (&ed == 0) {
+ /* early key press in pre-main-window-dialogs, no editor yet */
+ return false;
+ }
+
if (!key_press_focus_accelerator_handler (*win, ev)) {
- return PublicEditor::instance().on_key_press_event(ev);
+ return ed.on_key_press_event(ev);
} else {
return true;
}