mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
Add a send amp's gain control as a send controllable.
Tweak AutomationControl now that PBD::Controllable has a default implementation of user_to_ui and ui_to_user. Add correct implementations of these methods to Amp::GainControl. Hence allow SendProcessorEntry to use the generic mini-fader-adding code from ProcessorEntry. git-svn-id: svn://localhost/ardour2/branches/3.0@11292 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
0c30881ad4
commit
a8bb49e5d8
6 changed files with 61 additions and 151 deletions
|
|
@ -28,7 +28,6 @@
|
|||
#include <sigc++/bind.h>
|
||||
|
||||
#include "pbd/convert.h"
|
||||
#include "pbd/stacktrace.h"
|
||||
|
||||
#include <glibmm/miscutils.h>
|
||||
|
||||
|
|
@ -112,6 +111,7 @@ ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
|
|||
_button.set_text (name (_width));
|
||||
|
||||
if (_processor) {
|
||||
|
||||
_vbox.pack_start (_button, true, true);
|
||||
|
||||
if (_processor->active()) {
|
||||
|
|
@ -126,10 +126,17 @@ ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
|
|||
set<Evoral::Parameter> p = _processor->what_can_be_automated ();
|
||||
for (set<Evoral::Parameter>::iterator i = p.begin(); i != p.end(); ++i) {
|
||||
if (boost::dynamic_pointer_cast<Amp> (_processor)) {
|
||||
/* Don't give Fader processors separate controls here */
|
||||
continue;
|
||||
}
|
||||
|
||||
Control* c = new Control (_slider_pixbuf, _processor->automation_control (*i), _processor->describe_parameter (*i));
|
||||
|
||||
string d = _processor->describe_parameter (*i);
|
||||
if (boost::dynamic_pointer_cast<Send> (_processor)) {
|
||||
/* Little hack; don't label send level faders */
|
||||
d = "";
|
||||
}
|
||||
|
||||
Control* c = new Control (_slider_pixbuf, _processor->automation_control (*i), d);
|
||||
_controls.push_back (c);
|
||||
_vbox.pack_start (c->box);
|
||||
}
|
||||
|
|
@ -141,6 +148,13 @@ ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
|
|||
}
|
||||
}
|
||||
|
||||
ProcessorEntry::~ProcessorEntry ()
|
||||
{
|
||||
for (list<Control*>::iterator i = _controls.begin(); i != _controls.end(); ++i) {
|
||||
delete *i;
|
||||
}
|
||||
}
|
||||
|
||||
EventBox&
|
||||
ProcessorEntry::action_widget ()
|
||||
{
|
||||
|
|
@ -373,12 +387,12 @@ ProcessorEntry::Control::Control (Glib::RefPtr<Gdk::Pixbuf> s, boost::shared_ptr
|
|||
|
||||
double const lo = c->user_to_ui (c->lower ());
|
||||
double const up = c->user_to_ui (c->upper ());
|
||||
|
||||
|
||||
_adjustment.set_lower (lo);
|
||||
_adjustment.set_upper (up);
|
||||
_adjustment.set_step_increment ((up - lo) / 100);
|
||||
_adjustment.set_page_increment ((up - lo) / 10);
|
||||
_slider.set_default_value (up);
|
||||
_slider.set_default_value (c->user_to_ui (c->normal ()));
|
||||
|
||||
_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
|
||||
c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
|
||||
|
|
@ -404,7 +418,7 @@ ProcessorEntry::Control::slider_adjusted ()
|
|||
if (!c) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
c->set_value (c->ui_to_user (_adjustment.get_value ()));
|
||||
}
|
||||
|
||||
|
|
@ -417,7 +431,18 @@ ProcessorEntry::Control::control_changed ()
|
|||
}
|
||||
|
||||
_ignore_slider_adjustment = true;
|
||||
|
||||
_adjustment.set_value (c->user_to_ui (c->get_value ()));
|
||||
|
||||
/* XXX: general presentation of values to the user */
|
||||
stringstream s;
|
||||
s.precision (1);
|
||||
s.setf (ios::fixed, ios::floatfield);
|
||||
s << accurate_coefficient_to_dB (c->get_value ());
|
||||
s << _("dB");
|
||||
|
||||
_slider.set_tooltip_text (s.str ());
|
||||
|
||||
_ignore_slider_adjustment = false;
|
||||
}
|
||||
|
||||
|
|
@ -485,111 +510,6 @@ BlankProcessorEntry::BlankProcessorEntry (Width w)
|
|||
{
|
||||
}
|
||||
|
||||
SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
|
||||
: ProcessorEntry (s, w)
|
||||
, _send (s)
|
||||
, _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
|
||||
, _fader (_slider_pixbuf, &_adjustment, 0, false)
|
||||
, _ignore_gain_change (false)
|
||||
, _data_type (DataType::AUDIO)
|
||||
{
|
||||
_fader.set_name ("SendFader");
|
||||
_fader.set_controllable (_send->amp()->gain_control ());
|
||||
_vbox.pack_start (_fader);
|
||||
|
||||
_fader.show ();
|
||||
|
||||
_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted));
|
||||
|
||||
_send->amp()->gain_control()->Changed.connect (
|
||||
_send_connections, invalidator (*this), boost::bind (&SendProcessorEntry::show_gain, this), gui_context()
|
||||
);
|
||||
|
||||
_send->amp()->ConfigurationChanged.connect (
|
||||
_send_connections, invalidator (*this), ui_bind (&SendProcessorEntry::setup_gain_adjustment, this), gui_context ()
|
||||
);
|
||||
|
||||
setup_gain_adjustment ();
|
||||
show_gain ();
|
||||
}
|
||||
|
||||
void
|
||||
SendProcessorEntry::setup_gain_adjustment ()
|
||||
{
|
||||
if (_send->amp()->output_streams().n_midi() == 0) {
|
||||
_data_type = DataType::AUDIO;
|
||||
_adjustment.set_lower (0);
|
||||
_adjustment.set_upper (1);
|
||||
_adjustment.set_step_increment (0.01);
|
||||
_adjustment.set_page_increment (0.1);
|
||||
_fader.set_default_value (gain_to_slider_position (1));
|
||||
} else {
|
||||
_data_type = DataType::MIDI;
|
||||
_adjustment.set_lower (0);
|
||||
_adjustment.set_upper (2);
|
||||
_adjustment.set_step_increment (0.05);
|
||||
_adjustment.set_page_increment (0.1);
|
||||
_fader.set_default_value (1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SendProcessorEntry::show_gain ()
|
||||
{
|
||||
gain_t value = 0;
|
||||
|
||||
switch (_data_type) {
|
||||
case DataType::AUDIO:
|
||||
value = gain_to_slider_position_with_max (_send->amp()->gain (), Config->get_max_gain());
|
||||
break;
|
||||
case DataType::MIDI:
|
||||
value = _send->amp()->gain ();
|
||||
break;
|
||||
}
|
||||
|
||||
if (_adjustment.get_value() != value) {
|
||||
_ignore_gain_change = true;
|
||||
_adjustment.set_value (value);
|
||||
_ignore_gain_change = false;
|
||||
|
||||
stringstream s;
|
||||
s.precision (1);
|
||||
s.setf (ios::fixed, ios::floatfield);
|
||||
s << accurate_coefficient_to_dB (_send->amp()->gain ());
|
||||
if (_data_type == DataType::AUDIO) {
|
||||
s << _("dB");
|
||||
}
|
||||
|
||||
_fader.set_tooltip_text (s.str ());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SendProcessorEntry::gain_adjusted ()
|
||||
{
|
||||
if (_ignore_gain_change) {
|
||||
return;
|
||||
}
|
||||
|
||||
gain_t value = 0;
|
||||
|
||||
switch (_data_type) {
|
||||
case DataType::AUDIO:
|
||||
value = slider_position_to_gain_with_max (_adjustment.get_value(), Config->get_max_gain());
|
||||
break;
|
||||
case DataType::MIDI:
|
||||
value = _adjustment.get_value ();
|
||||
}
|
||||
|
||||
_send->amp()->set_gain (value, this);
|
||||
}
|
||||
|
||||
void
|
||||
SendProcessorEntry::set_pixel_width (int p)
|
||||
{
|
||||
_fader.set_fader_length (p);
|
||||
}
|
||||
|
||||
PluginInsertProcessorEntry::PluginInsertProcessorEntry (boost::shared_ptr<ARDOUR::PluginInsert> p, Width w)
|
||||
: ProcessorEntry (p, w)
|
||||
, _plugin_insert (p)
|
||||
|
|
@ -1450,12 +1370,9 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
|
|||
return;
|
||||
}
|
||||
|
||||
boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
|
||||
boost::shared_ptr<PluginInsert> plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (processor);
|
||||
ProcessorEntry* e = 0;
|
||||
if (send) {
|
||||
e = new SendProcessorEntry (send, _width);
|
||||
} else if (plugin_insert) {
|
||||
if (plugin_insert) {
|
||||
e = new PluginInsertProcessorEntry (plugin_insert, _width);
|
||||
} else {
|
||||
e = new ProcessorEntry (processor, _width);
|
||||
|
|
@ -1469,6 +1386,11 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
|
|||
e->set_control_state (proc);
|
||||
}
|
||||
|
||||
if (boost::dynamic_pointer_cast<Send> (processor)) {
|
||||
/* Always show send controls */
|
||||
e->show_all_controls ();
|
||||
}
|
||||
|
||||
processor_display.add_child (e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ namespace ARDOUR {
|
|||
class PluginInsert;
|
||||
class PortInsert;
|
||||
class Route;
|
||||
class Send;
|
||||
class Session;
|
||||
}
|
||||
|
||||
|
|
@ -103,6 +102,7 @@ class ProcessorEntry : public Gtkmm2ext::DnDVBoxChild, public sigc::trackable
|
|||
{
|
||||
public:
|
||||
ProcessorEntry (boost::shared_ptr<ARDOUR::Processor>, Width);
|
||||
~ProcessorEntry ();
|
||||
|
||||
Gtk::EventBox& action_widget ();
|
||||
Gtk::Widget& widget ();
|
||||
|
|
@ -189,27 +189,6 @@ class BlankProcessorEntry : public ProcessorEntry
|
|||
BlankProcessorEntry (Width w);
|
||||
};
|
||||
|
||||
class SendProcessorEntry : public ProcessorEntry
|
||||
{
|
||||
public:
|
||||
SendProcessorEntry (boost::shared_ptr<ARDOUR::Send>, Width);
|
||||
|
||||
void set_enum_width (Width, int);
|
||||
void set_pixel_width (int);
|
||||
|
||||
private:
|
||||
void show_gain ();
|
||||
void gain_adjusted ();
|
||||
void setup_gain_adjustment ();
|
||||
|
||||
boost::shared_ptr<ARDOUR::Send> _send;
|
||||
Gtk::Adjustment _adjustment;
|
||||
Gtkmm2ext::HSliderController _fader;
|
||||
bool _ignore_gain_change;
|
||||
PBD::ScopedConnectionList _send_connections;
|
||||
ARDOUR::DataType _data_type;
|
||||
};
|
||||
|
||||
class PluginInsertProcessorEntry : public ProcessorEntry
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -42,8 +42,11 @@ Amp::Amp (Session& s)
|
|||
, _apply_gain_automation(false)
|
||||
, _current_gain(1.0)
|
||||
{
|
||||
boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(GainAutomation)));
|
||||
_gain_control = boost::shared_ptr<GainControl>( new GainControl(X_("gaincontrol"), s, this, Evoral::Parameter(GainAutomation), gl ));
|
||||
Evoral::Parameter p (GainAutomation);
|
||||
/* gain range of -inf to +6dB, default 0dB */
|
||||
p.set_range (0, 1.99526231f, 1, false);
|
||||
boost::shared_ptr<AutomationList> gl (new AutomationList (p));
|
||||
_gain_control = boost::shared_ptr<GainControl> (new GainControl (X_("gaincontrol"), s, this, p, gl));
|
||||
add_control(_gain_control);
|
||||
}
|
||||
|
||||
|
|
@ -371,8 +374,6 @@ Amp::set_gain (gain_t val, void *src)
|
|||
val = 1.99526231f;
|
||||
}
|
||||
|
||||
//cerr << "set desired gain to " << val << " when curgain = " << _gain_control->get_value () << endl;
|
||||
|
||||
if (src != _gain_control.get()) {
|
||||
_gain_control->set_value (val);
|
||||
// bit twisty, this will come back and call us again
|
||||
|
|
@ -427,6 +428,18 @@ Amp::GainControl::get_value (void) const
|
|||
return AutomationControl::get_value();
|
||||
}
|
||||
|
||||
double
|
||||
Amp::GainControl::user_to_ui (double v) const
|
||||
{
|
||||
return gain_to_slider_position (v);
|
||||
}
|
||||
|
||||
double
|
||||
Amp::GainControl::ui_to_user (double v) const
|
||||
{
|
||||
return slider_position_to_gain (v);
|
||||
}
|
||||
|
||||
void
|
||||
Amp::setup_gain_automation (framepos_t start_frame, framepos_t end_frame, framecnt_t nframes)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ public:
|
|||
void set_value (double val);
|
||||
double get_value (void) const;
|
||||
|
||||
double user_to_ui (double) const;
|
||||
double ui_to_user (double) const;
|
||||
|
||||
Amp* _amp;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -79,19 +79,10 @@ public:
|
|||
|
||||
double lower() const { return parameter().min(); }
|
||||
double upper() const { return parameter().max(); }
|
||||
double normal() const { return parameter().normal(); }
|
||||
|
||||
const ARDOUR::Session& session() const { return _session; }
|
||||
|
||||
/** Convert user values to UI values. See pbd/controllable.h */
|
||||
virtual double user_to_ui (double val) const {
|
||||
return val;
|
||||
}
|
||||
|
||||
/** Convert UI values to user values. See pbd/controllable.h */
|
||||
virtual double ui_to_user (double val) const {
|
||||
return val;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
ARDOUR::Session& _session;
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMas
|
|||
|
||||
_amp.reset (new Amp (_session));
|
||||
_meter.reset (new PeakMeter (_session));
|
||||
|
||||
add_control (_amp->gain_control ());
|
||||
}
|
||||
|
||||
Send::~Send ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue