2005-09-25 18:42:24 +00:00
|
|
|
/*
|
2009-10-14 16:10:01 +00:00
|
|
|
Copyright (C) 2001 Paul Davis
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
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"
|
2006-11-13 00:50:28 +00:00
|
|
|
|
2009-10-30 15:30:22 +00:00
|
|
|
#include "ardour/session.h"
|
2009-02-25 18:26:51 +00:00
|
|
|
#include "ardour/audioregion.h"
|
|
|
|
|
#include "ardour/playlist.h"
|
|
|
|
|
#include "ardour/utils.h"
|
2009-10-23 23:21:55 +00:00
|
|
|
#include "ardour/dB.h"
|
2005-09-25 20:33:00 +00:00
|
|
|
#include <gtkmm2ext/utils.h>
|
2005-09-25 18:42:24 +00:00
|
|
|
#include <cmath>
|
|
|
|
|
|
2006-08-01 03:23:35 +00:00
|
|
|
#include "audio_region_editor.h"
|
|
|
|
|
#include "audio_region_view.h"
|
2005-09-25 18:42:24 +00:00
|
|
|
#include "ardour_ui.h"
|
|
|
|
|
#include "utils.h"
|
2006-01-03 14:16:27 +00:00
|
|
|
#include "gui_thread.h"
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2006-06-21 23:01:03 +00:00
|
|
|
using namespace PBD;
|
2005-09-25 18:42:24 +00:00
|
|
|
using namespace std;
|
2007-03-18 16:45:43 +00:00
|
|
|
using namespace Gtkmm2ext;
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2010-05-22 00:26:26 +00:00
|
|
|
AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr<AudioRegion> r)
|
|
|
|
|
: RegionEditor (s, r)
|
|
|
|
|
, _audio_region (r)
|
|
|
|
|
, gain_adjustment(accurate_coefficient_to_dB(_audio_region->scale_amplitude()), -40.0, +40.0, 0.1, 1.0, 0)
|
2005-09-25 18:42:24 +00:00
|
|
|
|
|
|
|
|
{
|
2010-04-24 00:29:28 +00:00
|
|
|
gain_label.set_alignment (1, 0.5);
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2010-04-24 00:29:28 +00:00
|
|
|
Gtk::HBox* gb = Gtk::manage (new Gtk::HBox);
|
|
|
|
|
gb->set_spacing (6);
|
|
|
|
|
gb->pack_start (gain_entry);
|
|
|
|
|
gb->pack_start (*Gtk::manage (new Gtk::Label (_("dB"))), false, false);
|
2008-12-12 14:43:24 +00:00
|
|
|
|
2009-10-23 23:21:55 +00:00
|
|
|
gain_label.set_name ("AudioRegionEditorLabel");
|
2010-04-24 00:29:28 +00:00
|
|
|
gain_label.set_text (_("Region gain:"));
|
2009-10-23 23:21:55 +00:00
|
|
|
gain_entry.configure (gain_adjustment, 0.0, 1);
|
2010-10-27 21:18:44 +00:00
|
|
|
_table.attach (gain_label, 0, 1, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL);
|
|
|
|
|
_table.attach (*gb, 1, 2, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL);
|
2010-02-19 18:09:08 +00:00
|
|
|
|
2009-10-23 23:21:55 +00:00
|
|
|
gain_changed ();
|
2005-09-25 18:42:24 +00:00
|
|
|
|
2010-05-22 00:26:26 +00:00
|
|
|
gain_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &AudioRegionEditor::gain_adjustment_changed));
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2010-02-19 18:09:08 +00:00
|
|
|
AudioRegionEditor::region_changed (const PBD::PropertyChange& what_changed)
|
2005-09-25 18:42:24 +00:00
|
|
|
{
|
2010-05-22 00:26:26 +00:00
|
|
|
RegionEditor::region_changed (what_changed);
|
|
|
|
|
|
2010-02-19 18:09:08 +00:00
|
|
|
if (what_changed.contains (ARDOUR::Properties::scale_amplitude)) {
|
2009-10-23 23:21:55 +00:00
|
|
|
gain_changed ();
|
|
|
|
|
}
|
2005-09-25 18:42:24 +00:00
|
|
|
}
|
2009-10-23 23:21:55 +00:00
|
|
|
void
|
|
|
|
|
AudioRegionEditor::gain_changed ()
|
|
|
|
|
{
|
2010-05-22 00:26:26 +00:00
|
|
|
float const region_gain_dB = accurate_coefficient_to_dB (_audio_region->scale_amplitude());
|
2009-10-23 23:21:55 +00:00
|
|
|
if (region_gain_dB != gain_adjustment.get_value()) {
|
|
|
|
|
gain_adjustment.set_value(region_gain_dB);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
AudioRegionEditor::gain_adjustment_changed ()
|
|
|
|
|
{
|
|
|
|
|
float const gain = dB_to_coefficient (gain_adjustment.get_value());
|
2010-05-22 00:26:26 +00:00
|
|
|
if (_audio_region->scale_amplitude() != gain) {
|
|
|
|
|
_audio_region->set_scale_amplitude (gain);
|
2009-10-23 23:21:55 +00:00
|
|
|
}
|
|
|
|
|
}
|