13
0

fix up the port insert I/O GUI

git-svn-id: svn://localhost/ardour2/branches/3.0@7722 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-08-31 14:16:29 +00:00
parent f13b700944
commit 1ba9060c44
7 changed files with 300 additions and 249 deletions

View File

@ -269,193 +269,3 @@ IOSelectorWindow::io_name_changed (void* src)
set_title (title);
}
PortInsertUI::PortInsertUI (Gtk::Window* parent, ARDOUR::Session* sess, boost::shared_ptr<ARDOUR::PortInsert> pi)
: _pi (pi)
, latency_button (_("Measure Latency"))
, input_selector (parent, sess, pi->input())
, output_selector (parent, sess, pi->output())
{
latency_hbox.pack_start (latency_button, false, false);
latency_hbox.pack_start (latency_display, false, false);
latency_frame.add (latency_hbox);
output_selector.set_min_height_divisor (2);
input_selector.set_min_height_divisor (2);
pack_start (latency_frame);
pack_start (output_selector, true, true);
pack_start (input_selector, true, true);
update_latency_display ();
latency_button.signal_toggled().connect (mem_fun (*this, &PortInsertUI::latency_button_toggled));
}
void
PortInsertUI::update_latency_display ()
{
nframes_t sample_rate = input_selector.session()->engine().frame_rate();
if (sample_rate == 0) {
latency_display.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);
latency_display.set_text(buf);
}
}
bool
PortInsertUI::check_latency_measurement ()
{
MTDM* mtdm = _pi->mtdm ();
if (mtdm->resolve () < 0) {
latency_display.set_text (_("No signal detected"));
return true;
}
if (mtdm->err () > 0.3) {
mtdm->invert ();
mtdm->resolve ();
}
char buf[128];
nframes_t sample_rate = AudioEngine::instance()->frame_rate();
if (sample_rate == 0) {
latency_display.set_text (_("Disconnected from audio engine"));
_pi->stop_latency_detection ();
return false;
}
snprintf (buf, sizeof (buf), "%10.3lf frames %10.3lf ms", mtdm->del (), mtdm->del () * 1000.0f/sample_rate);
bool solid = true;
if (mtdm->err () > 0.2) {
strcat (buf, " ??");
solid = false;
}
if (mtdm->inv ()) {
strcat (buf, " (Inv)");
solid = false;
}
if (solid) {
_pi->set_measured_latency ((nframes_t) rint (mtdm->del()));
latency_button.set_active (false);
strcat (buf, " (set)");
}
latency_display.set_text (buf);
return true;
}
void
PortInsertUI::latency_button_toggled ()
{
if (latency_button.get_active ()) {
_pi->start_latency_detection ();
latency_display.set_text (_("Detecting ..."));
latency_timeout = Glib::signal_timeout().connect (mem_fun (*this, &PortInsertUI::check_latency_measurement), 250);
} else {
_pi->stop_latency_detection ();
latency_timeout.disconnect ();
}
}
void
PortInsertUI::redisplay ()
{
input_selector.setup_ports (input_selector.other());
output_selector.setup_ports (output_selector.other());
}
void
PortInsertUI::finished (IOSelector::Result r)
{
input_selector.Finished (r);
output_selector.Finished (r);
}
PortInsertWindow::PortInsertWindow (ARDOUR::Session* sess, boost::shared_ptr<ARDOUR::PortInsert> pi, bool can_cancel)
: ArdourDialog ("port insert dialog"),
_portinsertui (this, sess, pi),
ok_button (can_cancel ? _("OK"): _("Close")),
cancel_button (_("Cancel"))
{
set_name ("IOSelectorWindow");
string title = _("Port Insert ");
title += pi->name();
set_title (title);
ok_button.set_name ("IOSelectorButton");
if (!can_cancel) {
ok_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CLOSE, Gtk::ICON_SIZE_BUTTON)));
}
cancel_button.set_name ("IOSelectorButton");
if (can_cancel) {
cancel_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CANCEL, Gtk::ICON_SIZE_BUTTON)));
get_action_area()->pack_start (cancel_button, false, false);
} else {
cancel_button.hide();
}
get_action_area()->pack_start (ok_button, false, false);
get_vbox()->pack_start (_portinsertui);
ok_button.signal_clicked().connect (sigc::mem_fun (*this, &PortInsertWindow::accept));
cancel_button.signal_clicked().connect (sigc::mem_fun (*this, &PortInsertWindow::cancel));
signal_delete_event().connect (sigc::mem_fun (*this, &PortInsertWindow::wm_delete), false);
pi->DropReferences.connect (going_away_connection, invalidator (*this), boost::bind (&PortInsertWindow::plugin_going_away, this), gui_context());
}
bool
PortInsertWindow::wm_delete (GdkEventAny* /*event*/)
{
accept ();
return true;
}
void
PortInsertWindow::plugin_going_away ()
{
ENSURE_GUI_THREAD (*this, &PortInsertWindow::plugin_going_away)
going_away_connection.disconnect ();
delete_when_idle (this);
}
void
PortInsertWindow::on_map ()
{
_portinsertui.redisplay ();
Window::on_map ();
}
void
PortInsertWindow::cancel ()
{
_portinsertui.finished (IOSelector::Cancelled);
hide ();
}
void
PortInsertWindow::accept ()
{
_portinsertui.finished (IOSelector::Accepted);
hide ();
}

