mp4chaps Lua script: don't clutter global environment
[ardour.git] / gtk2_ardour / rhythm_ferret.h
1 /*
2     Copyright (C) 2012 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __gtk2_ardour_rhythm_ferret_h__
21 #define __gtk2_ardour_rhythm_ferret_h__
22
23 #include <gtkmm/box.h>
24 #include <gtkmm/scale.h>
25 #include <gtkmm/spinbutton.h>
26 #include <gtkmm/radiobutton.h>
27 #include <gtkmm/radiobuttongroup.h>
28 #include <gtkmm/frame.h>
29 #include <gtkmm/image.h>
30 #include <gtkmm/comboboxtext.h>
31 #include <gtkmm/button.h>
32
33 #include "ardour_dialog.h"
34 #include "region_selection.h"
35
36 namespace ARDOUR {
37         class Readable;
38 }
39
40 class Editor;
41 class RegionView;
42
43 class RhythmFerret : public ArdourDialog
44 {
45 public:
46         /* order of these enums must match the _analyse_mode_strings
47          * in rhythm_ferret.cc
48          */
49         enum AnalysisMode {
50                 PercussionOnset,
51                 NoteOnset
52         };
53
54         enum Action {
55                 SplitRegion,
56                 SnapRegionsToGrid,
57                 ConformRegion
58         };
59
60         RhythmFerret (Editor&);
61
62         void set_session (ARDOUR::Session*);
63         void on_response (int);
64
65 protected:
66         void on_hide ();
67
68 private:
69         Editor& editor;
70
71         Gtk::ComboBoxText operation_selector;
72
73         Gtk::ComboBoxText analysis_mode_selector;
74
75         /* transient detection widgets */
76
77         Gtk::Adjustment detection_threshold_adjustment;
78         Gtk::HScale detection_threshold_scale;
79         Gtk::Adjustment sensitivity_adjustment;
80         Gtk::HScale sensitivity_scale;
81         Gtk::Button analyze_button;
82
83         /* onset detection widgets */
84
85         Gtk::ComboBoxText onset_detection_function_selector;
86         Gtk::Adjustment peak_picker_threshold_adjustment;
87         Gtk::HScale peak_picker_threshold_scale;
88         Gtk::Adjustment silence_threshold_adjustment;
89         Gtk::HScale silence_threshold_scale;
90 #ifdef HAVE_AUBIO4
91         Gtk::Adjustment minioi_adjustment;
92         Gtk::HScale minioi_scale;
93 #endif
94
95         /* generic stuff */
96
97         Gtk::Adjustment trigger_gap_adjustment;
98         Gtk::SpinButton trigger_gap_spinner;
99
100         Gtk::Button action_button;
101
102         std::vector<std::string> analysis_mode_strings;
103         std::vector<std::string> onset_function_strings;
104         std::vector<std::string> operation_strings;
105
106         ARDOUR::AnalysisFeatureList current_results;
107
108         void clear_transients ();
109         /** Regions that we have added transient marks to */
110         RegionSelection regions_with_transients;
111
112         AnalysisMode get_analysis_mode () const;
113         Action get_action() const;
114         void analysis_mode_changed ();
115         int get_note_onset_function ();
116
117         void run_analysis ();
118         int run_percussion_onset_analysis (boost::shared_ptr<ARDOUR::Readable> region, ARDOUR::frameoffset_t offset, ARDOUR::AnalysisFeatureList& results);
119         int run_note_onset_analysis (boost::shared_ptr<ARDOUR::Readable> region, ARDOUR::frameoffset_t offset, ARDOUR::AnalysisFeatureList& results);
120
121         void do_action ();
122         void do_split_action ();
123         void do_region_split (RegionView* rv, const ARDOUR::AnalysisFeatureList&);
124 };
125
126 #endif /* __gtk2_ardour_rhythm_ferret_h__ */