Patch from Lincoln to fix rhythm ferret in various ways (#3715).
[ardour.git] / gtk2_ardour / rhythm_ferret.h
1 #ifndef __gtk2_ardour_rhythm_ferret_h__
2 #define __gtk2_ardour_rhythm_ferret_h__
3
4 #include <gtkmm/box.h>
5 #include <gtkmm/scale.h>
6 #include <gtkmm/spinbutton.h>
7 #include <gtkmm/radiobutton.h>
8 #include <gtkmm/radiobuttongroup.h>
9 #include <gtkmm/frame.h>
10 #include <gtkmm/image.h>
11 #include <gtkmm/comboboxtext.h>
12 #include <gtkmm/button.h>
13
14 #include "ardour_dialog.h"
15 #include "region_selection.h"
16
17 namespace ARDOUR {
18         class Readable;
19 }
20
21 class Editor;
22 class RegionView;
23
24 class RhythmFerret : public ArdourDialog {
25   public:
26         /* order of these enums must match the _analyse_mode_strings
27            in rhythm_ferret.cc
28         */
29         enum AnalysisMode {
30                 PercussionOnset,
31                 NoteOnset
32         };
33
34         enum Action {
35                 SplitRegion,
36                 SnapRegionsToGrid,
37                 ConformRegion
38         };
39
40         RhythmFerret (Editor&);
41
42         void set_session (ARDOUR::Session*);
43
44   protected:
45         void on_hide ();
46
47   private:
48         Editor& editor;
49
50         Gtk::ComboBoxText operation_selector;
51
52         Gtk::ComboBoxText analysis_mode_selector;
53
54         /* transient detection widgets */
55
56         Gtk::Adjustment detection_threshold_adjustment;
57         Gtk::HScale detection_threshold_scale;
58         Gtk::Adjustment sensitivity_adjustment;
59         Gtk::HScale sensitivity_scale;
60         Gtk::Button analyze_button;
61
62         /* onset detection widgets */
63
64         Gtk::ComboBoxText onset_detection_function_selector;
65         Gtk::Adjustment peak_picker_threshold_adjustment;
66         Gtk::HScale peak_picker_threshold_scale;
67         Gtk::Adjustment silence_threshold_adjustment;
68         Gtk::HScale silence_threshold_scale;
69
70         /* generic stuff */
71
72         Gtk::Adjustment trigger_gap_adjustment;
73         Gtk::SpinButton trigger_gap_spinner;
74
75         Gtk::Button action_button;
76
77         std::vector<std::string> analysis_mode_strings;
78         std::vector<std::string> onset_function_strings;
79         std::vector<std::string> operation_strings;
80
81         ARDOUR::AnalysisFeatureList current_results;
82
83         void clear_transients ();
84         /** Regions that we have added transient marks to */
85         RegionSelection regions_with_transients;
86
87         AnalysisMode get_analysis_mode () const;
88         Action get_action() const;
89         void analysis_mode_changed ();
90         int get_note_onset_function ();
91
92         void run_analysis ();
93         int run_percussion_onset_analysis (boost::shared_ptr<ARDOUR::Readable> region, ARDOUR::frameoffset_t offset, ARDOUR::AnalysisFeatureList& results);
94         int run_note_onset_analysis (boost::shared_ptr<ARDOUR::Readable> region, ARDOUR::frameoffset_t offset, ARDOUR::AnalysisFeatureList& results);
95
96         void do_action ();
97         void do_split_action ();
98         void do_region_split (RegionView* rv, const ARDOUR::AnalysisFeatureList&);
99 };
100
101 #endif /* __gtk2_ardour_rhythm_ferret_h__ */