2 * Copyright (C) 2005-2007 Taybin Rutkin <taybin@taybin.com>
3 * Copyright (C) 2006-2017 Paul Davis <paul@linuxaudiosystems.com>
4 * Copyright (C) 2008-2014 David Robillard <d@drobilla.net>
5 * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
6 * Copyright (C) 2012-2017 Robin Gareus <robin@gareus.org>
7 * Copyright (C) 2013 Colin Fletcher <colin.m.fletcher@googlemail.com>
8 * Copyright (C) 2015-2017 Tim Mayberry <mojofunk@gmail.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __ardour_sfdb_ui_h__
26 #define __ardour_sfdb_ui_h__
32 #include <sigc++/signal.h>
34 #include <gtkmm/stock.h>
35 #include <gtkmm/box.h>
36 #include <gtkmm/button.h>
37 #include <gtkmm/checkbutton.h>
38 #include <gtkmm/comboboxtext.h>
39 #include <gtkmm/dialog.h>
40 #include <gtkmm/entry.h>
41 #include <gtkmm/filechooserwidget.h>
42 #include <gtkmm/frame.h>
43 #include <gtkmm/label.h>
44 #include <gtkmm/scale.h>
45 #include <gtkmm/textview.h>
46 #include <gtkmm/table.h>
47 #include <gtkmm/liststore.h>
48 #include <gtkmm/spinbutton.h>
49 #include <gtkmm/notebook.h>
52 #include "ardour/audiofilesource.h"
53 #include "ardour/session_handle.h"
55 #include "ardour_window.h"
57 #include "audio_clock.h"
58 #include "instrument_selector.h"
67 class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr, public PBD::ScopedConnectionList
70 SoundFileBox (bool persistent);
71 virtual ~SoundFileBox () {};
73 void set_session (ARDOUR::Session* s);
74 bool setup_labels (const std::string& filename);
77 bool audition_oneshot();
78 bool autoplay () const;
79 void set_src_quality(ARDOUR::SrcQuality q) { _src_quality = q; }
80 void set_import_position(Editing::ImportPosition p) { _import_position = p; }
85 ARDOUR::SoundFileInfo sf_info;
92 Gtk::Label samplerate;
96 Gtk::Label channels_value;
97 Gtk::Label samplerate_value;
98 Gtk::Label tempomap_value;
100 Gtk::Label format_text;
101 AudioClock length_clock;
102 AudioClock timecode_clock;
104 Gtk::Frame border_frame;
105 Gtk::Label preview_label;
107 Gtk::TextView tags_entry;
111 Gtk::HBox bottom_box;
113 Gtk::Button play_btn;
114 Gtk::Button stop_btn;
115 Gtk::CheckButton autoplay_btn;
116 Gtk::Button apply_btn;
117 Gtk::HScale seek_slider;
119 PBD::ScopedConnectionList auditioner_connections;
120 void audition_active(bool);
121 void audition_progress(ARDOUR::samplecnt_t, ARDOUR::samplecnt_t);
123 void update_autoplay ();
124 void autoplay_toggled ();
126 bool tags_entry_left (GdkEventFocus* event);
127 void tags_changed ();
128 void save_tags (const std::vector<std::string>&);
129 void stop_audition ();
130 bool seek_button_press(GdkEventButton*);
131 bool seek_button_release(GdkEventButton*);
133 ARDOUR::SrcQuality _src_quality;
134 Editing::ImportPosition _import_position;
137 class SoundFileBrowser : public ArdourWindow
140 class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
143 Gtk::TreeModelColumn<std::string> pathname;
145 FoundTagColumns() { add(pathname); }
148 class FreesoundColumns : public Gtk::TreeModel::ColumnRecord
151 Gtk::TreeModelColumn<std::string> id;
152 Gtk::TreeModelColumn<std::string> uri;
153 Gtk::TreeModelColumn<std::string> filename;
154 Gtk::TreeModelColumn<std::string> duration;
155 Gtk::TreeModelColumn<std::string> filesize;
156 Gtk::TreeModelColumn<std::string> smplrate;
157 Gtk::TreeModelColumn<std::string> license;
158 Gtk::TreeModelColumn<bool> started;
172 FoundTagColumns found_list_columns;
173 Glib::RefPtr<Gtk::ListStore> found_list;
175 FreesoundColumns freesound_list_columns;
176 Glib::RefPtr<Gtk::ListStore> freesound_list;
178 Gtk::Button freesound_more_btn;
179 Gtk::Button freesound_similar_btn;
181 void handle_freesound_results(std::string theString);
184 SoundFileBrowser (std::string title, ARDOUR::Session* _s, bool persistent);
185 virtual ~SoundFileBrowser ();
188 int status () const { return _status; }
190 virtual void set_session (ARDOUR::Session*);
191 std::vector<std::string> get_paths ();
193 void clear_selection ();
195 Gtk::FileChooserWidget chooser;
197 SoundFileBox preview;
199 Gtk::Entry found_entry;
200 Gtk::Button found_search_btn;
201 Gtk::TreeView found_list_view;
203 Gtk::Entry freesound_entry;
204 Gtk::ComboBoxText freesound_sort;
206 Gtk::Button freesound_search_btn;
207 Gtk::TreeView freesound_list_view;
208 Gtk::Notebook notebook;
210 void freesound_search();
211 void refresh_display(std::string ID, std::string file);
214 bool resetting_ourselves;
219 Gtk::FileFilter audio_and_midi_filter;
220 Gtk::FileFilter audio_filter;
221 Gtk::FileFilter midi_filter;
222 Gtk::FileFilter custom_filter;
223 Gtk::FileFilter matchall_filter;
227 Gtk::Button import_button;
229 static std::string persistent_folder;
232 Gtk::VBox meter_packer;
233 void add_gain_meter ();
234 void remove_gain_meter ();
236 void start_metering ();
237 void stop_metering ();
238 sigc::connection metering_connection;
240 void update_preview ();
242 void found_list_view_selected ();
243 void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
244 void found_search_clicked ();
246 void freesound_list_view_selected ();
247 void freesound_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
248 void freesound_search_clicked ();
249 void freesound_more_clicked ();
250 void freesound_similar_clicked ();
253 void chooser_file_activated ();
254 std::string freesound_get_audio_file(Gtk::TreeIter iter);
256 bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
257 bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
258 bool on_audio_and_midi_filter (const Gtk::FileFilter::Info& filter_info);
260 void set_action_sensitive (bool);
261 bool get_action_sensitive () const;
263 virtual bool reset_options () { return true; }
266 bool on_key_press_event (GdkEventKey*);
267 virtual void do_something(int action);
270 class SoundFileChooser : public SoundFileBrowser
273 SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
274 virtual ~SoundFileChooser () {};
276 std::string get_filename ();
282 class SoundFileOmega : public SoundFileBrowser
285 SoundFileOmega (std::string title,
287 uint32_t selected_audio_tracks,
288 uint32_t selected_midi_tracks,
290 Editing::ImportMode mode_hint = Editing::ImportAsTrack);
292 void reset (uint32_t selected_audio_tracks, uint32_t selected_midi_tracks);
294 Gtk::ComboBoxText action_combo;
295 Gtk::ComboBoxText where_combo;
296 Gtk::ComboBoxText channel_combo;
297 Gtk::ComboBoxText src_combo;
298 Gtk::ComboBoxText midi_track_name_combo;
299 InstrumentSelector instrument_combo;
301 Gtk::CheckButton copy_files_btn;
302 Gtk::CheckButton smf_tempo_btn;
304 void set_mode (Editing::ImportMode);
305 Editing::ImportMode get_mode() const;
306 ARDOUR::MidiTrackNameSource get_midi_track_name_source () const;
307 bool get_use_smf_tempo_map () const;
308 Editing::ImportPosition get_position() const;
309 Editing::ImportDisposition get_channel_disposition() const;
310 ARDOUR::SrcQuality get_src_quality() const;
316 uint32_t selected_audio_track_cnt;
317 uint32_t selected_midi_track_cnt;
319 typedef std::map<std::string,Editing::ImportDisposition> DispositionMap;
320 DispositionMap disposition_map;
324 Gtk::VBox block_three;
325 Gtk::VBox block_four;
327 bool check_info (const std::vector<std::string>& paths,
328 bool& same_size, bool& src_needed, bool& multichannel, bool& must_copy);
330 static bool check_link_status (const ARDOUR::Session*, const std::vector<std::string>& paths);
332 void instrument_combo_changed ();
334 void file_selection_changed ();
335 bool reset_options ();
336 void reset_options_noret ();
337 bool bad_file_message ();
338 void src_combo_changed ();
339 void where_combo_changed ();
341 void do_something (int action);
344 bool _reset_post_import;
347 #endif // __ardour_sfdb_ui_h__