2 Copyright (C) 2005-2006 Paul Davis
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.
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.
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.
20 #ifndef __ardour_sfdb_ui_h__
21 #define __ardour_sfdb_ui_h__
27 #include <sigc++/signal.h>
29 #include <gtkmm/stock.h>
30 #include <gtkmm/box.h>
31 #include <gtkmm/button.h>
32 #include <gtkmm/checkbutton.h>
33 #include <gtkmm/comboboxtext.h>
34 #include <gtkmm/dialog.h>
35 #include <gtkmm/entry.h>
36 #include <gtkmm/filechooserwidget.h>
37 #include <gtkmm/frame.h>
38 #include <gtkmm/label.h>
39 #include <gtkmm/scale.h>
40 #include <gtkmm/textview.h>
41 #include <gtkmm/table.h>
42 #include <gtkmm/liststore.h>
43 #include <gtkmm/spinbutton.h>
44 #include <gtkmm/notebook.h>
47 #include "ardour/audiofilesource.h"
48 #include "ardour/session_handle.h"
50 #include "ardour_window.h"
52 #include "audio_clock.h"
53 #include "instrument_selector.h"
62 class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr, public PBD::ScopedConnectionList
65 SoundFileBox (bool persistent);
66 virtual ~SoundFileBox () {};
68 void set_session (ARDOUR::Session* s);
69 bool setup_labels (const std::string& filename);
72 bool audition_oneshot();
73 bool autoplay () const;
74 void set_src_quality(ARDOUR::SrcQuality q) { _src_quality = q; }
75 void set_import_position(Editing::ImportPosition p) { _import_position = p; }
80 ARDOUR::SoundFileInfo sf_info;
87 Gtk::Label samplerate;
91 Gtk::Label channels_value;
92 Gtk::Label samplerate_value;
93 Gtk::Label tempomap_value;
95 Gtk::Label format_text;
96 AudioClock length_clock;
97 AudioClock timecode_clock;
99 Gtk::Frame border_frame;
100 Gtk::Label preview_label;
102 Gtk::TextView tags_entry;
106 Gtk::HBox bottom_box;
108 Gtk::Button play_btn;
109 Gtk::Button stop_btn;
110 Gtk::CheckButton autoplay_btn;
111 Gtk::Button apply_btn;
112 Gtk::HScale seek_slider;
114 PBD::ScopedConnectionList auditioner_connections;
115 void audition_active(bool);
116 void audition_progress(ARDOUR::samplecnt_t, ARDOUR::samplecnt_t);
118 void update_autoplay ();
119 void autoplay_toggled ();
121 bool tags_entry_left (GdkEventFocus* event);
122 void tags_changed ();
123 void save_tags (const std::vector<std::string>&);
124 void stop_audition ();
125 bool seek_button_press(GdkEventButton*);
126 bool seek_button_release(GdkEventButton*);
128 ARDOUR::SrcQuality _src_quality;
129 Editing::ImportPosition _import_position;
132 class SoundFileBrowser : public ArdourWindow
135 class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
138 Gtk::TreeModelColumn<std::string> pathname;
140 FoundTagColumns() { add(pathname); }
143 class FreesoundColumns : public Gtk::TreeModel::ColumnRecord
146 Gtk::TreeModelColumn<std::string> id;
147 Gtk::TreeModelColumn<std::string> uri;
148 Gtk::TreeModelColumn<std::string> filename;
149 Gtk::TreeModelColumn<std::string> duration;
150 Gtk::TreeModelColumn<std::string> filesize;
151 Gtk::TreeModelColumn<std::string> smplrate;
152 Gtk::TreeModelColumn<std::string> license;
153 Gtk::TreeModelColumn<bool> started;
167 FoundTagColumns found_list_columns;
168 Glib::RefPtr<Gtk::ListStore> found_list;
170 FreesoundColumns freesound_list_columns;
171 Glib::RefPtr<Gtk::ListStore> freesound_list;
173 Gtk::Button freesound_more_btn;
174 Gtk::Button freesound_similar_btn;
176 void handle_freesound_results(std::string theString);
179 SoundFileBrowser (std::string title, ARDOUR::Session* _s, bool persistent);
180 virtual ~SoundFileBrowser ();
183 int status () const { return _status; }
185 virtual void set_session (ARDOUR::Session*);
186 std::vector<std::string> get_paths ();
188 void clear_selection ();
190 Gtk::FileChooserWidget chooser;
192 SoundFileBox preview;
194 Gtk::Entry found_entry;
195 Gtk::Button found_search_btn;
196 Gtk::TreeView found_list_view;
198 Gtk::Entry freesound_entry;
199 Gtk::ComboBoxText freesound_sort;
201 Gtk::Button freesound_search_btn;
202 Gtk::TreeView freesound_list_view;
203 Gtk::Notebook notebook;
205 void freesound_search();
206 void refresh_display(std::string ID, std::string file);
209 bool resetting_ourselves;
214 Gtk::FileFilter audio_and_midi_filter;
215 Gtk::FileFilter audio_filter;
216 Gtk::FileFilter midi_filter;
217 Gtk::FileFilter custom_filter;
218 Gtk::FileFilter matchall_filter;
222 Gtk::Button import_button;
224 static std::string persistent_folder;
227 Gtk::VBox meter_packer;
228 void add_gain_meter ();
229 void remove_gain_meter ();
231 void start_metering ();
232 void stop_metering ();
233 sigc::connection metering_connection;
235 void update_preview ();
237 void found_list_view_selected ();
238 void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
239 void found_search_clicked ();
241 void freesound_list_view_selected ();
242 void freesound_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
243 void freesound_search_clicked ();
244 void freesound_more_clicked ();
245 void freesound_similar_clicked ();
248 void chooser_file_activated ();
249 std::string freesound_get_audio_file(Gtk::TreeIter iter);
251 bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
252 bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
253 bool on_audio_and_midi_filter (const Gtk::FileFilter::Info& filter_info);
255 void set_action_sensitive (bool);
256 bool get_action_sensitive () const;
258 virtual bool reset_options () { return true; }
261 bool on_key_press_event (GdkEventKey*);
262 virtual void do_something(int action);
265 class SoundFileChooser : public SoundFileBrowser
268 SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
269 virtual ~SoundFileChooser () {};
271 std::string get_filename ();
277 class SoundFileOmega : public SoundFileBrowser
280 SoundFileOmega (std::string title,
282 uint32_t selected_audio_tracks,
283 uint32_t selected_midi_tracks,
285 Editing::ImportMode mode_hint = Editing::ImportAsTrack);
287 void reset (uint32_t selected_audio_tracks, uint32_t selected_midi_tracks);
289 Gtk::ComboBoxText action_combo;
290 Gtk::ComboBoxText where_combo;
291 Gtk::ComboBoxText channel_combo;
292 Gtk::ComboBoxText src_combo;
293 Gtk::ComboBoxText midi_track_name_combo;
294 InstrumentSelector instrument_combo;
296 Gtk::CheckButton copy_files_btn;
297 Gtk::CheckButton smf_tempo_btn;
299 void set_mode (Editing::ImportMode);
300 Editing::ImportMode get_mode() const;
301 ARDOUR::MidiTrackNameSource get_midi_track_name_source () const;
302 bool get_use_smf_tempo_map () const;
303 Editing::ImportPosition get_position() const;
304 Editing::ImportDisposition get_channel_disposition() const;
305 ARDOUR::SrcQuality get_src_quality() const;
311 uint32_t selected_audio_track_cnt;
312 uint32_t selected_midi_track_cnt;
314 typedef std::map<std::string,Editing::ImportDisposition> DispositionMap;
315 DispositionMap disposition_map;
319 Gtk::VBox block_three;
320 Gtk::VBox block_four;
322 bool check_info (const std::vector<std::string>& paths,
323 bool& same_size, bool& src_needed, bool& multichannel);
325 static bool check_link_status (const ARDOUR::Session*, const std::vector<std::string>& paths);
327 void file_selection_changed ();
328 bool reset_options ();
329 void reset_options_noret ();
330 bool bad_file_message ();
331 void src_combo_changed ();
332 void where_combo_changed ();
334 void do_something (int action);
337 bool _reset_post_import;
340 #endif // __ardour_sfdb_ui_h__