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