summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-04-25 21:24:58 +0200
committerRobin Gareus <robin@gareus.org>2015-04-25 21:24:58 +0200
commit517467f29747acde8baa6f42ed064e2ed58f5ea5 (patch)
treeef41b57cd66aaca1c7b639a2c50ee3463879c7b9 /libs/ardour
parent1e5be9ebfd35f6b603368f394e7f2448b2c2e56d (diff)
prepare trim automation
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/amp.cc2
-rw-r--r--libs/ardour/ardour/process_thread.h1
-rw-r--r--libs/ardour/ardour/route.h1
-rw-r--r--libs/ardour/ardour/session.h1
-rw-r--r--libs/ardour/ardour/thread_buffers.h1
-rw-r--r--libs/ardour/automatable.cc9
-rw-r--r--libs/ardour/automation_list.cc1
-rw-r--r--libs/ardour/event_type_map.cc4
-rw-r--r--libs/ardour/process_thread.cc11
-rw-r--r--libs/ardour/route.cc41
-rw-r--r--libs/ardour/session.cc6
-rw-r--r--libs/ardour/thread_buffers.cc3
12 files changed, 77 insertions, 4 deletions
diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc
index f2381cdefb..9430585b61 100644
--- a/libs/ardour/amp.cc
+++ b/libs/ardour/amp.cc
@@ -46,7 +46,7 @@ Amp::Amp (Session& s, std::string type)
{
Evoral::Parameter p (_type == "trim" ? TrimAutomation : GainAutomation);
boost::shared_ptr<AutomationList> gl (new AutomationList (p));
- _gain_control = boost::shared_ptr<GainControl> (new GainControl (X_("gaincontrol"), s, this, p, gl));
+ _gain_control = boost::shared_ptr<GainControl> (new GainControl ((_type == "trim") ? X_("trimcontrol") : X_("gaincontrol"), s, this, p, gl));
_gain_control->set_flags (Controllable::GainLike);
add_control(_gain_control);
diff --git a/libs/ardour/ardour/process_thread.h b/libs/ardour/ardour/process_thread.h
index 779fdaea2d..67bd07dbfe 100644
--- a/libs/ardour/ardour/process_thread.h
+++ b/libs/ardour/ardour/process_thread.h
@@ -50,6 +50,7 @@ public:
static BufferSet& get_route_buffers (ChanCount count = ChanCount::ZERO, bool silence = false);
static BufferSet& get_mix_buffers (ChanCount count = ChanCount::ZERO);
static gain_t* gain_automation_buffer ();
+ static gain_t* trim_automation_buffer ();
static gain_t* send_gain_automation_buffer ();
static pan_t** pan_automation_buffer ();
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h
index 99d3421491..5a459e7ce5 100644
--- a/libs/ardour/ardour/route.h
+++ b/libs/ardour/ardour/route.h
@@ -508,6 +508,7 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
bool _active;
framecnt_t _signal_latency;
framecnt_t _signal_latency_at_amp_position;
+ framecnt_t _signal_latency_at_trim_position;
framecnt_t _initial_delay;
framecnt_t _roll_delay;
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 30afd00fdb..3da040af0d 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -817,6 +817,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
/* buffers for gain and pan */
gain_t* gain_automation_buffer () const;
+ gain_t* trim_automation_buffer () const;
gain_t* send_gain_automation_buffer () const;
pan_t** pan_automation_buffer () const;
diff --git a/libs/ardour/ardour/thread_buffers.h b/libs/ardour/ardour/thread_buffers.h
index bf686fd57e..5ea352f2ef 100644
--- a/libs/ardour/ardour/thread_buffers.h
+++ b/libs/ardour/ardour/thread_buffers.h
@@ -42,6 +42,7 @@ public:
BufferSet* route_buffers;
BufferSet* mix_buffers;
gain_t* gain_automation_buffer;
+ gain_t* trim_automation_buffer;
gain_t* send_gain_automation_buffer;
pan_t** pan_automation_buffer;
uint32_t npan_buffers;
diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc
index 310592ae4b..9a37b1d590 100644
--- a/libs/ardour/automatable.cc
+++ b/libs/ardour/automatable.cc
@@ -163,6 +163,8 @@ Automatable::describe_parameter (Evoral::Parameter param)
if (param == Evoral::Parameter(GainAutomation)) {
return _("Fader");
+ } else if (param.type() == TrimAutomation) {
+ return _("Trim");
} else if (param.type() == MuteAutomation) {
return _("Mute");
} else if (param.type() == MidiCCAutomation) {
@@ -441,6 +443,13 @@ Automatable::control_factory(const Evoral::Parameter& param)
} else {
warning << "GainAutomation for non-Amp" << endl;
}
+ } else if (param.type() == TrimAutomation) {
+ Amp* amp = dynamic_cast<Amp*>(this);
+ if (amp) {
+ control = new Amp::GainControl(X_("trimcontrol"), _a_session, amp, param);
+ } else {
+ warning << "TrimAutomation for non-Amp" << endl;
+ }
} else if (param.type() == PanAzimuthAutomation || param.type() == PanWidthAutomation || param.type() == PanElevationAutomation) {
Pannable* pannable = dynamic_cast<Pannable*>(this);
if (pannable) {
diff --git a/libs/ardour/automation_list.cc b/libs/ardour/automation_list.cc
index 941178a698..7f7599f8ca 100644
--- a/libs/ardour/automation_list.cc
+++ b/libs/ardour/automation_list.cc
@@ -139,6 +139,7 @@ AutomationList::create_curve_if_necessary()
{
switch (_parameter.type()) {
case GainAutomation:
+ case TrimAutomation:
case PanAzimuthAutomation:
case PanElevationAutomation:
case PanWidthAutomation:
diff --git a/libs/ardour/event_type_map.cc b/libs/ardour/event_type_map.cc
index cd3aeacebd..8782162304 100644
--- a/libs/ardour/event_type_map.cc
+++ b/libs/ardour/event_type_map.cc
@@ -130,6 +130,8 @@ EventTypeMap::from_symbol(const string& str) const
if (str == "gain") {
p_type = GainAutomation;
+ } else if (str == "trim") {
+ p_type = TrimAutomation;
} else if (str == "solo") {
p_type = SoloAutomation;
} else if (str == "mute") {
@@ -207,6 +209,8 @@ EventTypeMap::to_symbol(const Evoral::Parameter& param) const
if (t == GainAutomation) {
return "gain";
+ } else if (t == TrimAutomation) {
+ return "trim";
} else if (t == PanAzimuthAutomation) {
return "pan-azimuth";
} else if (t == PanElevationAutomation) {
diff --git a/libs/ardour/process_thread.cc b/libs/ardour/process_thread.cc
index d4a3d2f390..cf48c50c70 100644
--- a/libs/ardour/process_thread.cc
+++ b/libs/ardour/process_thread.cc
@@ -169,6 +169,17 @@ ProcessThread::gain_automation_buffer()
}
gain_t*
+ProcessThread::trim_automation_buffer()
+{
+ ThreadBuffers* tb = _private_thread_buffers.get();
+ assert (tb);
+
+ gain_t *g = tb->trim_automation_buffer;
+ assert (g);
+ return g;
+}
+
+gain_t*
ProcessThread::send_gain_automation_buffer()
{
ThreadBuffers* tb = _private_thread_buffers.get();
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index 3d9785b2fb..76006ec186 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -82,6 +82,7 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type)
, _active (true)
, _signal_latency (0)
, _signal_latency_at_amp_position (0)
+ , _signal_latency_at_trim_position (0)
, _initial_delay (0)
, _roll_delay (0)
, _flags (flg)
@@ -360,7 +361,6 @@ Route::ensure_track_or_route_name(string name, Session &session)
return newname;
}
-
void
Route::inc_gain (gain_t fraction, void *src)
{
@@ -474,8 +474,15 @@ Route::process_output_buffers (BufferSet& bufs,
start_frame + _signal_latency_at_amp_position,
end_frame + _signal_latency_at_amp_position,
nframes);
+
+ _trim->set_gain_automation_buffer (_session.trim_automation_buffer ());
+ _trim->setup_gain_automation (
+ start_frame + _signal_latency_at_trim_position,
+ end_frame + _signal_latency_at_trim_position,
+ nframes);
} else {
_amp->apply_gain_automation (false);
+ _trim->apply_gain_automation (false);
}
/* Tell main outs what to do about monitoring. We do this so that
@@ -610,6 +617,10 @@ Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes,
_amp->set_gain_automation_buffer (_session.gain_automation_buffer ());
_amp->setup_gain_automation (start - latency, start - latency + nframes, nframes);
+ /* trim is always at the top, for bounce no latency compensation is needed */
+ _trim->set_gain_automation_buffer (_session.trim_automation_buffer ());
+ _trim->setup_gain_automation (start, start + nframes, nframes);
+
latency = 0;
for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
@@ -1509,7 +1520,7 @@ Route::clear_processors (Placement p)
seen_amp = true;
}
- if ((*i) == _amp || (*i) == _meter || (*i) == _main_outs || (*i) == _delayline) {
+ if ((*i) == _amp || (*i) == _meter || (*i) == _main_outs || (*i) == _delayline || (*i) == _trim) {
/* you can't remove these */
@@ -1576,7 +1587,7 @@ Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStream
/* these can never be removed */
- if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline) {
+ if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline || processor == _trim) {
return 0;
}
@@ -3209,6 +3220,7 @@ Route::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
}
_amp->apply_gain_automation (false);
+ _trim->apply_gain_automation (false);
passthru (bufs, start_frame, end_frame, nframes, 0);
return 0;
@@ -3391,6 +3403,8 @@ Route::update_signal_latency ()
framecnt_t l = _output->user_latency();
framecnt_t lamp = 0;
bool before_amp = true;
+ framecnt_t ltrim = 0;
+ bool before_trim = true;
for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
if ((*i)->active ()) {
@@ -3399,14 +3413,23 @@ Route::update_signal_latency ()
if ((*i) == _amp) {
before_amp = false;
}
+ if ((*i) == _trim) {
+ before_amp = false;
+ }
if (before_amp) {
lamp = l;
}
+ if (before_trim) {
+ lamp = l;
+ }
}
DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: internal signal latency = %2\n", _name, l));
+ // TODO: (lamp - _signal_latency) to sync to output (read-ahed), currently _roll_delay shifts this around
_signal_latency_at_amp_position = lamp;
+ _signal_latency_at_trim_position = ltrim;
+
if (_signal_latency != l) {
_signal_latency = l;
signal_latency_changed (); /* EMIT SIGNAL */
@@ -3609,6 +3632,18 @@ Route::shift (framepos_t pos, framecnt_t frames)
_session.add_command (new MementoCommand<AutomationList> (*gc->alist().get(), &before, &after));
}
+ /* gain automation */
+ {
+ boost::shared_ptr<AutomationControl> gc = _trim->gain_control();
+
+ XMLNode &before = gc->alist()->get_state ();
+ gc->alist()->shift (pos, frames);
+ XMLNode &after = gc->alist()->get_state ();
+ _session.add_command (new MementoCommand<AutomationList> (*gc->alist().get(), &before, &after));
+ }
+
+ // TODO mute automation ??
+
/* pan automation */
if (_pannable) {
ControlSet::Controls& c (_pannable->controls());
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index b69b0bce61..100c124d72 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -4811,6 +4811,12 @@ Session::gain_automation_buffer() const
}
gain_t*
+Session::trim_automation_buffer() const
+{
+ return ProcessThread::trim_automation_buffer ();
+}
+
+gain_t*
Session::send_gain_automation_buffer() const
{
return ProcessThread::send_gain_automation_buffer ();
diff --git a/libs/ardour/thread_buffers.cc b/libs/ardour/thread_buffers.cc
index b51576bfc9..2336ee50bc 100644
--- a/libs/ardour/thread_buffers.cc
+++ b/libs/ardour/thread_buffers.cc
@@ -33,6 +33,7 @@ ThreadBuffers::ThreadBuffers ()
, route_buffers (new BufferSet)
, mix_buffers (new BufferSet)
, gain_automation_buffer (0)
+ , trim_automation_buffer (0)
, send_gain_automation_buffer (0)
, pan_automation_buffer (0)
, npan_buffers (0)
@@ -79,6 +80,8 @@ ThreadBuffers::ensure_buffers (ChanCount howmany, size_t custom)
delete [] gain_automation_buffer;
gain_automation_buffer = new gain_t[audio_buffer_size];
+ delete [] trim_automation_buffer;
+ trim_automation_buffer = new gain_t[audio_buffer_size];
delete [] send_gain_automation_buffer;
send_gain_automation_buffer = new gain_t[audio_buffer_size];