View File

@ -17,16 +17,11 @@
*/
#ifndef __ardour_ui_io_selector_h__
#define __ardour_ui_io_selector_h__
#ifndef __gtkardour_io_selector_h__
#define __gtkardour_io_selector_h__
#include "ardour_dialog.h"
#include "port_matrix.h"
namespace ARDOUR {
class PortInsert;
}
class IOSelector : public PortMatrix
{
public:
@ -89,55 +84,4 @@ class IOSelectorWindow : public Gtk::Window
bool wm_delete (GdkEventAny*);
};
class PortInsertUI : public Gtk::HBox
{
public:
PortInsertUI (Gtk::Window*, ARDOUR::Session *, boost::shared_ptr<ARDOUR::PortInsert>);
void redisplay ();
void finished (IOSelector::Result);
private:
boost::shared_ptr<ARDOUR::PortInsert> _pi;
Gtk::ToggleButton latency_button;
IOSelector input_selector;
IOSelector output_selector;
Gtk::Label latency_display;
Gtk::Frame latency_frame;
Gtk::HBox latency_hbox;
sigc::connection latency_timeout;
bool check_latency_measurement ();
void latency_button_toggled ();
void update_latency_display ();
};
class PortInsertWindow : public ArdourDialog
{
public:
PortInsertWindow (ARDOUR::Session *, boost::shared_ptr<ARDOUR::PortInsert>, bool can_cancel = false);
protected:
void on_map ();
private:
PortInsertUI _portinsertui;
Gtk::VBox vbox;
Gtk::Button ok_button;
Gtk::Button cancel_button;
Gtk::Frame button_frame;
void cancel ();
void accept ();
void plugin_going_away ();
PBD::ScopedConnection going_away_connection;
bool wm_delete (GdkEventAny*);
};
#endif
#endif /* __gtkardour_io_selector_h__ */

View File

