ardour
sfdb_ui.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2005-2006 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 __ardour_sfdb_ui_h__
21 #define __ardour_sfdb_ui_h__
22 
23 #include <string>
24 #include <vector>
25 #include <map>
26 
27 #include <sigc++/signal.h>
28 
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>
45 
46 
47 #include "ardour/audiofilesource.h"
48 #include "ardour/session_handle.h"
49 
50 #include "ardour_window.h"
51 #include "editing.h"
52 #include "audio_clock.h"
53 #include "instrument_selector.h"
54 
55 namespace ARDOUR {
56  class Session;
57 };
58 
59 class GainMeter;
60 class Mootcher;
61 
62 class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr, public PBD::ScopedConnectionList
63 {
64  public:
65  SoundFileBox (bool persistent);
66  virtual ~SoundFileBox () {};
67 
68  void set_session (ARDOUR::Session* s);
69  bool setup_labels (const std::string& filename);
70 
71  void audition();
72  bool audition_oneshot();
73  bool autoplay () const;
76 
77  protected:
78  std::string path;
79 
81 
82  Gtk::Table table;
83 
84  Gtk::Label length;
85  Gtk::Label format;
86  Gtk::Label channels;
87  Gtk::Label samplerate;
88  Gtk::Label timecode;
89 
90  Gtk::Label channels_value;
91  Gtk::Label samplerate_value;
92 
93  Gtk::Label format_text;
96 
97  Gtk::Frame border_frame;
98  Gtk::Label preview_label;
99 
100  Gtk::TextView tags_entry;
101 
102  Gtk::VBox main_box;
103  Gtk::VBox path_box;
104  Gtk::HBox bottom_box;
105 
106  Gtk::Button play_btn;
107  Gtk::Button stop_btn;
108  Gtk::CheckButton autoplay_btn;
109  Gtk::Button apply_btn;
110  Gtk::HScale seek_slider;
111 
113  void audition_active(bool);
115 
116  bool tags_entry_left (GdkEventFocus* event);
117  void tags_changed ();
118  void save_tags (const std::vector<std::string>&);
119  void stop_audition ();
120  bool seek_button_press(GdkEventButton*);
121  bool seek_button_release(GdkEventButton*);
122  bool _seeking;
125 };
126 
128 {
129  private:
130  class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
131  {
132  public:
133  Gtk::TreeModelColumn<std::string> pathname;
134 
135  FoundTagColumns() { add(pathname); }
136  };
137 
138  class FreesoundColumns : public Gtk::TreeModel::ColumnRecord
139  {
140  public:
141  Gtk::TreeModelColumn<std::string> id;
142  Gtk::TreeModelColumn<std::string> uri;
143  Gtk::TreeModelColumn<std::string> filename;
144  Gtk::TreeModelColumn<std::string> duration;
145  Gtk::TreeModelColumn<std::string> filesize;
146  Gtk::TreeModelColumn<std::string> smplrate;
147  Gtk::TreeModelColumn<std::string> license;
148  Gtk::TreeModelColumn<bool> started;
149 
151  add(id);
152  add(filename);
153  add(uri);
154  add(duration);
155  add(filesize);
156  add(smplrate);
157  add(license);
158  add(started);
159  }
160  };
161 
163  Glib::RefPtr<Gtk::ListStore> found_list;
164 
166  Glib::RefPtr<Gtk::ListStore> freesound_list;
167 
168  Gtk::Button freesound_more_btn;
170 
171  void handle_freesound_results(std::string theString);
172  public:
173  SoundFileBrowser (std::string title, ARDOUR::Session* _s, bool persistent);
174  virtual ~SoundFileBrowser ();
175 
176  int run ();
177  int status () const { return _status; }
178 
179  virtual void set_session (ARDOUR::Session*);
180  std::vector<std::string> get_paths ();
181 
182  void clear_selection ();
183 
184  Gtk::FileChooserWidget chooser;
185 
187 
188  Gtk::Entry found_entry;
189  Gtk::Button found_search_btn;
190  Gtk::TreeView found_list_view;
191 
192  Gtk::Entry freesound_entry;
193  Gtk::ComboBoxText freesound_sort;
194 
195  Gtk::Button freesound_search_btn;
196  Gtk::TreeView freesound_list_view;
197  Gtk::Notebook notebook;
198 
199  void freesound_search();
200  void refresh_display(std::string ID, std::string file);
201 
202  protected:
204  int matches;
205  int _status;
206  bool _done;
207 
208  Gtk::FileFilter audio_and_midi_filter;
209  Gtk::FileFilter audio_filter;
210  Gtk::FileFilter midi_filter;
211  Gtk::FileFilter custom_filter;
212  Gtk::FileFilter matchall_filter;
213  Gtk::HBox hpacker;
214  Gtk::VBox vpacker;
215 
216  Gtk::Button ok_button;
217  Gtk::Button cancel_button;
218  Gtk::Button apply_button;
219 
220  static std::string persistent_folder;
221 
222 
224  Gtk::VBox meter_packer;
225  void add_gain_meter ();
226  void remove_gain_meter ();
227  void meter ();
228  void start_metering ();
229  void stop_metering ();
230  sigc::connection metering_connection;
231 
232  void update_preview ();
233 
234  void found_list_view_selected ();
235  void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
236  void found_search_clicked ();
237 
239  void freesound_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
240  void freesound_search_clicked ();
241  void freesound_more_clicked ();
244 
245  void chooser_file_activated ();
246  std::string freesound_get_audio_file(Gtk::TreeIter iter);
247 
248  bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
249  bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
250  bool on_audio_and_midi_filter (const Gtk::FileFilter::Info& filter_info);
251 
252  void set_action_sensitive (bool);
253 
254  virtual bool reset_options() { return true; }
255 
256  protected:
257  void on_show();
258  virtual void do_something (int action);
259 };
260 
262 {
263  public:
264  SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
265  virtual ~SoundFileChooser () {};
266 
267  std::string get_filename ();
268 
269  protected:
270  void on_hide();
271 };
272 
274 {
275 
276  public:
277  SoundFileOmega (std::string title, ARDOUR::Session* _s,
278  uint32_t selected_audio_tracks, uint32_t selected_midi_tracks,
279  bool persistent,
280  Editing::ImportMode mode_hint = Editing::ImportAsTrack);
281 
282  void reset (uint32_t selected_audio_tracks, uint32_t selected_midi_tracks);
283 
284  Gtk::ComboBoxText action_combo;
285  Gtk::ComboBoxText where_combo;
286  Gtk::ComboBoxText channel_combo;
287  Gtk::ComboBoxText src_combo;
289 
290  Gtk::CheckButton copy_files_btn;
291 
297 
298  protected:
299  void on_hide();
300 
301  private:
304 
305  typedef std::map<std::string,Editing::ImportDisposition> DispositionMap;
306  DispositionMap disposition_map;
307 
308  Gtk::HBox options;
309  Gtk::VBox block_two;
310  Gtk::VBox block_three;
311  Gtk::VBox block_four;
312 
313  bool check_info (const std::vector<std::string>& paths,
314  bool& same_size, bool& src_needed, bool& multichannel);
315 
316  static bool check_link_status (const ARDOUR::Session*, const std::vector<std::string>& paths);
317 
318  void file_selection_changed ();
319  bool reset_options ();
320  void reset_options_noret ();
321  bool bad_file_message ();
322  void src_combo_changed ();
323  void where_combo_changed ();
324 
325  void do_something (int action);
326 };
327 
328 #endif // __ardour_sfdb_ui_h__
Editing::ImportDisposition get_channel_disposition() const
Definition: sfdb_ui.cc:1901
void refresh_display(std::string ID, std::string file)
Definition: sfdb_ui.cc:1019
void set_src_quality(ARDOUR::SrcQuality q)
Definition: sfdb_ui.h:74
void file_selection_changed()
Definition: sfdb_ui.cc:1937
void handle_freesound_results(std::string theString)
Definition: sfdb_ui.cc:1108
Gtk::TreeView found_list_view
Definition: sfdb_ui.h:190
Gtk::ComboBoxText action_combo
Definition: sfdb_ui.h:284
void freesound_similar_clicked()
Definition: sfdb_ui.cc:1057
Gtk::TreeModelColumn< std::string > filesize
Definition: sfdb_ui.h:145
void audition()
Definition: sfdb_ui.cc:400
Gtk::ComboBoxText channel_combo
Definition: sfdb_ui.h:286
Gtk::HBox hpacker
Definition: sfdb_ui.h:213
void on_show()
Definition: sfdb_ui.cc:783
void freesound_list_view_activated(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *)
Definition: sfdb_ui.cc:809
void found_search_clicked()
Definition: sfdb_ui.cc:929
virtual ~SoundFileBox()
Definition: sfdb_ui.h:66
int freesound_page
Definition: sfdb_ui.h:243
Gtk::Frame border_frame
Definition: sfdb_ui.h:97
std::string get_filename()
Definition: sfdb_ui.cc:1642
bool tags_entry_left(GdkEventFocus *event)
Definition: sfdb_ui.cc:512
Gtk::Label samplerate
Definition: sfdb_ui.h:87
void set_action_sensitive(bool)
Definition: sfdb_ui.cc:769
std::string path
Definition: sfdb_ui.h:78
void audition_progress(ARDOUR::framecnt_t, ARDOUR::framecnt_t)
Definition: sfdb_ui.cc:252
FoundTagColumns found_list_columns
Definition: sfdb_ui.h:162
bool on_audio_filter(const Gtk::FileFilter::Info &filter_info)
Definition: sfdb_ui.cc:878
SoundFileChooser(std::string title, ARDOUR::Session *_s=0)
Definition: sfdb_ui.cc:1622
std::string freesound_get_audio_file(Gtk::TreeIter iter)
Definition: sfdb_ui.cc:954
Gtk::ComboBoxText freesound_sort
Definition: sfdb_ui.h:193
Gtk::ComboBoxText src_combo
Definition: sfdb_ui.h:287
void freesound_search_clicked()
Definition: sfdb_ui.cc:1038
Gtk::VBox path_box
Definition: sfdb_ui.h:103
static bool check_link_status(const ARDOUR::Session *, const std::vector< std::string > &paths)
Definition: sfdb_ui.cc:1585
Glib::RefPtr< Gtk::ListStore > found_list
Definition: sfdb_ui.h:163
void freesound_more_clicked()
Definition: sfdb_ui.cc:1047
ImportPosition
Definition: editing.h:158
Gtk::Entry found_entry
Definition: sfdb_ui.h:188
static std::string persistent_folder
Definition: sfdb_ui.h:220
void reset_options_noret()
Definition: sfdb_ui.cc:1287
Gtk::VBox block_three
Definition: sfdb_ui.h:310
void save_tags(const std::vector< std::string > &)
Definition: sfdb_ui.cc:538
std::map< std::string, Editing::ImportDisposition > DispositionMap
Definition: sfdb_ui.h:305
void audition_active(bool)
Definition: sfdb_ui.cc:243
void start_metering()
Definition: sfdb_ui.cc:858
void set_import_position(Editing::ImportPosition p)
Definition: sfdb_ui.h:75
uint32_t selected_audio_track_cnt
Definition: sfdb_ui.h:302
void src_combo_changed()
Definition: sfdb_ui.cc:1889
void chooser_file_activated()
Definition: sfdb_ui.cc:797
bool check_info(const std::vector< std::string > &paths, bool &same_size, bool &src_needed, bool &multichannel)
Definition: sfdb_ui.cc:1534
virtual void set_session(ARDOUR::Session *)
Definition: sfdb_ui.cc:815
void tags_changed()
Definition: sfdb_ui.cc:519
Gtk::FileFilter midi_filter
Definition: sfdb_ui.h:210
void found_list_view_activated(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *)
Definition: sfdb_ui.cc:803
SrcQuality
Definition: types.h:522
Gtk::FileChooserWidget chooser
Definition: sfdb_ui.h:184
Gtk::FileFilter custom_filter
Definition: sfdb_ui.h:211
Gtk::Notebook notebook
Definition: sfdb_ui.h:197
Gtk::Entry freesound_entry
Definition: sfdb_ui.h:192
Gtk::FileFilter audio_and_midi_filter
Definition: sfdb_ui.h:208
void on_hide()
Definition: sfdb_ui.cc:1846
void freesound_list_view_selected()
Definition: sfdb_ui.cc:980
Gtk::Label channels
Definition: sfdb_ui.h:86
bool _seeking
Definition: sfdb_ui.h:122
Gtk::Label length
Definition: sfdb_ui.h:84
Gtk::TreeModelColumn< std::string > duration
Definition: sfdb_ui.h:144
Gtk::VBox meter_packer
Definition: sfdb_ui.h:224
void freesound_search()
Definition: sfdb_ui.cc:1080
Gtk::CheckButton copy_files_btn
Definition: sfdb_ui.h:290
virtual bool reset_options()
Definition: sfdb_ui.h:254
Gtk::VBox block_four
Definition: sfdb_ui.h:311
bool reset_options()
Definition: sfdb_ui.cc:1295
Gtk::CheckButton autoplay_btn
Definition: sfdb_ui.h:108
Gtk::Label preview_label
Definition: sfdb_ui.h:98
Gtk::Button play_btn
Definition: sfdb_ui.h:106
void add_gain_meter()
Definition: sfdb_ui.cc:828
Gtk::Button freesound_search_btn
Definition: sfdb_ui.h:195
SoundFileBox preview
Definition: sfdb_ui.h:186
DispositionMap disposition_map
Definition: sfdb_ui.h:306
Editing::ImportPosition get_position() const
Definition: sfdb_ui.cc:1855
void where_combo_changed()
Definition: sfdb_ui.cc:1895
Gtk::Button apply_btn
Definition: sfdb_ui.h:109
InstrumentSelector instrument_combo
Definition: sfdb_ui.h:288
int64_t framecnt_t
Definition: types.h:76
std::vector< std::string > get_paths()
Definition: sfdb_ui.cc:1247
Gtk::TreeModelColumn< std::string > filename
Definition: sfdb_ui.h:143
Gtk::VBox vpacker
Definition: sfdb_ui.h:214
Gtk::TextView tags_entry
Definition: sfdb_ui.h:100
bool seek_button_release(GdkEventButton *)
Definition: sfdb_ui.cc:266
Gtk::Label format
Definition: sfdb_ui.h:85
Gtk::TreeModelColumn< std::string > pathname
Definition: sfdb_ui.h:133
Gtk::HBox options
Definition: sfdb_ui.h:308
FreesoundColumns freesound_list_columns
Definition: sfdb_ui.h:165
SoundFileOmega(std::string title, ARDOUR::Session *_s, uint32_t selected_audio_tracks, uint32_t selected_midi_tracks, bool persistent, Editing::ImportMode mode_hint=Editing::ImportAsTrack)
Definition: sfdb_ui.cc:1659
Definition: amp.h:29
bool audition_oneshot()
Definition: sfdb_ui.cc:393
bool autoplay() const
Definition: sfdb_ui.cc:387
Gtk::Button found_search_btn
Definition: sfdb_ui.h:189
Gtk::Button cancel_button
Definition: sfdb_ui.h:217
Gtk::FileFilter matchall_filter
Definition: sfdb_ui.h:212
ARDOUR::SoundFileInfo sf_info
Definition: sfdb_ui.h:80
Gtk::Button ok_button
Definition: sfdb_ui.h:216
Gtk::Label format_text
Definition: sfdb_ui.h:93
bool on_audio_and_midi_filter(const Gtk::FileFilter::Info &filter_info)
Definition: sfdb_ui.cc:890
Gtk::TreeModelColumn< std::string > smplrate
Definition: sfdb_ui.h:146
ImportMode
Definition: editing.h:148
SoundFileBrowser(std::string title, ARDOUR::Session *_s, bool persistent)
Definition: sfdb_ui.cc:544
void found_list_view_selected()
Definition: sfdb_ui.cc:906
Gtk::TreeModelColumn< bool > started
Definition: sfdb_ui.h:148
void set_mode(Editing::ImportMode)
Definition: sfdb_ui.cc:1834
void clear_selection()
Definition: sfdb_ui.cc:790
Gtk::ComboBoxText where_combo
Definition: sfdb_ui.h:285
GainMeter * gm
Definition: sfdb_ui.h:223
void remove_gain_meter()
Definition: sfdb_ui.cc:847
Gtk::HBox bottom_box
Definition: sfdb_ui.h:104
bool seek_button_press(GdkEventButton *)
Definition: sfdb_ui.cc:260
virtual void do_something(int action)
Definition: sfdb_ui.cc:776
Gtk::Button freesound_similar_btn
Definition: sfdb_ui.h:169
Gtk::FileFilter audio_filter
Definition: sfdb_ui.h:209
ImportDisposition
Definition: editing.h:168
Gtk::TreeModelColumn< std::string > id
Definition: sfdb_ui.h:141
Gtk::Label timecode
Definition: sfdb_ui.h:88
AudioClock timecode_clock
Definition: sfdb_ui.h:95
ARDOUR::SrcQuality get_src_quality() const
Definition: sfdb_ui.cc:1871
Gtk::TreeView freesound_list_view
Definition: sfdb_ui.h:196
Gtk::TreeModelColumn< std::string > uri
Definition: sfdb_ui.h:142
Gtk::Label channels_value
Definition: sfdb_ui.h:90
Gtk::TreeModelColumn< std::string > license
Definition: sfdb_ui.h:147
Gtk::VBox main_box
Definition: sfdb_ui.h:102
Gtk::Button freesound_more_btn
Definition: sfdb_ui.h:168
ARDOUR::SrcQuality _src_quality
Definition: sfdb_ui.h:123
Gtk::Table table
Definition: sfdb_ui.h:82
Gtk::HScale seek_slider
Definition: sfdb_ui.h:110
void reset(uint32_t selected_audio_tracks, uint32_t selected_midi_tracks)
Definition: sfdb_ui.cc:1920
Editing::ImportPosition _import_position
Definition: sfdb_ui.h:124
Gtk::Label samplerate_value
Definition: sfdb_ui.h:91
Editing::ImportMode get_mode() const
Definition: sfdb_ui.cc:1840
void stop_metering()
Definition: sfdb_ui.cc:864
virtual ~SoundFileBrowser()
Definition: sfdb_ui.cc:747
Gtk::Button stop_btn
Definition: sfdb_ui.h:107
void update_preview()
Definition: sfdb_ui.cc:896
bool setup_labels(const std::string &filename)
Definition: sfdb_ui.cc:274
sigc::connection metering_connection
Definition: sfdb_ui.h:230
Glib::RefPtr< Gtk::ListStore > freesound_list
Definition: sfdb_ui.h:166
SoundFileBox(bool persistent)
Definition: sfdb_ui.cc:122
bool resetting_ourselves
Definition: sfdb_ui.h:203
virtual ~SoundFileChooser()
Definition: sfdb_ui.h:265
Gtk::Button apply_button
Definition: sfdb_ui.h:218
int status() const
Definition: sfdb_ui.h:177
void set_session(ARDOUR::Session *s)
Definition: sfdb_ui.cc:224
bool on_midi_filter(const Gtk::FileFilter::Info &filter_info)
Definition: sfdb_ui.cc:884
PBD::ScopedConnectionList auditioner_connections
Definition: sfdb_ui.h:112
bool bad_file_message()
Definition: sfdb_ui.cc:1518
Gtk::VBox block_two
Definition: sfdb_ui.h:309
uint32_t selected_midi_track_cnt
Definition: sfdb_ui.h:303
void do_something(int action)
Definition: sfdb_ui.cc:1955
AudioClock length_clock
Definition: sfdb_ui.h:94
void stop_audition()
Definition: sfdb_ui.cc:504