Introduce "Transpose..." also in the context menu of selected notes.
authorAndré Nusser <andre.nusser@googlemail.com>
Thu, 15 Oct 2015 13:44:09 +0000 (15:44 +0200)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 18 Oct 2015 02:12:55 +0000 (22:12 -0400)
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_ops.cc

index 9ed69351d5c2d19374853c1ef92e81f342f8003a..538203644f8e54a6128d862e05255b2de16e05ee 100644 (file)
@@ -5959,6 +5959,8 @@ Editor::popup_note_context_menu (ArdourCanvas::Item* item, GdkEvent* event)
                                 sigc::mem_fun(mrv, &MidiRegionView::delete_selection)));
        items.push_back(MenuElem(_("Edit..."),
                                 sigc::bind(sigc::mem_fun(*this, &Editor::edit_notes), &mrv)));
+       items.push_back(MenuElem(_("Transpose..."),
+                                sigc::bind(sigc::mem_fun(*this, &Editor::transpose_regions), rs)));
        items.push_back(MenuElem(_("Legatize"),
                                 sigc::bind(sigc::mem_fun(*this, &Editor::legatize_regions), rs, false)));
        items.push_back(MenuElem(_("Quantize..."),
index f558355bb05a86de42e29b63e0c2508dd4a0182f..be018d6b9b03f9d430732d97db4d406402fe5628 100644 (file)
@@ -1258,6 +1258,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void legatize_regions (const RegionSelection& rs, bool shrink_only);
        void transform_region ();
        void transform_regions (const RegionSelection& rs);
+       void transpose_region ();
+       void transpose_regions (const RegionSelection& rs);
        void insert_patch_change (bool from_context);
        void fork_region ();
 
@@ -2029,8 +2031,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        int pitch_shift (RegionSelection&, float cents);
        void pitch_shift_region ();
 
-       void transpose_region ();
-
        /* editor-mixer strip */
 
        MixerStrip *current_mixer_strip;
index bfd7b1449233b95ceb22d13e0f3a306a479fcc89..2d718284d28aaed31d8582feb3996b63ea6f9eaf 100644 (file)
@@ -57,6 +57,7 @@
 #include "ardour/session_playlists.h"
 #include "ardour/strip_silence.h"
 #include "ardour/transient_detector.h"
+#include "ardour/transpose.h"
 
 #include "canvas/canvas.h"
 
@@ -5353,6 +5354,30 @@ Editor::transform_regions (const RegionSelection& rs)
        }
 }
 
+void
+Editor::transpose_region ()
+{
+       if (_session) {
+               transpose_regions(get_regions_from_selection_and_entered ());
+       }
+}
+
+void
+Editor::transpose_regions (const RegionSelection& rs)
+{
+       if (rs.n_midi_regions() == 0) {
+               return;
+       }
+
+       TransposeDialog d;
+       int const r = d.run ();
+
+       if (r == RESPONSE_ACCEPT) {
+               Transpose transpose(d.semitones ());
+               apply_midi_note_edit_op (transpose, rs);
+       }
+}
+
 void
 Editor::insert_patch_change (bool from_context)
 {
@@ -6425,30 +6450,6 @@ Editor::pitch_shift_region ()
        pitch_shift (audio_rs, 1.2);
 }
 
-void
-Editor::transpose_region ()
-{
-       RegionSelection rs = get_regions_from_selection_and_entered ();
-
-       list<MidiRegionView*> midi_region_views;
-       for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) {
-               MidiRegionView* mrv = dynamic_cast<MidiRegionView*> (*i);
-               if (mrv) {
-                       midi_region_views.push_back (mrv);
-               }
-       }
-
-       TransposeDialog d;
-       int const r = d.run ();
-       if (r != RESPONSE_ACCEPT) {
-               return;
-       }
-
-       for (list<MidiRegionView*>::iterator i = midi_region_views.begin(); i != midi_region_views.end(); ++i) {
-               (*i)->midi_region()->transpose (d.semitones ());
-       }
-}
-
 void
 Editor::set_tempo_from_region ()
 {