Remove internal edit mode and add "content" tool.
[ardour.git] / gtk2_ardour / rhythm_ferret.cc
index 8845a29313d2a211d483f9bb77ad90a5a0651eae..e257f56b52479fa15039c2ceb796e91b4c1f0f8d 100644 (file)
@@ -1,21 +1,36 @@
+/*
+    Copyright (C) 2012 Paul Davis 
+
+    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 <gtkmm2ext/utils.h>
 
 #include "pbd/memento_command.h"
 #include "pbd/convert.h"
 
-#include "ardour/transient_detector.h"
-#include "ardour/onset_detector.h"
-#include "ardour/audiosource.h"
 #include "ardour/audioregion.h"
-#include "ardour/playlist.h"
-#include "ardour/region_factory.h"
+#include "ardour/onset_detector.h"
 #include "ardour/session.h"
+#include "ardour/transient_detector.h"
 
 #include "rhythm_ferret.h"
 #include "audio_region_view.h"
 #include "editor.h"
-#include "utils.h"
 #include "time_axis_view.h"
 
 #include "i18n.h"
@@ -113,7 +128,7 @@ RhythmFerret::RhythmFerret (Editor& e)
        t->attach (peak_picker_threshold_scale, 1, 2, n, n + 1, FILL);
        t->attach (*manage (new Label (_("dB"))), 2, 3, n, n + 1, FILL);
        ++n;
-       
+
        t->attach (*manage (new Label (_("Silence threshold"), 1, 0.5)), 0, 1, n, n + 1, FILL);
        t->attach (silence_threshold_scale, 1, 2, n, n + 1, FILL);
        t->attach (*manage (new Label (_("dB"))), 2, 3, n, n + 1, FILL);
@@ -145,7 +160,7 @@ void
 RhythmFerret::analysis_mode_changed ()
 {
        bool const perc = get_analysis_mode() == PercussionOnset;
-       
+
        trigger_gap_spinner.set_sensitive (!perc);
        detection_threshold_scale.set_sensitive (perc);
        sensitivity_scale.set_sensitive (perc);
@@ -209,14 +224,14 @@ RhythmFerret::run_analysis ()
                default:
                        break;
                }
-               
+
                (*i)->region()->set_transients (current_results);
                current_results.clear();
        }
 }
 
 int
-RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readable, framepos_t /*offset*/, AnalysisFeatureList& results)
+RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readable, frameoffset_t /*offset*/, AnalysisFeatureList& results)
 {
        TransientDetector t (_session->frame_rate());
 
@@ -236,7 +251,7 @@ RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readabl
 
                results.insert (results.end(), these_results.begin(), these_results.end());
                these_results.clear ();
-               
+
                t.update_positions (readable.get(), i, results);
        }
 
@@ -254,16 +269,16 @@ RhythmFerret::get_note_onset_function ()
                        return n;
                }
        }
-       
+
        fatal << string_compose (_("programming error: %1 (%2)"), X_("illegal note onset function string"), txt)
              << endmsg;
-       
-       /*NOTREACHED*/
+
+       abort(); /*NOTREACHED*/
        return -1;
 }
 
 int
-RhythmFerret::run_note_onset_analysis (boost::shared_ptr<Readable> readable, framepos_t /*offset*/, AnalysisFeatureList& results)
+RhythmFerret::run_note_onset_analysis (boost::shared_ptr<Readable> readable, frameoffset_t /*offset*/, AnalysisFeatureList& results)
 {
        try {
                OnsetDetector t (_session->frame_rate());
@@ -329,19 +344,19 @@ RhythmFerret::do_split_action ()
           performed on the selection only (without entered_regionview or the edit point
           being considered)
        */
-       RegionSelection regions = editor.get_regions_from_selection();
-       
+       RegionSelection regions = editor.selection->regions;
+
        if (regions.empty()) {
                return;
        }
-       
+
        editor.EditorFreeze(); /* Emit signal */
 
-       _session->begin_reversible_command (_("split regions (rhythm ferret)"));
-       
+       editor.begin_reversible_command (_("split regions (rhythm ferret)"));
+
        /* Merge the transient positions for regions in consideration */
        AnalysisFeatureList merged_features;
-       
+
        for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
 
                AnalysisFeatureList features;
@@ -366,8 +381,8 @@ RhythmFerret::do_split_action ()
                i = tmp;
        }
 
-       _session->commit_reversible_command ();
-       
+       editor.commit_reversible_command ();
+
        editor.EditorThaw(); /* Emit signal */
 }
 
@@ -390,11 +405,11 @@ void
 RhythmFerret::clear_transients ()
 {
        current_results.clear ();
-       
+
        for (RegionSelection::iterator i = regions_with_transients.begin(); i != regions_with_transients.end(); ++i) {
                (*i)->region()->set_transients (current_results);
        }
-       
+
        regions_with_transients.clear ();
 }