summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-12-22 23:45:04 +0000
committerCarl Hetherington <carl@carlh.net>2010-12-22 23:45:04 +0000
commit818f2cffd7b7c95319eb5728b2e519cd96c62dc4 (patch)
treefcb1fbc9641fa71e3deaf93e69d4bb07afec0411 /gtk2_ardour
parent95bb346926e237b903059c83a70e58ed9253eaca (diff)
Add menu option to insert program changes.
git-svn-id: svn://localhost/ardour2/branches/3.0@8330 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/ardour.menus.in2
-rw-r--r--gtk2_ardour/editor.h1
-rw-r--r--gtk2_ardour/editor_actions.cc1
-rw-r--r--gtk2_ardour/editor_drag.cc2
-rw-r--r--gtk2_ardour/editor_ops.cc26
-rw-r--r--gtk2_ardour/midi_region_view.cc26
-rw-r--r--gtk2_ardour/midi_region_view.h5
-rw-r--r--gtk2_ardour/program_change_dialog.cc67
-rw-r--r--gtk2_ardour/program_change_dialog.h35
-rw-r--r--gtk2_ardour/wscript1
10 files changed, 160 insertions, 6 deletions
diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in
index e7d8eff8f1..ffbdfcc131 100644
--- a/gtk2_ardour/ardour.menus.in
+++ b/gtk2_ardour/ardour.menus.in
@@ -258,6 +258,7 @@
<menuitem action='lower-region-to-bottom'/>
</menu>
<menu action='RegionMenuMIDI'>
+ <menuitem action='insert-program-change'/>
<menuitem action='quantize-region'/>
<menuitem action='fork-region'/>
<menuitem action='show-region-list-editor'/>
@@ -592,6 +593,7 @@
<menuitem action='lower-region-to-bottom'/>
</menu>
<menu action='RegionMenuMIDI'>
+ <menuitem action='insert-program-change'/>
<menuitem action='quantize-region'/>
<menuitem action='fork-region'/>
<menuitem action='show-region-list-editor'/>
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 0b90c16e0d..57bfd5205b 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -1090,6 +1090,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void reset_region_scale_amplitude ();
void adjust_region_gain (bool up);
void quantize_region ();
+ void insert_program_change ();
void fork_region ();
void do_insert_time ();
diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc
index 2458e0234e..e88f5c9c31 100644
--- a/gtk2_ardour/editor_actions.cc
+++ b/gtk2_ardour/editor_actions.cc
@@ -1469,6 +1469,7 @@ Editor::register_region_actions ()
);
reg_sens (_region_actions, "quantize-region", _("Quantize"), sigc::mem_fun (*this, &Editor::quantize_region));
+ reg_sens (_region_actions, "insert-program-change", _("Insert Program Change..."), sigc::mem_fun (*this, &Editor::insert_program_change));
reg_sens (_region_actions, "fork-region", _("Fork"), sigc::mem_fun (*this, &Editor::fork_region));
reg_sens (_region_actions, "strip-region-silence", _("Strip Silence..."), sigc::mem_fun (*this, &Editor::strip_region_silence));
reg_sens (_region_actions, "set-selection-from-region", _("Set Range Selection"), sigc::mem_fun (*this, &Editor::set_selection_from_region));
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 7f87ae0273..67367e8b65 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -1776,6 +1776,8 @@ TrimDrag::setup_pointer_frame_offset ()
case EndTrim:
_pointer_frame_offset = raw_grab_frame() - i->initial_end;
break;
+ case ContentsTrim:
+ break;
}
}
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index fa096dc42b..6c5c250fa3 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -84,6 +84,7 @@
#include "normalize_dialog.h"
#include "editor_cursors.h"
#include "mouse_cursors.h"
+#include "program_change_dialog.h"
#include "i18n.h"
@@ -4705,6 +4706,31 @@ Editor::quantize_region ()
}
void
+Editor::insert_program_change ()
+{
+ RegionSelection rs = get_regions_from_selection_and_entered ();
+ if (rs.empty ()) {
+ return;
+ }
+
+ ProgramChangeDialog d;
+ if (d.run() == RESPONSE_CANCEL) {
+ return;
+ }
+
+ framepos_t const p = get_preferred_edit_position (false);
+
+ for (RegionSelection::iterator i = rs.begin (); i != rs.end(); ++i) {
+ MidiRegionView* const mrv = dynamic_cast<MidiRegionView*> (*i);
+ if (mrv) {
+ if (p >= mrv->region()->first_frame() && p <= mrv->region()->last_frame()) {
+ mrv->add_program_change (p - mrv->region()->position(), d.channel (), d.program ());
+ }
+ }
+ }
+}
+
+void
Editor::apply_filter (Filter& filter, string command, ProgressReporter* progress)
{
RegionSelection rs = get_regions_from_selection_and_entered ();
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 8ceb31afc9..227587d5a0 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -1111,12 +1111,12 @@ MidiRegionView::display_program_changes_on_channel(uint8_t channel)
PCEvent program_change(event_time, uint8_t(program_number), channel);
if (patch != 0) {
- add_pgm_change(program_change, patch->name());
+ add_canvas_program_change (program_change, patch->name());
} else {
char buf[4];
// program_number is zero-based: convert to one-based
snprintf(buf, 4, "%d", int(program_number+1));
- add_pgm_change(program_change, buf);
+ add_canvas_program_change (program_change, buf);
}
}
}
@@ -1583,7 +1583,7 @@ MidiRegionView::step_sustain (Evoral::MusicalTime beats)
}
void
-MidiRegionView::add_pgm_change(PCEvent& program, const string& displaytext)
+MidiRegionView::add_canvas_program_change (PCEvent& program, const string& displaytext)
{
assert(program.time >= 0);
@@ -1668,8 +1668,26 @@ MidiRegionView::alter_program_change(PCEvent& old_program, const MIDI::Name::Pat
display_program_changes (); // XXX would be nice to limit to just old_program.channel
}
+/** @param t Time in frames relative to region position */
void
-MidiRegionView::move_program_change (PCEvent pc, double t)
+MidiRegionView::add_program_change (framecnt_t t, uint8_t channel, uint8_t value)
+{
+ boost::shared_ptr<Evoral::Control> control = midi_region()->model()->control (
+ Evoral::Parameter (MidiPgmChangeAutomation, channel, 0), true
+ );
+
+ assert (control);
+
+ Evoral::MusicalTime const b = frames_to_beats (t + midi_region()->start());
+
+ control->list()->add (b, value);
+
+ _pgm_changes.clear ();
+ display_program_changes ();
+}
+
+void
+MidiRegionView::move_program_change (PCEvent pc, Evoral::MusicalTime t)
{
boost::shared_ptr<Evoral::Control> control = _model->control (Evoral::Parameter (MidiPgmChangeAutomation, pc.channel, 0));
assert (control);
diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h
index 781ef35036..4bfaebbf13 100644
--- a/gtk2_ardour/midi_region_view.h
+++ b/gtk2_ardour/midi_region_view.h
@@ -133,7 +133,7 @@ class MidiRegionView : public RegionView
* @param program the MidiRegionView::PCEvent to add
* @param the text to display in the flag
*/
- void add_pgm_change(PCEvent& program, const std::string& displaytext);
+ void add_canvas_program_change (PCEvent& program, const std::string& displaytext);
/** Look up the given time and channel in the 'automation' and set keys accordingly.
* @param time the time of the program change event
@@ -149,7 +149,8 @@ class MidiRegionView : public RegionView
*/
void alter_program_change(PCEvent& old_program, const MIDI::Name::PatchPrimaryKey& new_patch);
- void move_program_change (PCEvent, double);
+ void add_program_change (framecnt_t, uint8_t, uint8_t);
+ void move_program_change (PCEvent, Evoral::MusicalTime);
void delete_program_change (ArdourCanvas::CanvasProgramChange *);
/** Alter a given program to the new given one.
diff --git a/gtk2_ardour/program_change_dialog.cc b/gtk2_ardour/program_change_dialog.cc
new file mode 100644
index 0000000000..75bb8aeca1
--- /dev/null
+++ b/gtk2_ardour/program_change_dialog.cc
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2010 Paul Davis
+ Author: Carl Hetherington <cth@carlh.net>
+
+ 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/stock.h>
+#include <gtkmm/table.h>
+#include "program_change_dialog.h"
+
+using namespace Gtk;
+
+ProgramChangeDialog::ProgramChangeDialog ()
+ : ArdourDialog (_("Add Program Change"), true)
+ , _channel (*manage (new Adjustment (1, 1, 16, 1, 2)))
+ , _program (*manage (new Adjustment (1, 1, 128, 1, 16)))
+{
+ Table* t = manage (new Table (2, 2));
+ t->set_spacings (6);
+
+ Label* l = manage (new Label (_("Channel")));
+ l->set_alignment (0, 0.5);
+ t->attach (*l, 0, 1, 0, 1);
+
+ t->attach (_channel, 1, 2, 0, 1);
+
+ l = manage (new Label (_("Program")));
+ l->set_alignment (0, 0.5);
+ t->attach (*l, 0, 1, 1, 2);
+ t->attach (_program, 1, 2, 1, 2);
+
+ get_vbox()->add (*t);
+
+ add_button (Stock::CANCEL, RESPONSE_CANCEL);
+ add_button (Stock::ADD, RESPONSE_ACCEPT);
+ set_default_response (RESPONSE_ACCEPT);
+
+ show_all ();
+}
+
+/** @return Channel, counted from 0 */
+uint8_t
+ProgramChangeDialog::channel () const
+{
+ return _channel.get_value_as_int () - 1;
+}
+
+/** @return Program change number, counted from 0 */
+uint8_t
+ProgramChangeDialog::program () const
+{
+ return _program.get_value_as_int () - 1;
+}
diff --git a/gtk2_ardour/program_change_dialog.h b/gtk2_ardour/program_change_dialog.h
new file mode 100644
index 0000000000..05345e06b5
--- /dev/null
+++ b/gtk2_ardour/program_change_dialog.h
@@ -0,0 +1,35 @@
+/*
+ Copyright (C) 2010 Paul Davis
+ Author: Carl Hetherington <cth@carlh.net>
+
+ 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/spinbutton.h>
+#include "ardour_dialog.h"
+
+class ProgramChangeDialog : public ArdourDialog
+{
+public:
+ ProgramChangeDialog ();
+
+ uint8_t channel () const;
+ uint8_t program () const;
+
+private:
+ Gtk::SpinButton _channel;
+ Gtk::SpinButton _program;
+};
diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript
index ae673f06d6..8b71a1fdd2 100644
--- a/gtk2_ardour/wscript
+++ b/gtk2_ardour/wscript
@@ -173,6 +173,7 @@ gtk2_ardour_sources = [
'port_matrix_labels.cc',
'port_matrix_row_labels.cc',
'processor_box.cc',
+ 'program_change_dialog.cc',
'progress_reporter.cc',
'prompter.cc',
'public_editor.cc',