@ -0,0 +1,219 @@
/*
Copyright (C) 2002-2007 Paul Davis
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gtkmm/messagedialog.h>
#include <glibmm/objectbase.h>
#include <gtkmm2ext/doi.h>
#include "ardour/port_insert.h"
#include "ardour/session.h"
#include "ardour/io.h"
#include "ardour/audioengine.h"
#include "ardour/track.h"
#include "ardour/audio_track.h"
#include "ardour/midi_track.h"
#include "ardour/mtdm.h"
#include "ardour/data_type.h"
#include "ardour/port.h"
#include "ardour/bundle.h"
#include "port_insert_ui.h"
#include "utils.h"
#include "gui_thread.h"
#include "i18n.h"
using namespace ARDOUR;
using namespace Gtk;
PortInsertUI::PortInsertUI (Gtk::Window* parent, ARDOUR::Session* sess, boost::shared_ptr<ARDOUR::PortInsert> pi)
: _pi (pi)
, latency_button (_("Measure Latency"))
, input_selector (parent, sess, pi->input())
, output_selector (parent, sess, pi->output())
{
latency_hbox.pack_start (latency_button, false, false);
latency_hbox.pack_start (latency_display, false, false);
output_selector.set_min_height_divisor (2);
input_selector.set_min_height_divisor (2);
notebook.append_page (output_selector, _("Send/Output"));
notebook.append_page (input_selector, _("Return/Input"));
notebook.set_current_page (0);
set_spacing (12);
pack_start (notebook, true, true);
pack_start (latency_hbox, false, false);
update_latency_display ();
latency_button.signal_toggled().connect (mem_fun (*this, &PortInsertUI::latency_button_toggled));
}
void
PortInsertUI::update_latency_display ()
{
nframes_t sample_rate = input_selector.session()->engine().frame_rate();
if (sample_rate == 0) {
latency_display.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);
latency_display.set_text(buf);
}
}
bool
PortInsertUI::check_latency_measurement ()
{
MTDM* mtdm = _pi->mtdm ();
if (mtdm->resolve () < 0) {
latency_display.set_text (_("No signal detected"));
return true;
}
if (mtdm->err () > 0.3) {
mtdm->invert ();
mtdm->resolve ();
}
char buf[128];
nframes_t sample_rate = AudioEngine::instance()->frame_rate();
if (sample_rate == 0) {
latency_display.set_text (_("Disconnected from audio engine"));
_pi->stop_latency_detection ();
return false;
}
snprintf (buf, sizeof (buf), "%10.3lf frames %10.3lf ms", mtdm->del (), mtdm->del () * 1000.0f/sample_rate);
bool solid = true;
if (mtdm->err () > 0.2) {
strcat (buf, " ??");
solid = false;
}
if (mtdm->inv ()) {
strcat (buf, " (Inv)");
solid = false;
}
if (solid) {
_pi->set_measured_latency ((nframes_t) rint (mtdm->del()));
latency_button.set_active (false);
strcat (buf, " (set)");
}
latency_display.set_text (buf);
return true;
}
void
PortInsertUI::latency_button_toggled ()
{
if (latency_button.get_active ()) {
_pi->start_latency_detection ();
latency_display.set_text (_("Detecting ..."));
latency_timeout = Glib::signal_timeout().connect (mem_fun (*this, &PortInsertUI::check_latency_measurement), 250);
} else {
_pi->stop_latency_detection ();
latency_timeout.disconnect ();
update_latency_display ();
}
}
void
PortInsertUI::redisplay ()
{
input_selector.setup_ports (input_selector.other());
output_selector.setup_ports (output_selector.other());
}
void
PortInsertUI::finished (IOSelector::Result r)
{
input_selector.Finished (r);
output_selector.Finished (r);
}
PortInsertWindow::PortInsertWindow (ARDOUR::Session* sess, boost::shared_ptr<ARDOUR::PortInsert> pi)
: ArdourDialog ("port insert dialog"),
_portinsertui (this, sess, pi)
{
set_name ("IOSelectorWindow");
string title = _("Port Insert ");
title += pi->name();
set_title (title);
get_vbox()->pack_start (_portinsertui);
signal_delete_event().connect (sigc::mem_fun (*this, &PortInsertWindow::wm_delete), false);
pi->DropReferences.connect (going_away_connection, invalidator (*this), boost::bind (&PortInsertWindow::plugin_going_away, this), gui_context());
}
bool
PortInsertWindow::wm_delete (GdkEventAny* /*event*/)
{
accept ();
return true;
}
void
PortInsertWindow::plugin_going_away ()
{
ENSURE_GUI_THREAD (*this, &PortInsertWindow::plugin_going_away)
going_away_connection.disconnect ();
delete_when_idle (this);
}
void
PortInsertWindow::on_map ()
{
_portinsertui.redisplay ();
Window::on_map ();
}
void
PortInsertWindow::cancel ()
{
_portinsertui.finished (IOSelector::Cancelled);
hide ();
}
void
PortInsertWindow::accept ()
{
_portinsertui.finished (IOSelector::Accepted);
hide ();
}

View File

@ -0,0 +1,75 @@
/*
Copyright (C) 2002-2010 Paul Davis
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __gtkardour_port_insert_ui_h__
#define __gtkardour_port_insert_ui_h__
#include "ardour_dialog.h"
#include "io_selector.h"
namespace ARDOUR {
class PortInsert;
}
class PortInsertUI : public Gtk::VBox
{
public:
PortInsertUI (Gtk::Window*, ARDOUR::Session *, boost::shared_ptr<ARDOUR::PortInsert>);
void redisplay ();
void finished (IOSelector::Result);
private:
boost::shared_ptr<ARDOUR::PortInsert> _pi;
Gtk::Notebook notebook;
Gtk::ToggleButton latency_button;
IOSelector input_selector;
IOSelector output_selector;
Gtk::Label latency_display;
Gtk::HBox latency_hbox;
sigc::connection latency_timeout;
bool check_latency_measurement ();
void latency_button_toggled ();
void update_latency_display ();
};
class PortInsertWindow : public ArdourDialog
{
public:
PortInsertWindow (ARDOUR::Session *, boost::shared_ptr<ARDOUR::PortInsert>);
protected:
void on_map ();
private:
PortInsertUI _portinsertui;
Gtk::VBox vbox;
void cancel ();
void accept ();
void plugin_going_away ();
PBD::ScopedConnection going_away_connection;
bool wm_delete (GdkEventAny*);
};
#endif /* __gtkardour_port_insert_ui_h__ */

View File

@ -64,6 +64,7 @@
#include "mixer_strip.h"
#include "plugin_selector.h"
#include "plugin_ui.h"
#include "port_insert_ui.h"
#include "processor_box.h"
#include "public_editor.h"
#include "return_ui.h"

View File

@ -44,6 +44,7 @@
#include "io_selector.h"
#include "keyboard.h"
#include "mixer_strip.h"
#include "port_insert_ui.h"
#include "plugin_selector.h"
#include "plugin_ui.h"
#include "return_ui.h"

View File

@ -156,6 +156,7 @@ gtk2_ardour_sources = [
'plugin_selector.cc',
'plugin_ui.cc',
'port_group.cc',
'port_insert_ui.cc',
'port_matrix.cc',
'port_matrix_body.cc',
'port_matrix_column_labels.cc',