2007-04-14 18:39:01 +00:00
|
|
|
/*
|
2019-08-02 23:26:43 +02:00
|
|
|
* Copyright (C) 2005-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
|
* Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
|
|
|
|
|
* Copyright (C) 2005 Taybin Rutkin <taybin@taybin.com>
|
|
|
|
|
* Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
|
|
|
|
|
* Copyright (C) 2008-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
|
* Copyright (C) 2014-2015 Nick Mainsbridge <mainsbridge@gmail.com>
|
|
|
|
|
* Copyright (C) 2014-2019 Robin Gareus <robin@gareus.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.
|
|
|
|
|
*/
|
2007-04-14 18:39:01 +00:00
|
|
|
|
2019-10-25 13:13:51 -06:00
|
|
|
#include "evoral/Curve.h"
|
2009-02-25 18:26:51 +00:00
|
|
|
#include "pbd/memento_command.h"
|
2010-03-02 18:05:26 +00:00
|
|
|
#include "pbd/stateful_diff_command.h"
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2009-12-17 18:24:23 +00:00
|
|
|
#include "ardour/audioregion.h"
|
|
|
|
|
#include "ardour/session.h"
|
|
|
|
|
|
2012-04-05 16:53:55 +00:00
|
|
|
#include "control_point.h"
|
2005-09-25 18:42:24 +00:00
|
|
|
#include "region_gain_line.h"
|
2006-08-01 17:19:38 +00:00
|
|
|
#include "audio_region_view.h"
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
#include "time_axis_view.h"
|
|
|
|
|
#include "editor.h"
|
|
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
|
|
2023-02-16 16:33:28 -07:00
|
|
|
AudioRegionGainLine::AudioRegionGainLine (const string & name, AudioRegionView& r, ArdourCanvas::Container& parent, std::shared_ptr<AutomationList> l)
|
2024-04-17 03:53:30 +02:00
|
|
|
: RegionFxLine (name, r, parent, l, l->parameter ())
|
|
|
|
|
, arv (r)
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2010-01-11 19:36:29 +00:00
|
|
|
AudioRegionGainLine::start_drag_single (ControlPoint* cp, double x, float fraction)
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
2024-04-17 03:53:30 +02:00
|
|
|
RegionFxLine::start_drag_single (cp, x, fraction);
|
2010-03-02 18:05:26 +00:00
|
|
|
|
2017-07-01 18:42:24 +02:00
|
|
|
// XXX Stateful need to capture automation curve data
|
2011-06-01 17:00:29 +00:00
|
|
|
|
2024-04-17 03:53:30 +02:00
|
|
|
if (!arv.audio_region()->envelope_active()) {
|
|
|
|
|
trackview.session()->add_command(new MementoCommand<AudioRegion>(*(arv.audio_region().get()), &arv.audio_region()->get_state(), 0));
|
|
|
|
|
arv.audio_region()->set_envelope_active(false);
|
2009-10-14 16:10:01 +00:00
|
|
|
}
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
2024-04-14 19:37:09 +02:00
|
|
|
void
|
|
|
|
|
AudioRegionGainLine::start_drag_line (uint32_t i1, uint32_t i2, float fraction)
|
|
|
|
|
{
|
2024-04-17 03:53:30 +02:00
|
|
|
RegionFxLine::start_drag_line (i1, i2, fraction);
|
2024-04-14 19:37:09 +02:00
|
|
|
|
2024-04-17 03:53:30 +02:00
|
|
|
if (!arv.audio_region()->envelope_active()) {
|
|
|
|
|
trackview.session()->add_command(new MementoCommand<AudioRegion>(*(arv.audio_region().get()), &arv.audio_region()->get_state(), 0));
|
|
|
|
|
arv.audio_region()->set_envelope_active(false);
|
2024-04-14 19:37:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
AudioRegionGainLine::start_drag_multiple (list<ControlPoint*> cp, float fraction, XMLNode* state)
|
|
|
|
|
{
|
2024-04-17 03:53:30 +02:00
|
|
|
RegionFxLine::start_drag_multiple (cp, fraction, state);
|
2024-04-14 19:37:09 +02:00
|
|
|
|
2024-04-17 03:53:30 +02:00
|
|
|
if (!arv.audio_region()->envelope_active()) {
|
|
|
|
|
trackview.session()->add_command(new MementoCommand<AudioRegion>(*(arv.audio_region().get()), &arv.audio_region()->get_state(), 0));
|
|
|
|
|
arv.audio_region()->set_envelope_active(false);
|
2024-04-14 19:37:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-25 18:42:24 +00:00
|
|
|
// This is an extended copy from AutomationList
|
|
|
|
|
void
|
|
|
|
|
AudioRegionGainLine::remove_point (ControlPoint& cp)
|
|
|
|
|
{
|
2014-12-15 00:13:38 +11:00
|
|
|
trackview.editor().begin_reversible_command (_("remove control point"));
|
2007-06-29 04:02:58 +00:00
|
|
|
XMLNode &before = alist->get_state();
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2024-04-17 03:53:30 +02:00
|
|
|
if (!arv.audio_region()->envelope_active()) {
|
|
|
|
|
arv.audio_region()->clear_changes ();
|
|
|
|
|
arv.audio_region()->set_envelope_active(true);
|
|
|
|
|
trackview.session()->add_command(new PBD::StatefulDiffCommand (arv.audio_region()));
|
2009-10-14 16:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
2015-10-05 02:56:56 +11:00
|
|
|
trackview.editor ().get_selection ().clear_points ();
|
2012-04-05 16:53:55 +00:00
|
|
|
alist->erase (cp.model());
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2009-12-17 18:24:23 +00:00
|
|
|
trackview.editor().session()->add_command (new MementoCommand<AutomationList>(*alist.get(), &before, &alist->get_state()));
|
2014-12-15 00:13:38 +11:00
|
|
|
trackview.editor().commit_reversible_command ();
|
2009-12-17 18:24:23 +00:00
|
|
|
trackview.editor().session()->set_dirty ();
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2012-12-19 15:55:06 +00:00
|
|
|
AudioRegionGainLine::end_drag (bool with_push, uint32_t final_index)
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
2024-04-17 03:53:30 +02:00
|
|
|
if (!arv.audio_region()->envelope_active()) {
|
|
|
|
|
arv.audio_region()->set_envelope_active(true);
|
|
|
|
|
trackview.session()->add_command(new MementoCommand<AudioRegion>(*(arv.audio_region().get()), 0, &arv.audio_region()->get_state()));
|
2009-10-14 16:10:01 +00:00
|
|
|
}
|
2006-11-19 16:45:16 +00:00
|
|
|
|
2024-04-17 03:53:30 +02:00
|
|
|
RegionFxLine::end_drag (with_push, final_index);
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
2024-04-14 19:37:09 +02:00
|
|
|
void
|
|
|
|
|
AudioRegionGainLine::end_draw_merge ()
|
|
|
|
|
{
|
2024-08-24 00:24:28 +02:00
|
|
|
enable_automation ();
|
2024-04-17 03:53:30 +02:00
|
|
|
RegionFxLine::end_draw_merge ();
|
2024-04-14 19:37:09 +02:00
|
|
|
}
|
|
|
|
|
|
2015-04-30 22:54:18 +02:00
|
|
|
void
|
2024-08-24 00:24:28 +02:00
|
|
|
AudioRegionGainLine::enable_automation ()
|
2015-04-30 22:54:18 +02:00
|
|
|
{
|
2024-04-17 03:53:30 +02:00
|
|
|
if (!arv.audio_region()->envelope_active()) {
|
|
|
|
|
XMLNode& before = arv.audio_region()->get_state();
|
|
|
|
|
arv.audio_region()->set_envelope_active(true);
|
|
|
|
|
trackview.session()->add_command(new MementoCommand<AudioRegion>(*(arv.audio_region().get()), &before, &arv.audio_region()->get_state()));
|
2019-02-15 21:37:19 +01:00
|
|
|
}
|
2015-04-30 22:54:18 +02:00
|
|
|
}
|