summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-12-26 16:19:32 +0000
committerCarl Hetherington <carl@carlh.net>2010-12-26 16:19:32 +0000
commitfd0c45ec9745c5330fbb732581ec22ba9a31a3c0 (patch)
tree872df0ae0ba2b1b725890f4919d4be110aac395c
parentbc29adf05493ff2503b230604b237b75eb7af7fa (diff)
Use the channel selector to decide which channel to add program changes to.
git-svn-id: svn://localhost/ardour2/branches/3.0@8343 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/editor_ops.cc2
-rw-r--r--gtk2_ardour/midi_region_view.cc57
-rw-r--r--gtk2_ardour/midi_region_view.h4
-rw-r--r--gtk2_ardour/program_change_dialog.cc19
-rw-r--r--gtk2_ardour/program_change_dialog.h2
5 files changed, 39 insertions, 45 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index 6c5c250fa3..b70636f58b 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -4724,7 +4724,7 @@ Editor::insert_program_change ()
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 ());
+ mrv->add_program_change (p - mrv->region()->position(), d.program ());
}
}
}
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 227587d5a0..dced1cd3a8 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -58,7 +58,6 @@
#include "midi_region_view.h"
#include "midi_streamview.h"
#include "midi_time_axis.h"
-#include "midi_time_axis.h"
#include "midi_util.h"
#include "note_player.h"
#include "public_editor.h"
@@ -726,7 +725,7 @@ MidiRegionView::create_note_at(double x, double y, double length, bool sh)
MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
MidiStreamView* const view = mtv->midi_view();
- double note = midi_stream_view()->y_to_note(y);
+ double note = view->y_to_note(y);
assert(note >= 0.0);
assert(note <= 127.0);
@@ -745,26 +744,7 @@ MidiRegionView::create_note_at(double x, double y, double length, bool sh)
length = frames_to_beats (beats_to_frames (length) - 1);
}
- uint16_t chn_mask = mtv->channel_selector().get_selected_channels();
- int chn_cnt = 0;
- uint8_t channel = 0;
-
- /* pick the highest selected channel, unless all channels are selected,
- which is interpreted to mean channel 1 (zero)
- */
-
- for (uint16_t i = 0; i < 16; ++i) {
- if (chn_mask & (1<<i)) {
- channel = i;
- chn_cnt++;
- }
- }
-
- if (chn_cnt == 16) {
- channel = 0;
- }
-
- const boost::shared_ptr<NoteType> new_note (new NoteType (channel,
+ const boost::shared_ptr<NoteType> new_note (new NoteType (get_channel_for_add (),
frames_to_beats(start_frames + _region->start()), length,
(uint8_t)note, 0x40));
@@ -1670,10 +1650,10 @@ MidiRegionView::alter_program_change(PCEvent& old_program, const MIDI::Name::Pat
/** @param t Time in frames relative to region position */
void
-MidiRegionView::add_program_change (framecnt_t t, uint8_t channel, uint8_t value)
+MidiRegionView::add_program_change (framecnt_t t, uint8_t value)
{
boost::shared_ptr<Evoral::Control> control = midi_region()->model()->control (
- Evoral::Parameter (MidiPgmChangeAutomation, channel, 0), true
+ Evoral::Parameter (MidiPgmChangeAutomation, get_channel_for_add (), 0), true
);
assert (control);
@@ -3294,3 +3274,32 @@ MidiRegionView::trim_front_ending ()
midi_region()->fix_negative_start ();
}
}
+
+/** @return channel (counted from 0) to add an event to, based on the current setting
+ * of the channel selector.
+ */
+uint8_t
+MidiRegionView::get_channel_for_add () const
+{
+ MidiTimeAxisView* const mtv = dynamic_cast<MidiTimeAxisView*>(&trackview);
+ uint16_t const chn_mask = mtv->channel_selector().get_selected_channels();
+ int chn_cnt = 0;
+ uint8_t channel = 0;
+
+ /* pick the highest selected channel, unless all channels are selected,
+ which is interpreted to mean channel 1 (zero)
+ */
+
+ for (uint16_t i = 0; i < 16; ++i) {
+ if (chn_mask & (1<<i)) {
+ channel = i;
+ chn_cnt++;
+ }
+ }
+
+ if (chn_cnt == 16) {
+ channel = 0;
+ }
+
+ return channel;
+}
diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h
index 4bfaebbf13..ed8e382c4f 100644
--- a/gtk2_ardour/midi_region_view.h
+++ b/gtk2_ardour/midi_region_view.h
@@ -149,7 +149,7 @@ class MidiRegionView : public RegionView
*/
void alter_program_change(PCEvent& old_program, const MIDI::Name::PatchPrimaryKey& new_patch);
- void add_program_change (framecnt_t, uint8_t, uint8_t);
+ void add_program_change (framecnt_t, uint8_t);
void move_program_change (PCEvent, Evoral::MusicalTime);
void delete_program_change (ArdourCanvas::CanvasProgramChange *);
@@ -346,6 +346,8 @@ class MidiRegionView : public RegionView
void add_to_selection (ArdourCanvas::CanvasNoteEvent*);
void remove_from_selection (ArdourCanvas::CanvasNoteEvent*);
+ uint8_t get_channel_for_add () const;
+
int8_t _force_channel;
uint16_t _last_channel_selection;
uint8_t _current_range_min;
diff --git a/gtk2_ardour/program_change_dialog.cc b/gtk2_ardour/program_change_dialog.cc
index 75bb8aeca1..f333447f4a 100644
--- a/gtk2_ardour/program_change_dialog.cc
+++ b/gtk2_ardour/program_change_dialog.cc
@@ -26,19 +26,11 @@ 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);
+ Table* t = manage (new Table (1, 2));
- 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")));
+ Label* 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);
@@ -52,13 +44,6 @@ ProgramChangeDialog::ProgramChangeDialog ()
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
diff --git a/gtk2_ardour/program_change_dialog.h b/gtk2_ardour/program_change_dialog.h
index 05345e06b5..9da36ad6ed 100644
--- a/gtk2_ardour/program_change_dialog.h
+++ b/gtk2_ardour/program_change_dialog.h
@@ -26,10 +26,8 @@ class ProgramChangeDialog : public ArdourDialog
public:
ProgramChangeDialog ();
- uint8_t channel () const;
uint8_t program () const;
private:
- Gtk::SpinButton _channel;
Gtk::SpinButton _program;
};