#include "rhythm_ferret.h"
#include "audio_region_view.h"
-#include "public_editor.h"
+#include "editor.h"
#include "utils.h"
#include "time_axis_view.h"
0
};
-RhythmFerret::RhythmFerret (PublicEditor& e)
+RhythmFerret::RhythmFerret (Editor& e)
: ArdourDialog (_("Rhythm Ferret"))
, editor (e)
, detection_threshold_adjustment (3, 0, 20, 1, 4)
default:
break;
}
-
- }
-
- for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ++i) {
- (*i)->get_time_axis_view().show_feature_lines (current_results);
+
+ (*i)->region()->set_transients (current_results);
+ current_results.clear();
}
-
}
int
-RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readable, nframes64_t offset, AnalysisFeatureList& results)
+RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readable, framepos_t /*offset*/, AnalysisFeatureList& results)
{
TransientDetector t (_session->frame_rate());
/* translate all transients to give absolute position */
- for (AnalysisFeatureList::iterator x = these_results.begin(); x != these_results.end(); ++x) {
- (*x) += offset;
- }
+ //for (AnalysisFeatureList::iterator x = these_results.begin(); x != these_results.end(); ++x) {
+ // (*x) += offset;
+ //}
/* merge */
}
int
-RhythmFerret::run_note_onset_analysis (boost::shared_ptr<Readable> readable, nframes64_t offset, AnalysisFeatureList& results)
+RhythmFerret::run_note_onset_analysis (boost::shared_ptr<Readable> readable, framepos_t /*offset*/, AnalysisFeatureList& results)
{
try {
OnsetDetector t (_session->frame_rate());
/* translate all transients to give absolute position */
- for (AnalysisFeatureList::iterator x = these_results.begin(); x != these_results.end(); ++x) {
- (*x) += offset;
- }
+ //for (AnalysisFeatureList::iterator x = these_results.begin(); x != these_results.end(); ++x) {
+ // (*x) += offset;
+ //}
/* merge */
void
RhythmFerret::do_action ()
{
- if (!_session || current_results.empty()) {
+ if (!_session) {
return;
}
case SplitRegion:
do_split_action ();
break;
-
+ case ConformRegion:
+ editor.close_region_gaps();
+ break;
default:
break;
}
void
RhythmFerret::do_split_action ()
{
- /* this can/will change the current selection, so work with a copy */
-
RegionSelection& regions (editor.get_selection().regions);
-
+
if (regions.empty()) {
return;
}
_session->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;
+ features = (*i)->region()->transients();
+
+ merged_features.insert (merged_features.end(), features.begin(), features.end());
+ }
+
+ merged_features.sort();
+ merged_features.unique();
for (RegionSelection::iterator i = regions.begin(); i != regions.end(); ) {
tmp = i;
++tmp;
- (*i)->get_time_axis_view().hide_feature_lines ();
-
- editor.split_region_at_points ((*i)->region(), current_results, false);
+ AnalysisFeatureList features;
+ features = (*i)->region()->transients();
+ editor.split_region_at_points ((*i)->region(), merged_features, false);
/* i is invalid at this point */
current_results.clear ();
}
-static void hide_time_axis_features (TimeAxisView& tav)
-{
- tav.hide_feature_lines ();
-}
-
void
RhythmFerret::on_hide ()
{
- editor.foreach_time_axis_view (sigc::ptr_fun (hide_time_axis_features));
ArdourDialog::on_hide ();
}