diff options
Diffstat (limited to 'gtk2_ardour/rhythm_ferret.cc')
-rw-r--r-- | gtk2_ardour/rhythm_ferret.cc | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/gtk2_ardour/rhythm_ferret.cc b/gtk2_ardour/rhythm_ferret.cc index 980b36e1d1..d8d2f3c28b 100644 --- a/gtk2_ardour/rhythm_ferret.cc +++ b/gtk2_ardour/rhythm_ferret.cc @@ -13,6 +13,7 @@ #include "rhythm_ferret.h" #include "audio_region_view.h" #include "public_editor.h" +#include "utils.h" #include "i18n.h" @@ -57,9 +58,9 @@ RhythmFerret::RhythmFerret (PublicEditor& e) { upper_hpacker.set_spacing (6); - upper_hpacker.pack_start (operation_frame, true, true); - upper_hpacker.pack_start (selection_frame, true, true); upper_hpacker.pack_start (ferret_frame, true, true); + upper_hpacker.pack_start (selection_frame, true, true); + upper_hpacker.pack_start (operation_frame, true, true); op_packer.pack_start (region_split_button, false, false); op_packer.pack_start (tempo_button, false, false); @@ -107,15 +108,17 @@ RhythmFerret::RhythmFerret (PublicEditor& e) analyze_button.signal_clicked().connect (mem_fun (*this, &RhythmFerret::run_analysis)); ferret_frame.add (ferret_packer); - - // Glib::RefPtr<Pixbuf> logo_pixbuf ("somefile"); + logo = manage (new Gtk::Image (::get_icon (X_("ferret_02")))); + if (logo) { lower_hpacker.pack_start (*logo, false, false); } - lower_hpacker.pack_start (operation_clarification_label, false, false); + lower_hpacker.pack_start (operation_clarification_label, true, true); lower_hpacker.pack_start (action_button, false, false); + lower_hpacker.set_border_width (6); + lower_hpacker.set_spacing (6); action_button.signal_clicked().connect (mem_fun (*this, &RhythmFerret::do_action)); @@ -194,13 +197,13 @@ RhythmFerret::run_analysis () } int -RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readable, nframes64_t offset, vector<nframes64_t>& results) +RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readable, nframes64_t offset, AnalysisFeatureList& results) { TransientDetector t (session->frame_rate()); for (uint32_t i = 0; i < readable->n_channels(); ++i) { - vector<nframes64_t> these_results; + AnalysisFeatureList these_results; t.reset (); t.set_threshold (detection_threshold_adjustment.get_value()); @@ -212,38 +215,18 @@ RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readabl /* translate all transients to give absolute position */ - for (vector<nframes64_t>::iterator i = these_results.begin(); i != these_results.end(); ++i) { - (*i) += offset; + for (AnalysisFeatureList::iterator x = these_results.begin(); x != these_results.end(); ++x) { + (*x) += offset; } /* merge */ results.insert (results.end(), these_results.begin(), these_results.end()); + these_results.clear (); } - - if (!results.empty()) { - - /* now resort to bring transients from different channels together */ - - sort (results.begin(), results.end()); - - /* remove duplicates or other things that are too close */ - - vector<nframes64_t>::iterator i = results.begin(); - nframes64_t curr = (*i); - nframes64_t gap_frames = (nframes64_t) floor (trigger_gap_adjustment.get_value() * (session->frame_rate() / 1000.0)); - - ++i; - - while (i != results.end()) { - if (((*i) == curr) || (((*i) - curr) < gap_frames)) { - i = results.erase (i); - } else { - ++i; - curr = *i; - } - } + if (!results.empty()) { + TransientDetector::cleanup_transients (results, session->frame_rate(), trigger_gap_adjustment.get_value()); } return 0; |