summaryrefslogtreecommitdiff
path: root/gtk2_ardour/rhythm_ferret.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-02-02 17:22:04 +0000
committerDavid Robillard <d@drobilla.net>2008-02-02 17:22:04 +0000
commit80c3677c837cc9eb432df3d65a34aba543fa7258 (patch)
treeca23bb7e5bff6c35c151d73221002a9ce3abfe1a /gtk2_ardour/rhythm_ferret.cc
parent9f63ab9931e6478472853bdda58da47ea29ac125 (diff)
Merge with 2.0-ongoing R2988
git-svn-id: svn://localhost/ardour2/branches/3.0@2991 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/rhythm_ferret.cc')
-rw-r--r--gtk2_ardour/rhythm_ferret.cc47
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;